0

I can not change family and size of a custom fontset in buffer-face-mode. Below is the minimal test config

(create-fontset-from-fontset-spec
 (font-xlfd-name (font-spec :registry "fontset-mine" :family "SF Pro"
                :weight 'regular :slant 'normal :width 'normal)))

(defun org-mode-set-face ()
  ;; (buffer-face-set :family "SF Pro" :height 1.50) ; works
  (buffer-face-set :family "fontset-mine" :height 1.50)) ; does not work
(add-hook 'org-mode-hook #'org-mode-set-face)

enter image description here

(Note that describe-char on t of texts shows that it uses a different font instead.)

  • Emacs version: GNU Emacs 28.1 (build 1, x86_64-apple-darwin21.5.0, Carbon Version 165 AppKit 2113.5) of 2022-07-0
  • OS: macOS 12.5 (21G72)
Saddle Point
  • 481
  • 7
  • 23

1 Answers1

0

Try this

(create-fontset-from-fontset-spec
 (font-xlfd-name
  (font-spec
   :registry "fontset-mine"
   :family "SF Pro"
   :weight 'regular
   :slant 'normal
   :width 'normal)))

(defface my-face nil "My Face.")

(set-face-attribute 'my-face nil
                    :font "fontset-mine"
                    :height 1.0)

(add-hook 'org-mode-hook
          (defun my-org-mode-hook ()
            (buffer-face-set 'my-face)
            (face-remap-add-relative 'my-face
                                     :height 1.5)))

Instead of rolling out your own my-face, you can as well work with variable-pitch face. IOW, you can get the same effect by

  • setting the :font property on variable-pitch face
  • put the org buffer in variable-pitch-mode
  • do a face-remap-add-relative as above

Before putting org buffers in variable-pitch-mode I suggest that you consult prior work like this one Ricing up Org Mode