Following the guide in The Secrets of My Emacs Presentation Style - System Crafters I would like to present some additions / improvements, here.
- The first issue I took with the face remapping setup was, that did not allow me to use
text-scale-adjust
due to hard-coded font sizes. - Also, it did not make use of Emacs’s provided infrastructure to make face remapping more robust.
Scalable face definitions
So, it turns out that it is easier to just remove the :height
properties for the fixed-pitch
and variable-pitch
faces and define a font rescaling factor for the variable-pitch font. This way, you can just use your “intended” heights while mixing fixed- and variable-pitched fonts. If you stick to relative :height
values during face remapping, all faces remain scalable with text-scale-adjust
.
(add-to-list 'face-font-rescale-alist '("Iosevka Aile" . 1.1))
(set-face-attribute 'default nil :font "JetBrains Mono" :weight 'light :height 130)
(set-face-attribute 'fixed-pitch nil :inherit 'default :family "JetBrains Mono")
(set-face-attribute 'variable-pitch nil :font "Iosevka Aile" :weight 'light :height 130)
More robust face remapping
The new face remapping code looks as follows:
(defvar +org-present-face-remappings nil
"List of cookies to reset face remappings when leaving org-present mode.")
(defun +org-present-remap-faces (&rest faces)
(mapcar (lambda (x)
(push (apply #'face-remap-add-relative x)
+org-present-face-remappings))
faces))
(defun +org-present-start ()
...
(+org-present-remap-faces
'(default variable-pitch)
'(header-line (:height 4.0) default)
...))
(defun +org-present-stop ()
...
(dolist (face +org-present-face-remappings)
(face-remap-remove-relative face))
(setq +org-present-face-remappings nil))
You’ll notice that I don’t scale the default
face in +org-present-start
. That is because I am using org-present-big
with a factor of 3
. I found that to be more flexible.
Be aware, that with visual-fill-column-mode
, image scaling is off when using :width <factor|percent>
attributes. I am using a overriding advice on org-display-inline-image--width
to fix that. I will leave the details for another topic if there is interest.