I want to use a variable pitch face when using org mode (for composing articles, prose, etc.) The emacs wiki suggested using buffer face mode with a hook to set the face for org mode buffers:

 ;; Use variable width font faces in certain buffers
 (defun my-buffer-face-mode-variable ()
   "Set font to a variable width (proportional) fonts in current buffer"
   (setq buffer-face-mode-face '(:family "Liberation Serif" ))

 ;; Set default font faces for org  modes
 (add-hook 'org-mode-hook 'my-buffer-face-mode-variable)

This correctly changes the buffer face to variable-width, but seems to break org mode indentation.

Without buffer face mode, the buffer uses the default fixed pitch face for text and a variable pitch face for headers (as defined by the theme.) The resulting indentation is correct:

enter image description here

With buffer face mode both text and header use variable pitch face, but breaks indentation of all but the first line of headers:

enter image description here

Perhaps there is a conflict using variable pitch faces with indentation or with visual line mode, which I also use?

 (with-eval-after-load 'org       
  (setq org-startup-indented t) 
  (add-hook 'org-mode-hook #'visual-line-mode))

I had the same issue. I believe this is because the indentation is implemented as a number of spaces, but those spaces are in the face "org-indent" which, by default, changes no attributes.

The result of this is that your indentation is set by the pitch of your "default" face, which is now narrower than the pitch of your bullets in your headings and therefore your body text looks like it's shifted left compared with the indentation of your headings.

As a solution I have the following in my init:

(set-face-attribute 'org-indent nil :inherit '(org-hide fixed-pitch))

My heading face always inherits from fixed-pitch so that tags line up, hence the use of "fixed-pitch" above.

It's not perfect, but this has at least made it acceptable enough that I've stopped noticing. I also use "org-bullets" for prettier indents, which may be why it doesn't work perfectly (since the bullets end up being of a varying size), but if you don't use org-bullets this is likely to work even better for you.

Note that I had to wrap the above face change into a hook to ensure it was done at the appropriate time. It's probably clumsy, but the way I've done that in my init is as follows:

(add-hook 'after-init-hook
    (lambda ()
     (require 'org-indent)       ; for org-indent face
     (set-face-attribute 'org-indent nil
         :inherit '(org-hide fixed-pitch))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.