I share my Emacs config across several machines, and I can't necessarily guarantee that they will all have the same fonts installed. For this reason, I would like to be able to give Emacs a list of acceptable fonts to use and have it select the first available font from that list at startup and set the default face to use that font. This should give me a reasonable-looking Emacs on any system. Is there a way to do this by default, or a package that implements it, or will I have to write my own code for this?
You could just set the
-- User Option: face-font-family-alternatives If a given family is specified but does not exist, this variable specifies alternative font families to try. Each element should have this form: (FAMILY ALTERNATE-FAMILIES...) If FAMILY is specified but not available, Emacs will try the other families given in ALTERNATE-FAMILIES, one by one, until it finds a family that does exist.
C-h v to see its current value; it's probably already got some alternatives for certain family names. Here's the value my Emacs currently has:
(("Monospace" "courier" "fixed") ("Monospace Serif" "Courier 10 Pitch" "Consolas" "Courier Std" "FreeMono" "Nimbus Mono L" "courier" "fixed") ("courier" "CMU Typewriter Text" "fixed") ("Sans Serif" "helv" "helvetica" "arial" "fixed") ("helv" "helvetica" "arial" "fixed"))