Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you specify a fallback font in emacs?

Tags:

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

like image 993
Dov Grobgeld Avatar asked May 21 '11 18:05

Dov Grobgeld


People also ask

How do I change the default font in Emacs?

Go to Options -> Set Default Font... . After you choose a font, don't forget to press Options -> Save Options —otherwise your new font will not be saved after you close Emacs.

What is fallback font for editing?

A fallback font is a reserve typeface containing symbols for as many Unicode characters as possible. When a display system encounters a character that is not part of the repertoire of any of the other available fonts, a symbol from a fallback font is used instead.

What is fallback font in CSS?

Commonly Used Fallback Fonts This means that you should add a list of similar "backup fonts" in the font-family property. If the first font does not work, the browser will try the next one, and the next one, and so on. Always end the list with a generic font family name.

What is the default font in Emacs?

By default, Emacs displays text on graphical displays using a 10-point monospace font, and the font size can be changed interactively (see Text Scale).


2 Answers

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")
like image 52
Dov Grobgeld Avatar answered Oct 02 '22 03:10

Dov Grobgeld


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.

like image 32
Jim Balter Avatar answered Oct 02 '22 02:10

Jim Balter