markdown-mode icon indicating copy to clipboard operation
markdown-mode copied to clipboard

A way to configure a proportional base font for markdown-mode

Open hmelman opened this issue 7 years ago • 3 comments

I just learned about ET Book font from this post on Ricing up Org Mode. Is there a way to configure just markdown-mode to use it? I currently use Arial as font variable-pitch and enable variable-pitch-mode in text-mode-hook and org-mode-hook. I'd like a way to keep that but just use ET Book (aka ETBembo) in markdown-mode, is that possible? I didn't see a base font that markdown-mode used to render plain text. Could there be a markdown-base-face that all the non-monospace markdown fonts inherit from and that plain text used?

hmelman avatar Jul 28 '18 12:07 hmelman

Plain text in markdown-mode just uses the default face, but I think you can achieve what you want using buffer-face-mode. There is some example code here: https://www.emacswiki.org/emacs/FacesPerBuffer

jrblevin avatar Jul 31 '18 15:07 jrblevin

Kinda. So variable-pitch-mode that I was using is based on buffer-face-mode, and now I just learned about buffer-face-set and this almost works:

    (add-hook 'markdown-mode-hook '(lambda () (buffer-face-set '(:family "ETBembo"))))

Body text is shown in ETBembo, but headings aren't because markdown-header-face inherits from variable-pitch and font-lock-function-name-face. I suspect there's more than just headers that do this but didn't look too far.

hmelman avatar Jul 31 '18 16:07 hmelman

I know this issue is old but I came across it today and thought I'd add my $0.02.

I think you should first set "ETBembo" as your variable-pitch font, then use buffer-face-set to switch the default face to variable-pitch:

(custom-set-faces
 '(variable-pitch ((t (:family "ETBembo")))))
(buffer-face-set :inherit 'variable-pitch)

The other thing you might have to fight against is your theme. The theme I'm using completely resets all faces so the ones that I want to be fixed-pitch are no longer so. Ultimately I gave up on this endeavor since a variable width font looked too weird to me.

If you really want to go down this road I recommend this article and video.

pjones avatar Apr 21 '21 23:04 pjones