jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
892 stars 163 forks source link

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

Open hmelman opened 6 years ago

hmelman commented 6 years ago

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?

jrblevin commented 6 years ago

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

hmelman commented 6 years ago

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.

pjones commented 3 years ago

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.