Emacs Init: Setup Font
This page shows you how to set font for emacs in init file.
Set Font to Init via Graphical User Interface Menu
Chose the menu:
- menu [Options ▸ Set Default Font…]
- menu [Options ▸ Save Options].
font setting is saved to the Emacs Init File in the custom-set-variables
section. 〔see Emacs Init: M-x customize〕
Manually Set Font in Init File
put this in your Emacs Init File:
;; set default font (cond ((eq system-type 'windows-nt) (when (member "Consolas" (font-family-list)) (set-frame-font "Consolas" t t))) ((eq system-type 'darwin) ; macOS (when (member "Menlo" (font-family-list)) (set-frame-font "Menlo" t t))) ((eq system-type 'gnu/linux) (when (member "DejaVu Sans Mono" (font-family-list)) (set-frame-font "DejaVu Sans Mono" t t))))
You can add a font size, e.g. replace
"Consolas"
to
"Consolas-14"
List available fonts
(print (font-family-list))
〔see Evaluate Emacs Lisp Code〕
Check if a font exist
;; returns true if Symbola exists (member "Symbola" (font-family-list))
How to install font
- Microsoft Windows: double click on the font.
- MacOS: double click on the font.
- Linux: How to Install Font, List Fonts
Restart emacs. Emacs should see it.
Reference
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 λ