unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How do I set up font fallback in a robust way?
@ 2016-04-09 19:14 Clément Pit--Claudel
  2016-04-09 19:46 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Clément Pit--Claudel @ 2016-04-09 19:14 UTC (permalink / raw)
  To: Emacs developers


[-- Attachment #1.1: Type: text/plain, Size: 2960 bytes --]

Hi emacs-devel,

I'm cross-posting this from https://emacs.stackexchange.com/questions/17205 following Eli's suggestion; I couldn't figure this out from reading the manual.

TL;DR: What's a simple way to reliably say: use Ubuntu Mono as the default font, FreeMono for the characters unsupported by Ubuntu Mono, and Symbola for characters unsupported by both?

Since my main programming font does not cover all the mathematical symbols I need, I initially set up font fallback as shown below:

    (set-fontset-font t 'unicode (font-spec :name "FreeMono") nil 'append)
    (set-fontset-font t 'unicode (font-spec :name "Symbola") nil 'append)

Unfortunately this also changed the font for some of the character that my main font (Ubuntu Mono) supports, so I changed it to

    (set-fontset-font t 'unicode (font-spec :name "Ubuntu Mono") nil)
    (set-fontset-font t 'unicode (font-spec :name "FreeMono") nil 'append)
    (set-fontset-font t 'unicode (font-spec :name "Symbola") nil 'append)

If my understanding is correct, this should ensure that characters that Ubuntu Mono cannot handle are handled by FreeMono, unless FreeMono doesn't have them, in which case they should be displayed using Symbola. It is also my understanding that `t` does the same as `"fontset-default"` above.

Unfortunately, there were still cases where the right font wasn't selected; I found that changing to

    (set-fontset-font t 'unicode (font-spec :name "Ubuntu Mono") nil)
    (set-fontset-font t 'unicode (font-spec :name "FreeMono") nil 'append)
    (set-fontset-font t 'unicode (font-spec :name "Symbola") nil 'append)
    (set-fontset-font "fontset-startup" 'unicode (font-spec :name "Ubuntu Mono") nil)
    (set-fontset-font "fontset-startup" 'unicode (font-spec :name "FreeMono") nil 'append)
    (set-fontset-font "fontset-startup" 'unicode (font-spec :name "Symbola") nil 'append)

worked better, but not always: changing the font size using

    (set-face-attribute 'default nil :height some-size)

caused the fallbacks to be ignored, due to new fontsets being created.

My current solution is to do

    (set-fontset-font fontset 'unicode (font-spec :name "Ubuntu Mono") nil)
    (set-fontset-font fontset 'unicode (font-spec :name "FreeMono") nil 'append)
    (set-fontset-font fontset 'unicode (font-spec :name "Symbola") nil 'append)

on each fontset (`fontset-list`), after each font size change. This is cumbersome, and I have trouble imagining that it's the right solution.

What's the proper way to configure font fallback?

*Note*: for testing purposes, here are a few math characters: `ℕ𝓟⧺×≠≥≤±¬∨∧∃∀λ⟿⟹⊥⊤⊢`

*References*: Emacs manual on [fontsets](https://www.gnu.org/software/emacs/manual/html_node/emacs/Fontsets.html) and on [modifying fontsets](https://www.gnu.org/software/emacs/manual/html_node/emacs/Defining-Fontsets.html#Defining-Fontsets)

Cheers,
Clément.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-10 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-09 19:14 How do I set up font fallback in a robust way? Clément Pit--Claudel
2016-04-09 19:46 ` Eli Zaretskii
2016-04-09 20:01   ` Clément Pit--Claudel
2016-04-10  2:44     ` Eli Zaretskii
2016-04-10 14:01       ` Clément Pit--Claudel
2016-04-10 16:38         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).