10000 pyftmerge breaks fonts that support the same character · Issue #2475 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pyftmerge breaks fonts that support the same character #2475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dscorbett opened this issue Dec 15, 2021 · 4 comments · Fixed by #2476
Closed

pyftmerge breaks fonts that support the same character #2475

dscorbett opened this issue Dec 15, 2021 · 4 comments · Fixed by #2476

Comments

@dscorbett
Copy link
Member
dscorbett commented Dec 15, 2021

Merging fonts sometimes doesn’t work when the source fonts support the same non-common-script character. This happens both with 4.28.4 and with 4.28.4 plus #2473 (as of that PR’s commit 8a76455).

$ curl -LOs https://github.com/googlefonts/noto-fonts/raw/main/hinted/ttf/NotoSansGrantha/NotoSansGrantha-Regular.ttf
$ curl -LOs https://github.com/googlefonts/noto-fonts/raw/main/hinted/ttf/NotoSansTamil/NotoSansTamil-Regular.ttf
$ pyftmerge NotoSansTamil-Regular.ttf NotoSansGrantha-Regular.ttf
$ mv merged.ttf taml-gran.ttf
$ pyftmerge NotoSansGrantha-Regular.ttf NotoSansTamil-Regular.ttf
$ mv merged.ttf gran-taml.ttf
$ hb-shape --ned --no-positions -u 0BAA taml-gran.ttf
[patamil]
$ hb-shape --ned --no-positions -u 0BAA gran-taml.ttf
[pa_tamil]

If the Tamil font comes first, the glyph is patamil. If the Grantha font comes first, the glyph is pa_tamil, which breaks any Tamil lookups that expect patamil. Both fonts include both glyphs, but each font only ever uses one of the glyphs.

A solution might be to canonicalize the glyphs to a single glyph. For example, if Noto Sans Grantha is specified first, the canonical glyph would be pa_tamil. patamil would be discarded entirely and anything in Noto Sans Tamil that refers to patamil would be changed to refer to pa_tamil.

@behdad
Copy link
Member
behdad commented Dec 15, 2021

The way this is supposed to work in the merger, and given that you don't get a warning, is that, since the two scripts use different script tags, the merger adds GSUB rules to one of the scripts to map one glyph to the other in one of those scripts. But I cannot make it work....

2 hours later...

okay found the bugs. PR coming.

behdad added a commit that referenced this issue Dec 15, 2021
Part of fixing #2475

Old code was mistakenly only adding the synthetic-generated feature
to the first language-system. In the case of merging Noto Grantha
and Noto Tamil fonts, Noto Tamil had two script systems: 'taml' and
'tml2', and we were adding the synthetic 'locl' feature only to the
DefaultLangSys of the 'taml' script, not the 'tml2' script. That was
the main bug.

A second issue was that the lookup was being added twice to the same
(synthetic) feature. Check before adding lookup, to avoid that.
behdad added a commit that referenced this issue Dec 15, 2021
This was removing semantically-significant difference amongst glyphs
such as two identical glyphs one in Noto Sans Tamil one in Noto Sans
Grantha as in the following issue:

Part of fixing #2475
@behdad
Copy link
Member
behdad commented Dec 15, 2021

With that PR:

behdad:ttf 0 (main)$ hb-shape -u 0BAA merged.ttf --script taml
[patamil=0+778]
behdad:ttf 0 (main)$ hb-shape -u 0BAA merged.ttf --script gran
[pa_tamil=0+778]

@behdad
Copy link
Member
behdad commented Dec 15, 2021

A solution might be to canonicalize the glyphs to a single glyph.

I like to move towards this if the glyphs have identical rendering (in this case they do). One issue with it is that some of our lookup representations need reshuffling if glyph order changes. However, I think we can ignore that since our Coverage compiler knows how to deal with out-of-order glyphs as a known hack by using format2.

@satbyy
Copy link
satbyy commented Dec 16, 2021

Thanks! PR #2476 fixes this issue for Tamil/Grantha with test string ப்பிபீபுபூவு. Both cases are rendered identically (as expected)

image 8000

behdad added a commit that referenced this issue Dec 16, 2021
Part of fixing #2475

Old code was mistakenly only adding the synthetic-generated feature
to the first language-system. In the case of merging Noto Grantha
and Noto Tamil fonts, Noto Tamil had two script systems: 'taml' and
'tml2', and we were adding the synthetic 'locl' feature only to the
DefaultLangSys of the 'taml' script, not the 'tml2' script. That was
the main bug.

A second issue was that the lookup was being added twice to the same
(synthetic) feature. Check before adding lookup, to avoid that.
behdad added a commit that referenced this issue Dec 16, 2021
This was removing semantically-significant difference amongst glyphs
such as two identical glyphs one in Noto Sans Tamil one in Noto Sans
Grantha as in the following issue:

Part of fixing #2475
behdad added a commit that referenced this issue Dec 16, 2021
Part of fixing #2475

Old code was mistakenly only adding the synthetic-generated feature
to the first language-system. In the case of merging Noto Grantha
and Noto Tamil fonts, Noto Tamil had two script systems: 'taml' and
'tml2', and we were adding the synthetic 'locl' feature only to the
DefaultLangSys of the 'taml' script, not the 'tml2' script. That was
the main bug.

A second issue was that the lookup was being added twice to the same
(synthetic) feature. Check before adding lookup, to avoid that.
behdad added a commit that referenced this issue Dec 16, 2021
This was removing semantically-significant difference amongst glyphs
such as two identical glyphs one in Noto Sans Tamil one in Noto Sans
Grantha as in the following issue:

Part of fixing #2475
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0