help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: script-representative-chars vs incomplete fonts


From: Eli Zaretskii
Subject: Re: script-representative-chars vs incomplete fonts
Date: Sun, 12 Sep 2021 08:54:56 +0300

> From: Kévin Le Gouguec <kevin.legouguec@gmail.com>
> Date: Sun, 12 Sep 2021 00:09:21 +0200
> 
> IIUC, fontset.el sets up script-representative-chars so that any font
> providing U+1D49C "𝒜" can be used for the whole "mathematical-script"
> range (U+1D49C–U+1D4CF "𝒜–𝓏").

No, script-representative-chars is used to _reject_ fonts that don't
suit our needs.  The candidate fonts should be selected by your font
backend, and selected wisely.

> On my system, I happen to have
> 
> - one font (KpMath) that provides U+1D49C–U+1D4B5 (the "capital" chars),
>   but not U+1D4B6–U+1D4CF (the "small" chars),
> 
> - another font (DejaVu Math TeX Gyre) that provides both sub-ranges[1].
> 
> As luck would have it, when trying to display a char in this range,
> Emacs stumbles on KpMath first

It's not Emacs that stumbles on that font, it's your font backend
(probably fontconfig?).  Emacs just verifies that the candidate fonts
returned by the backend satisfy the requirements, and uses the first
font that does.  So this might mean a bug report for fontconfig and/or
the font designers is in order.

> The situation is not irremediable; I've thought of at least 3
> workarounds[2].  I do wonder though if this situation is something Emacs
> should guard against by default, and if so, with what heuristics?

If there are strange fonts that support only portions of that Unicode
block, the easiest solution is to add more representative characters.

> E.g. in fontset.el, would it be overkill to break down the 52-char
> ranges in the math-subgroup loop into 2 26-char ranges in order to
> always add the "SMALL A" codepoints to script-representative-chars?

What would be the purpose of breaking that range?
script-representative-chars can specify multiple characters per
script, see its doc string.

>     1. (push #x1D4CF (alist-get 'mathematical-script
>                                 script-representative-chars))
>     2. (set-fontset-font
>         t 'mathematical "DejaVu Math TeX Gyre" nil 'prepend)
>     3. Uninstall KpMath.

I'd suggest to do 3 regardless.  A font that supports only part of a
block is a bad font to have.

Emacs should probably do the equivalent of 1, and the solution for
end-users is 2, of course; messing with script-representative-chars is
not recommended.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]