reddit / emacs
setting fonts (doom emacs)
wwwfff0 · 2022-02-21 18:47
\*FIXED\*(had to modify use flags i made a post on r/gentoo about it)\[gentoo\]When i first opened doom emacs i gui mode my first reaction was: What is this horrible font?
So my second thaught was let's set a new font. I quickly serched how to set a new font in doom emacs so i added.:
`(setq doom-theme 'doom-dracula`
`doom-font (font-spec :family "FiraCode NerdFont" :size 12 :weight 'medium))`
(I have tried multiple variations such as: FiraCode, Fira Code fira-code etc...)
But i get this font not found error when i reopen emacs:
`Error running hook "doom-init-fonts" because: (error Font not available #<font-spec nil nil FiraCode NerdFont nil nil medium nil nil 12 nil nil nil nil>)`
Help whould be appreciated!
BobKoss · 2022-02-21 18:50
Have you installed the font in your operating system?
wwwfff0 · 2022-02-21 19:06
Yes,i use it for a lot of other programs as well.
Ybenel · 2022-02-21 19:26
open font manager and search Fira Code if it shows up then it's installed, click it and copy its name then restart emacs.
Ybenel · 2022-02-21 19:27
im pretty sure you typed Fira code font incorrectly,
hlissner · 2022-02-21 19:37
To quote the default config.el that `doom install` employs (assuming you've installed in the past week or so):
```
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
```
So use `M-x describe-font` to look up and search the available fonts _as Emacs/your OS_ see them. You should see a list of xlfd font strings. E.g.
```
-CTDB-Fira Code-bold-normal-normal-*-*-*-*-*-m-0-iso10646-1
-CTDB-Fira Code-light-normal-normal-*-*-*-*-*-m-0-iso10646-1
-CTDB-Fira Code-medium-normal-normal-*-*-*-*-*-m-0-iso10646-1
-CTDB-Fira Code-regular-normal-normal-*-*-*-*-*-m-0-iso10646-1
-CTDB-Fira Code-semibold-normal-normal-*-*-*-*-*-m-0-iso10646-1
-CTDB-Fira Code-regular-normal-normal-*-10-*-*-*-m-0-fontset-startup
-CTDB-Fira Code Symbol-regular-normal-normal-*-*-*-*-*-*-0-iso10646-1
```
In my case, I can deduce that `Fira Code` is the correct family name to use. If no Fira Code entries show up on this list (or `$ fc-list | grep fira` on the command line), then the font hasn't been installed correctly.
I think it's most likely that your font is (internally) named `FiraCode Nerd Font` or `Fira Code Nerd Font` (note the frustratingly subtle difference in whitespace).
hlissner · 2022-02-21 19:43
Oh, another possibility (in case my earlier advice yields no solution): Emacs couldn't find a `medium` weight version of `FiraCode NerdFont`, specifically. Try playing with the `:weight` (or omit it entirely).
wwwfff0 · 2022-02-21 19:47
`fc-list | grep fira`
return the fira fonts installed on the system.But `M-x describe-font` does not.
wwwfff0 · 2022-02-21 20:00
I think i installed the font incorrectly,but then why does it show up in all other programs except emacs.
thatsrelativity · 2022-02-21 20:59
You've probably mistyped the font family. If you have some kid of font browser (font book on mac; not sure what the equivalent is for linux) find the font in there and copy the name. I think you probably want "FiraCode Nerd Font" (with a space between Nerd and Font) but it's hard to say for certain without knowing what it's called on your system
FrozenOnPluto · 2022-02-21 21:12
You should probably specify what OS and what build of Emacs you're running; like.. is it a Mac, or Windows or Linux or which? Does the build have support for the font type (ttf, etc)?
Like on a Mac, you need to install it via Fontbook or something? On linux/BSD you commonly drop the ttfs into ~/.local/share/fonts/ .. but every OS and distro does things differently, sadly.
I don't use doom, just mod the hack out of vanilla, but I essentially just call this to set the default font:
(set-face-attribute 'default nil :family "Consolas" :height 110)
(But then, I also have to set it in other contexts, like for shells, for dired, etc)
If you're looking for 'all the icons' and other 'font icon packs', those have some other steps too
Good luck in your font journey!
Schievel1 · 2022-02-21 21:46
hm i am having the very same problem right now. font shows up in fc-list but not in describe-fonts in emacs.
Schievel1 · 2022-02-21 23:05
are you on gentoo? because if so, emerging emacs with USE-flag json does the trick. (and if you built emacs yourself there should be a similar flag for ./configure or something)
kikechan · 2022-02-22 14:26
Use `counsel-fonts` to get a list of fonts that emacs can access.
Try using font-manager (comes with gnome, I think).
Try running `fc-cache -fv`
wwwfff0 · 2022-02-22 16:01
I emerged it with the json USE-flag but it still doesen't recognise the fonts.
Schievel1 · 2022-02-22 21:56
Hm I am quite confident that this is not a coincidence that we are both on gentoo and both having the exact same problem.
The only other use flag I have enabled for emacs is xft.
But I can reproduce this behavior this way: if I emerge with USE flags xft and json fonts work fine, if I emerge with only xft fonts don’t work. So I figured that json was the missing use flag, but it could be that you need both of them, xft and json.
BetImpressive8980 · 2022-02-23 08:05
i had the EXACT same issue today when i emerged it with only xft
im emerging again with json
yup its working nwo