59

How to find out current font used in my Emacs?

4 Answers 4

60

In my version of Emacs, I can get the information by entering M-x describe-font.

6
  • 11
    When doing that, it prompts Font name (default current choice for ASCII chars): What does that mean? What should I do there?
    – qazwsx
    May 10, 2012 at 18:02
  • 4
    @duperuser: I just hit Enter...
    – choroba
    May 10, 2012 at 18:06
  • 3
    This is an answer to the second question, but not the first one. After hitting Enter, is the displayed info about the font used for displaying ASCII characters ONLY? If so, how to find out the fonts used for displaying non-ASCII ones?
    – qazwsx
    May 10, 2012 at 20:34
  • @choroba after hitting enter on M-x describe-font I get "No fonts being used" on the mini-buffer Sep 9, 2013 at 17:18
  • @MenelaosPerdikeas: Are you running emacs in a text terminal?
    – choroba
    Sep 9, 2013 at 17:46
23

Different fonts can be used for different characters and different parts of the buffer. For a given character, you can find out which font was used by moving point to that character than then doing C-u C-x = which will give you all kinds of information about that position in the buffer, including which font was used for it.

7
  • 3
    What command is "C-u C-x =" a shortcut to?
    – qazwsx
    Dec 4, 2017 at 18:14
  • 3
    Well, C-x = is bound to what-cursor-position, but when called with a C-u prefix, it mostly delegates the work to describe-char.
    – Stefan
    Dec 4, 2017 at 18:21
  • So without using any keyboard shortcut, how to do the same thing?
    – qazwsx
    Dec 4, 2017 at 18:28
  • 2
    If you limit yourself to the M-x shortcut, it would be M-x describe-char RET.
    – Stefan
    Dec 4, 2017 at 18:32
  • So why is C-x =/what-cursor-position not used?
    – qazwsx
    Dec 4, 2017 at 18:44
17

You can just evaluate

(face-attribute 'default :font)

To evaluate a sexp, do M-:, type/paste the above sexp in there and hit enter.

4

Place cursor on text which you want to customize and run M-x describe-face.

It will give you information how this font was set, i.e. markdown-pre-face. You can then see that it inhertis from markdown-code-face which inherits from fixed-pitch.

And this is how you can set it:

(set-face-attribute 'default nil
                    :family "Source Code Pro"
                    :height 130
                    :weight 'normal
                    :width 'normal)
(copy-face 'default 'fixed-pitch)

Restart Emacs after setting it.

3
  • Does this not need to be saved in some init file before restarting? Apr 12, 2023 at 18:20
  • @MiserableVariable yes
    – rofrol
    Apr 13, 2023 at 11:04
  • Place it into ~/.emacs.d/init.el and adjust the height to you liking. Jan 30 at 22:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .