2008-12-01

zooming in/out

In some situations is nice if you can increase your font size in emacs. For example, when doing a presentation. This can be made very to do with emacs, with inspiration from blog.febuiles.com, which is no longer active (add to .emacs):
(defun djcb-zoom (n)
  "with positive N, increase the font size, otherwise decrease it"
  (set-face-attribute 'default (selected-frame) :height 
    (+ (face-attribute 'default :height) (* (if (> n 0) 1 -1) 10)))) 
It's more useful if we also have some keybindings for that. Let's make it the same one that compatible with FireFox and some other programs use; so, Ctrl-+ for zoom-in and Ctrl-- for zoom out, both on main keyboard and the numerical island. We add:
(global-set-key (kbd "C-+")      '(lambda nil (interactive) (djcb-zoom 1)))
(global-set-key [C-kp-add]       '(lambda nil (interactive) (djcb-zoom 1)))
(global-set-key (kbd "C--")      '(lambda nil (interactive) (djcb-zoom -1)))
(global-set-key [C-kp-subtract]  '(lambda nil (interactive) (djcb-zoom -1)))
Easy yet very useful; something like should be part of emacs... until, these simple functions will do.

2 comments:

Anonymous said...

In CVS-Emacs there's face-remap, which provides this feature.

Drew said...

See also:
http://emacswiki.org/emacs/SetFonts#toc4