commit f9be091b0e6bdab6d2e0e39529176244d0ec70f1
parent 6f7b9c2e9f1a671b46ae69425ed1d3f70831734c
Author: Ethan Long <me@ethandl.dev>
Date: Mon, 29 Jun 2026 19:02:58 +1000
Some improvements to font management and better defaults
Diffstat:
| M | config.org | | | 48 | +++++++++++++++++++++++++++++++++++++++--------- |
1 file changed, 39 insertions(+), 9 deletions(-)
diff --git a/config.org b/config.org
@@ -265,13 +265,24 @@ Org documents are configured to start in variable pitch mode such that we have t
To define our desired fonts, we create functions as we did before in [[Code fonts]]:
#+begin_src emacs-lisp
+ (defvar ethandl/org-mono-font-name nil
+ "Font for code and any monospace blocks in Org documents")
+ (defvar ethandl/org-var-font-name nil
+ "Font for Org documents, variable width")
+ (defvar ethandl/org-default-font-height 140
+ "Default height for fonts in org documents")
+ (defvar ethandl/org-font-ht nil
+ "Font height in org documents")
+
(defun ethandl/set-org-font-vars (&optional height var mono)
"Sets the mono font variables for Org mode
- Use HEIGHT to specify the font height in px, VAR as the variable-pitch
- font family, and MONO as the monospace font family. If HEIGHT is nil,
- uses a height of 140. If VAR or MONO are nil, selects the first
- available font for each from a predefined list."
+ Use HEIGHT to specify the font height in px, VAR as the
+ variable-pitch font family, and MONO as the monospace font
+ family. If HEIGHT is nil, uses the default height given by
+ `ethandl/org-default-font-height'. If VAR or MONO are nil,
+ selects the first available font for each from a predefined
+ list."
(setq ethandl/org-mono-font-name
(or mono
(seq-find #'ethandl/font-exists
@@ -290,15 +301,21 @@ To define our desired fonts, we create functions as we did before in [[Code font
"Times New Roman"
"DejaVu Serif"))))
(setq ethandl/org-font-ht
- (or height 140)))
+ (or height ethandl/org-default-font-height)))
#+end_src
Next, we define a way to easily apply these fonts.
This is not as simple as it should be, because ~variable-pitch-mode~ takes over all Org fonts.
#+begin_src emacs-lisp
(defun ethandl/set-org-fonts (&optional height var mono)
- "Applies the mono fonts for org mode. Arguments are the same as for `ethandl/set-org-font-vars'."
- (ethandl/set-org-font-vars height var mono)
+ "Applies the mono fonts for org mode. Arguments are the
+ same as for `ethandl/set-org-font-vars'."
+ (if (or height var mono)
+ (ethandl/set-org-font-vars height var mono)
+ (unless (and ethandl/org-mono-font-name
+ ethandl/org-var-font-name
+ ethandl/org-font-ht)
+ (ethandl/set-org-font-vars)))
(custom-theme-set-faces
'user
@@ -319,8 +336,16 @@ This is not as simple as it should be, because ~variable-pitch-mode~ takes over
'(org-verbatim ((t (:inherit (shadow fixed-pitch)))))))
#+end_src
-Finally, we apply these fonts every time we enter org mode.
+Finally, we ensure that these functions are run whenever necessary:
#+begin_src emacs-lisp
+ ;; Evaluate available fonts when loading config
+ (ethandl/set-org-font-vars)
+
+ ;; Evaluate available fonts when making a new frame (relevant for daemon mode)
+ (add-hook 'after-make-frame-functions #'ethandl/set-org-font-vars)
+ (add-hook 'server-after-make-frame-hook #'ethandl/set-org-font-vars)
+
+ ;; Set the fonts when loading into an org buffer
(add-hook 'org-mode-hook #'ethandl/set-org-fonts)
#+end_src
*** Ligatures
@@ -606,7 +631,12 @@ Because the menu bar exists regardless on MacOS, I like to keep ~menu-bar-mode~
#+begin_src emacs-lisp :tangle (if (eq system-type 'darwin) "platform-config/darwin.el" "no")
(menu-bar-mode 1)
#+end_src
-** Including your platforms
+** Work PC
+My work PC has a lower resolution screen, so I like to have smaller fonts so that they take up less screen space.
+#+begin_src emacs-lisp :tangle (if (equal system-name "lobotomite") "platform-config/work-system.el" "no")
+ (setq ethandl/org-default-font-height 110)
+#+end_src
+** Including the platforms
Finally, we include any tangled platforms:
#+begin_src emacs-lisp
(dolist (file (directory-files ethandl/platform-config-dir t "\\.el$"))