Search code examples
emacs

How do you specify a fallback font in emacs?


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


Solution

  • 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")
    

    where '(#x5d0 . #x5ff) indicates the range of characters.