18

I have just installed Emacs 24 from source and would like to install a primary font as well as a fallback font, when the primary font does not include the international glyphs that I need. Under Linux this is done by most environments through fontconfig, but trying to set the font by

(set-default-font "Monospace 11")

doesn't work, instead of the fontconfig Monospace collection, it appears that I get "Sans".

To get a monospace font I need to do something like:

(set-default-font "Dejavu Sans Mono 11")

but unfortunately it does not contain the glyphs that I want. So my question is if emacs provides a "fallback" mechanism that it uses whenever the primary font does not cona

1

2 Answers 2

22

Gilles pointed me to the solution which is to use fontsets. I learned that fontsets are flexible enough so that you can use different fonts for different unicode ranges. Thus to use Miriam Mono CLM for Hebrew, you can enter the following configuration option:

(set-fontset-font "fontset-default" '(#x5d0 . #x5ff) "Miriam Mono CLM:bold")
3
  • 5
    I think that it needs to be pointed out that "fontset-default" is a fallback fontset. I read this solution a number of times and read the manual for set-fontset-font but never really understood what this solution meant. Dec 19, 2011 at 22:44
  • 5
    Also, you can replace the range (#x5d0 . #x5ff) with a character set -- like unicode -- and only when the font can't be rendered will it fallback to those unicode characters. Dec 19, 2011 at 22:44
  • 3
    Just for the sake of information: you can also replace "Miriam Mono CLM:bold" with (font-spec :size 50 :name "Miriam Mono CLM:bold"). This allows you to set different size or weight to the fallback font (in case it looks too different from you standard font).
    – Malabarba
    Jul 4, 2013 at 7:57
3

Try

(set-fontset-font t nil (font-spec :size 20 :name "Unifont"))

or

(set-fontset-font t nil (font-spec :size 20 :name "Symbola"))

This will use the named font (and size) for all glyphs with missing definitions. You need to install the font, which can be found on the net.

Alternatively, install the unicode-fonts package from MELPA.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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