1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-11-19 16:39:20 +02:00

font-patcher: Correct essential glyph detection

[why]
We have two ranges of glyphs to examine:
 1. `0x0000`-`0x017f` is the Latin Extended-A range
 2. `0xfb00`-`0xfb06` are 'fi' and other ligatures

Both ranges are added to the essential glyphs (with their
sub-references, and with other glyphs that are referenced through
possub rules).

That is correct for range 1, but range 2 - the ligature glyphs - should
only become essential if they are indeed used for ligatures by some
rule.

For example with the UbuntuMono font, that does not have any fi ligature
natively, but it DOES have a filled `0xFB01` glyph, we would protect
that glyph and its subreferences (i.e. `0xF001`) - needlessly breaking
the Font Awesome icons in that font.

[how]
Add all glyphs of range 1 to the essential glyphs, but add glyphs of
range 2 only if they have a possub rule attached.

Reported-by: Eli Array Minkoff <eli@planetminkoff.com>
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2024-04-09 08:13:43 +02:00
parent 84140625a3
commit 066d36514c

View File

@ -6,7 +6,7 @@
from __future__ import absolute_import, print_function, unicode_literals
# Change the script version when you edit this script:
script_version = "4.13.0"
script_version = "4.13.1"
version = "3.2.0"
projectName = "Nerd Fonts"
@ -1135,14 +1135,14 @@ class font_patcher:
# glyphs intact.
# 0x0000-0x017f is the Latin Extended-A range
# 0xfb00-0xfb06 are 'fi' and other ligatures
basic_glyphs = set()
basic_glyphs = { c for c in range(0x21, 0x17f + 1) if c in self.sourceFont }
# Collect substitution destinations
for glyph in [*range(0x21, 0x17f + 1), *range(0xfb00, 0xfb06 + 1)]:
for glyph in list(basic_glyphs) + [*range(0xfb00, 0xfb06 + 1)]:
if not glyph in self.sourceFont:
continue
basic_glyphs.add(glyph)
for possub in self.sourceFont[glyph].getPosSub('*'):
if possub[1] == 'Substitution' or possub[1] == 'Ligature':
basic_glyphs.add(glyph)
basic_glyphs.add(self.sourceFont[possub[2]].unicode)
basic_glyphs.discard(-1) # the .notdef glyph
for glyph in basic_glyphs: