reddit / emacs

Emacs ignoring Operator Mono ligature font on startup, regular operator mono font works fine

Osiris834 · 2022-09-07 00:06
Hello, I'm running Emacs 28.1 and am fairly new, [get my init file here](https://pastebin.com/DvCVQ56M) and I'm trying to get it to do ligature functionality with Operator Mono adapted for ligatures. I've been following the FiraCode instructions, but they should do pretty much the same thing. The problem is whenever I start a new instance of Emacs, it doesn't render in the operator mono ligature font at first, it goes to another one. When I specify regular operator mono in the menu, it renders, saves, and new instances load just fine. The ligature operator mono, renders perfectly with the ligatures if I if set the default font in the menu, but new instances of emacs don't load the font. The `emacs --debug-init` returned literally nothing. ​ Please be nice as I'm new to emacs Help is much appreciated, cheers!
billydeath · 2022-09-07 00:51
Are you running as a daemon and connecting with a client? I've found this causes issues with fonts for me. "Fixed" it by creating a function to call all the font settings I like to change, then call it with the following hooks: `;; run this hook after we have initialised the first time(add-hook 'after-init-hook 'my-setup-font-faces)` `;; re-run this hook if we create a new frame from daemonised Emacs(add-hook 'server-after-make-frame-hook 'my-setup-font-faces)` Just be aware if you are setting fonts for packages loaded later in your init file (e.g. org-mode, etc.), then your function & hooks will need to be after those packages in your init, otherwise you'll get warnings about unknown faces specific to those packages. Here's my version of the function to give you some ideas: (defun my-setup-font-faces () (when (display-graphic-p) ;; set default font (set-face-attribute 'default nil :font "UbuntuMono Nerd Font" :height 150 :weight 'regular) ;; Set the fixed pitch face (set-face-attribute 'fixed-pitch nil :font "UbuntuMono Nerd Font" :height 170 :weight 'regular) ;; Set comments to italic (set-face-attribute 'font-lock-comment-face nil :font "UbuntuMono Nerd Font" :height 170 :italic t) ;; Set the variable pitch face which is the same for mac and linux (set-face-attribute 'variable-pitch nil :font "Overpass Nerd Font" :height 170 :weight 'light) ;; Modify which key separator font/size to prevent 'spillover' in the minibuffer (set-face-attribute 'which-key-separator-face nil :font "UbuntuMono Nerd Font" :italic nil :height 90) ;; Change which key help font size for legibility (set-face-attribute 'which-key-note-face nil :font "UbuntuMono Nerd Font" :italic nil :height 120) ;; Change info face in documentation (set-face-attribute 'Info-quoted nil :font "Ubuntu Mono" :height 170) ;; Mode line height (set-face-attribute 'mode-line nil :height 130) ;; after org-mode we want to adjust font sizes (with-eval-after-load 'org (dolist (face '((org-level-1 . 1.2) (org-level-2 . 1.15) (org-level-3 . 1.1) (org-level-4 . 1.05) (org-level-5 . 1.0) (org-level-6 . 1.0) (org-level-7 . 1.0) (org-level-8 . 1.0))) (set-face-attribute (car face) nil :font "Overpass Nerd Font" :weight 'regular :height (cdr face)) ) ;; Ensure that anything that should be fixed-pitch in Org files appears that way (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch) (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch)) (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) ) (set-face-attribute 'org-document-title nil :inherit '(shadow variable-pitch) :height 200) ) )
Osiris834 · 2022-09-07 07:14
I'm not running emacs as a daemon, I tried making a hook to run on after init, it froze up (maybe I wrote it wrong? not used to lisp.) and didn't show the welcome screen nor loaded the font. I installed FiraCode, and the ligatures seem to load just fine upon start up, I'm suspecting the problem lies with my font. I'm going to try to adjust the names and see if things start working
billydeath · 2022-09-07 07:49
You should be able to get the exact font name (assuming you're on Linux) with: `fc-list | grep -i firacode` or whatever font/variant you're looking for. Using the name that comes up after the colon (:) and before the style section after the second colon works for me. If you're not running Emacs as a daemon then the solution I posted possibly isn't relevant. It's basically setting every thing up then when a graphical frame is created, it calls the function. Not sure if font settings is an issue with Emacs 28 specifically, but it might be worth checking out the mailing list/bug tracker to see if someone has a better solution if none of this works. Good luck - it can be a bit confusing at first, but the more you tinker, the more you'll learn!
Osiris834 · 2022-09-07 08:23
Thank you! I've kind of done another option is using firacode for the ligatures (because that one works fine apparently) and then making face rules to use the Operator Mono Italics where needed. For future readers: the problem is with the font itself, customize the faces so the cursive italics are where you want them.