Emacs: Proportional Font

By Xah Lee. Date: .
emacs variable pitch mode
M-x variable-pitch-mode.
emacs variable-pitch-mode 2015-09-21
M-x variable-pitch-mode, for reading code.

Alt+x variable-pitch-mode to toggle between fixed-width and variable-width font. (monospace vs proportional)

The font change is for current file/buffer only.

Proportional font is useful for reading info doc, email, etc. Proportional font is easier to read, and shows 20 or more characters per line. It also works great for coding too (except Python). Try it. You may be surprised.

(Thanks to Oscar Carlsson for suggesting variable-pitch-mode.)

Setup Proportional Font by Major Mode

Here's how to make some mode always use proportional font.

(progn
  ;; use variable-width font for some modes
  (defun xah-use-variable-width-font ()
    "Set current buffer to use variable-width font."
    (variable-pitch-mode 1)
    ;; (text-scale-increase 0.5 )
    )
  (add-hook 'nxml-mode-hook 'xah-use-variable-width-font)
  (add-hook 'emacs-lisp-mode-hook 'xah-use-variable-width-font)
  (add-hook 'js-mode-hook 'xah-use-variable-width-font)
  (add-hook 'css-mode-hook 'xah-use-variable-width-font)
  (add-hook 'html-mode-hook 'xah-use-variable-width-font)
  )

Alternatively, you can use the following code:

(defun xah-set-font-to-monospace ()
  "Change font in current window to a monospaced font."
  (interactive)
  (set-frame-font "DejaVu Sans Mono" t)
  )

(defun xah-set-font-to-variable-width ()
  "Change font in current window to a variable-width font."
  (interactive)
  (set-frame-font "DejaVu Sans" t)
  )

〔►see Emacs: Font Configuration

Font/Unicode Topic

  1. Emacs: Unicode Tutorial
  2. Emacs File Encoding FAQ
  3. Unicode Basics: What's Character Set, Character Encoding, UTF-8?
  4. Emacs: Xah Math Input Mode
  5. Emacs: Xah Unicode Browser Mode

  1. Best Unicode Fonts for Programer
  2. Emacs: Font Configuration
  3. Emacs: Proportional Font
  4. Emacs: Cycle Fonts by Command
  5. Emacs: Set Line Spacing
  6. Emacs: toggle-word-wrap
  7. Emacs Lisp: Unicode Representation in String
Like it? Buy Xah Emacs Tutorial. Thanks.