When I list the fonts in my Emacs using the following code:

(dolist (font-name (x-list-fonts "*"))
  (let ((str font-name))
    (prin1 str)))

One of the fonts I get is:


but when I try to evaluate the following, using font-spec and the above font specification:

(font-spec :name "-outline-SimSun-ExtB-normal-normal-normal-mono-*-*-*-*-c-*-iso10646-1")

Emacs gives the following error:

Debugger entered--Lisp error: (error "Invalid font name: -outline-SimSun-ExtB-normal-normal-normal-mono-*-*-*-*-c-*-iso10646-1")
  font-spec(:name "-outline-SimSun-ExtB-normal-normal-normal-mono-*-*-*-*-c-*-iso10646-1")
  eval((font-spec :name "-outline-SimSun-ExtB-normal-normal-normal-mono-*-*-*-*-c-*-iso10646-1") nil)
  funcall-interactively(eval-print-last-sexp nil)
  call-interactively(eval-print-last-sexp nil nil)

This is weird, because Emacs complains about a font name being invalid that is obviously in the list of (x-list-fonts "*").

I mean, I tested it with other values from that list and font-spec worked as expected, e.g.

(font-spec :name "-outline-SimSun-normal-normal-normal-*-*-*-*-*-p-*-iso10646-1")
#<font-spec nil outline SimSun nil iso10646-1 normal normal normal nil nil 0 nil ((:name . "-outline-SimSun-normal-normal-normal-*-*-*-*-*-p-*-iso10646-1"))>

Why is that?

My Emacs version is 27.0.50, and I'm trying these on MS Windows 10.


You specify a font in XLFD-style, which normaly consits of 14 parts (specifiers between the -).

But your font has 15 parts and this is wrong.
The problem lies here: SimSun-ExtB.
I think this should specify the family (fmly), but the - makes ExtB to be evaluated as weight (wght) and this is wrong.

To use this font anyway, you could try to specify this font by choosing other parameters for font-spec. like :family, :weight, :foundry and so on.
(I can't test this, because I do not have a font with problematic name installed)

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.