reddit / emacs
What is the most appropriate way to set fonts in emacs?
sweet_demon · 2022-10-07 22:11
I'm a novice emacs user and I see several ways to set the editor fonts, I'd like to know which one is the most suitable.
TheFrenchPoulp · 2022-10-07 22:30
I set it to monospace and let my os determine what monospace mean
scottomyers · 2022-10-07 23:23
I like to use the customization menu.
1. Ctrl + Right Click > Options > Set Default Font
2. Choose the font
3. Ctrl + Right Click > Options > Save Options
[deleted] · 2022-10-08 01:07
[deleted]
wojtek-graj · 2022-10-08 01:28
I don't know if this is the best way, but I've had this in all my config files and It's been working fine:
```
(defun font-exists-p (font) (if (null (x-list-fonts font)) nil t))
(when (window-system)
(cond ((font-exists-p "Courier Prime") (set-frame-font "Courier Prime:spacing=100:size=18" nil t))
((font-exists-p "Courier New") (set-frame-font "Courier New:spacing=100:size=18" nil t))))
```
Essentially, this is what the code does: only set font if not in terminal, then check if font exists and use it if it does, otherwise use a fallback font.
Obviously you can replace the names of the fonts with whichever fonts suit you.
rishianand · 2022-10-08 03:41
(set-frame-font "Iosevka Extended 12" nil t)
[deleted] · 2022-10-08 03:42
[deleted]
MotherCanada · 2022-10-08 04:20
`(set-face-attribute 'default nil :family "Cascadia Mono" :height 110)`
in early-init
NoisyFrequency · 2022-10-08 06:17
Lol chaotic neutral
tsengf · 2022-10-08 06:37
Not sure what is most suitable for you. This is what I have been using. Make sure you have the font specified installed.
(defvar my-font-name "SauceCode Pro Nerd Font"
"Text font to use.")
(defvar my-font-size 10 "Font size to use in points (for example, 10).")
(defvar my-font (format "%s-%f" my-font-name my-font-size))
(defun font-exists-p (font)
"Check if the FONT exists." (and (display-graphic-p) (not (null (x-list-fonts font)))))
(cond ((font-exists-p my-font)
(add-to-list 'default-frame-alist (font . ,my-font))
(add-to-list 'default-frame-alist(height . 50))
(add-to-list 'default-frame-alist (width . 170))
(add-to-list 'initial-frame-alist(font . ,my-font))
(add-to-list 'initial-frame-alist (height . 50))
(add-to-list 'initial-frame-alist(width . 170))))
[deleted] · 2022-10-08 09:21
[deleted]
aqua0210 · 2022-10-08 14:31
>(x-list-fonts "Courier Prime")
Thanks for sharing this useful function. I can remove my `font-installed-p` now.
It's more convenience to use a built-in function instead.
ForkInBrain · 2022-10-08 15:04
The manual's descriptions are pretty good: https://www.gnu.org/software/emacs/manual/html_node/emacs/Fonts.html
00-11 · 2022-10-08 17:39
This.
Or customize option `default-frame-alist` to use the font you want, by default.
ComfyRug · 2022-10-08 17:41
```
(condition-case nil
;; (set-frame-font "Iosevka SS09-12")
;; (set-frame-font "Go Mono-11")
;; (set-frame-font "Fira Mono-11")
;; (set-frame-font "Inconsolata-13")
;; (set-frame-font "Monospace-11")
;; (set-frame-font "Ubuntu Mono-13")
;; (set-frame-font "IBM Plex Mono-13")
;; (set-frame-font "Cascadia Code-14")
;; (set-frame-font "Jetbrains Mono-11")
;; (set-frame-font "Monaco-11")
(set-frame-font "Martian Mono-10")
;; (set-frame-font "Dina-10")
;; (set-frame-font "iAWriterDuospace-13")
;; (set-frame-font "Hermit-13")
;; (set-frame-font "Menlo-11")
;; (set-frame-font "Hack-14")
(error (set-frame-font "Monospace-11")))
```
I'll be honest, I don't over think it. Also, Martian Mono is a pretty cool font so far. Link: https://github.com/evilmartians/mono
sweet_demon · 2022-10-08 18:02
?