Using C-x C-+ and C-x C-- (text-scale-adjust) is very convenient to increase/decrease the font size in one buffer. This is nice to reduce head bumping when a few people work together in front of the same monitor.

Is there a way to increase (and later decrease) the font size in one frame (or all frames simultaneously)? I am wondering if there is a way faster than 1- retyping C-x C-+ in each new buffer, 2- Calling M-x x-select-font and using the mouse to choose, and 3- running elisp code in the scratch buffer.

Update:

If you are interested in satisfying not just 1-3 above but also:

4- Keep the size (and position) of the frame still.

Then look at this question.

up vote 2 down vote accepted

See the Emacs Wiki page about frame zooming.

It tells you about several ways to do this, including commands from libraries zoom-frm.el, doremi-frm.el, and frame-cmds.el.

In particular, the single command zoom-in/out lets you zoom either a frame or a buffer in or out. (The former: zooming a frame, is what you requested.)

This is not the most correct way to do it, I have in the past use these functions to do frame by frame resizing:

In this case it is done by changing the :height attribute of the default face.

(defun zoom-frame (&optional n frame amt)
  "Increase the default size of text by AMT inside FRAME N times.
  N can be given as a prefix arg.
  AMT will default to 10.
  FRAME will default the selected frame."
  (interactive "p")
  (let ((frame (or frame (selected-frame)))
        (height (+ (face-attribute 'default :height frame) (* n (or amt 10)))))
    (set-face-attribute 'default frame :height height)
    (when (called-interactively-p)
      (message "Set frame's default text height to %d." height))))

(defun zoom-frame-out (&optional n frame amt)
  "Call `zoom-frame' with -N."
  (interactive "p")
  (zoom-frame (- n) frame amt))


(global-set-key (kbd "C-c z i") 'zoom-frame)

(global-set-key (kbd "C-c z o") 'zoom-frame-out)

This scales the whole frame, not just the text, so it'll shrink or grow on your desktop, possibly growing outside the visibility bounds and requiring a redraw from your OS.

Another possible solution is which I may look into, is setting a frame local variable to a desired height and using a hook that runs each time a buffer is selected to redisplay the text in that buffer to the frame's desired size. This would work decently well unless a buffer was shown on two frames.

See http://www.emacswiki.org/emacs/GlobalTextScaleMode, or for a more general explanation: http://www.emacswiki.org/emacs/SetFonts#toc6

  • No, text scaling is not frame zooming. Global text scaling is just buffer zooming applied to all buffers. Frame and buffer zooming are two different things. See your second link for info about the differences. – Drew Jul 11 '14 at 21:31

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.