Emacs: Cycle Fonts by Command π
Here's commands that switch among font for current window. Especially useful for comparison of fonts.
put this in your Emacs Init File:
(defvar xah-font-list (cond ((eq system-type 'windows-nt) '( "Courier-10" "Lucida Console-10" "Segoe UI Symbol-12" "Lucida Sans Unicode-10" )) ((eq system-type 'gnu/linux) '( "DejaVu Sans Mono-10" "DejaVu Sans-10" "Symbola-13" )) ((eq system-type 'darwin) ; Mac '( ;; "Courier-16" "Menlo-15" "Iosevka-16" ))) "A list of fonts for `xah-cycle-font' to cycle from.") (defun xah-cycle-font (N) "Change font in current frame. Each time this is called, font cycles thru a predefined list of fonts in the variable `xah-font-list' . If N is 1, cycle forward. If N is -1, cycle backward. See also `xah-cycle-font-next', `xah-cycle-font-previous'. URL `http://xahlee.info/emacs/emacs/emacs_switching_fonts.html' Version: 2015-09-21" (interactive "p") ;; this function sets a property βstateβ. It is a integer. Possible values are any index to the fontList. (let (xfontToUse xstateBefore xstateAfter ) (setq xstateBefore (if (get 'xah-cycle-font 'state) (get 'xah-cycle-font 'state) 0)) (setq xstateAfter (% (+ xstateBefore (length xah-font-list) N) (length xah-font-list))) (setq xfontToUse (nth xstateAfter xah-font-list)) (set-frame-font xfontToUse t) ;; (set-frame-parameter nil 'font xfontToUse) (message "Current font is: %s" xfontToUse ) (put 'xah-cycle-font 'state xstateAfter))) (defun xah-cycle-font-next () "Switch to the next font, in current window. See `xah-cycle-font'." (interactive) (xah-cycle-font 1)) (defun xah-cycle-font-previous () "Switch to the previous font, in current window. See `xah-cycle-font'." (interactive) (xah-cycle-font -1))
Modify the variable list xah-font-list , so that you can use this function to cycle among the fonts of your choice.
To get a list of fonts in emacs, see Emacs Init: Setup Font.
You can set Ctrl+F7 and Ctrl+F8 to switch to the prev/next font. γsee Emacs Keys: Define Keyγ
Emacs, font setup
- Emacs: Change Font Size
- Emacs: Change Default Font Size by Command, for Current Session π
- Emacs: Get Character Info, Cursor Position
- Emacs: Toggle Monospace / Proportional Font
- Best Unicode Fonts for Programer
- Emacs: Cycle Fonts by Command π
- Emacs Init: Setup Font
- Emacs Init: Font for Unicode Symbols
- Emacs Init: Font for Emoji
- Emacs Init: Font for Chinese
- Emacs Init: Minibuffer Font Size
- Emacs Init: Variable Pitch Mode (Proportional Font)
- Elisp: Modify Default Face (Font)
- Emacs Init: Display Lambda as Ξ»