-
Notifications
You must be signed in to change notification settings - Fork 43
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
Split kerning by script, not by direction (second attempt) #667
Conversation
While investigating #658, I stumbled over the following:
|
So, in the test font provided by yanone, the feature file does not declare |
Side-note: the code in
|
From call:
|
Also, the PairPos coverage must be unique inside a lookup, otherwise things are unreachable. That's an invariant to follow. |
So, regarding #667 (comment), we either:
Maybe I'll try the latter and see what happens in various shaping engines. |
This thing of using the globally declared default languagesystems pre-dates the split-kerning-by-scripts PR, but maybe doesn't make sense any more and should be revised. In the previous code in which we'd only split lookups between LTR/RTL, the default languagesystems were parsed and grouped into buckets depending on whether they were associated with "kern" or "dist", and on the script's horizontal writing direction (LTR/RTL), stored in Then, if there was no globally declared script associated with "dist" feature, none would be generated. Then, kerning pairs would be split into three lookups: LTR, RTL and a What we could have done maybe was to register such Even so, imposing the font developer to write explicit default languagesystems to control the behavior of the kern feature writer may not always be desirable, as those apply indiscriminately to both GPOS and GSUB. In the example brought forward by Nikolaus, the GSUB features work fine without Greek being declared among the default languagesystems, but GPOS kerning may need those otherwise ufo2ft places greek kerning under DFLT/dflt; but if greek were added to default languagesystems then the meaning of all the pos/sub rules elsewhere that are un-marked by explicit script/language statements would suddenly also be registered for Greek too - though i guess they'd be no-op since no greek glyphs are probably used in them... I'm warming up to the idea that for the split-by-script kern writer, we should just ignore the global languagesystem and use whatever scripts that we find among the kerned glyphs. Thoughts @simoncozens @khaledhosny @madig ? |
That sounds good to me, the only issue being that we still need to look at the languagesystem to be aware of what shaper the font goes through, so that we can put kerns in |
once we know what scripts are used in kerning pairs, and have split these accordingly, we also know whether there are dist-enabled scripts or not |
It seems that the new kern writer should be reworked a bit to adjust for our new assumptions. I'll try and draw up an algorithm to better wrap my mind around it. Also, blindly using ufo2ft/Lib/ufo2ft/featureWriters/kernFeatureWriter.py Lines 445 to 454 in 58d8b2b
lookup kern_Thaa and lookup kern_Yezi blocks for Arabic numerals :) I suppose they don't hurt, but are they useful?
|
5cc1dd7
to
d8638dd
Compare
@anthrotype what's the purpose of dealing with bases and marks in the kern writer? |
I am not sure we want to use script_extension.. that may add unwanted/unccessary script records. How about we extend the global default languagesystems with the set of scripts (not script_extensions!) actually used by the kerning pairs. You make a single kern_Arab lookup and also register the same under Thana or Yezi or whatever "extension" scripts |
aargh this is getting too complicated now, too much guessing. Maybe using the default languagesystems as we were/are is not so bad after all, at least it's explicit and leaves the responsibility to the font developer. 🤔 |
I think we should follow the guessing/inference approach until we hit an actual roadblock. I'll look into using the script rather than script_extension. Also, I found another problem: |
Note to self: look at trying to preserve the kerning pair type (glyph to glyph, class to class, ...) when splitting pairs, by emitting eg |
Maybe one could also classifyTools these specific multi-script pairs, group them into their own lookup and insert references in |
Hm, if some codepoints are used in multiple scripts (e.g. Arabic numerals in Arabic and Thaana), is just storing them for Arabic gonna work? Are shapers going to run |
More thinking... since the BRACKET glyphs aren't reachable in the UFO, should the kern writer actually do a reachability analysis (look for Unicoded glyphs plus scour GSUB; additionally scan Designspace rules) and ignore glyphs that aren't reachable? |
feature writers work on ufos, they don't know about designspace.. |
Hm. So, how do we pass in higher level information? Add new attribute |
it might work but feels iffy |
i'm thinking we should provide a way for users to override ufo2ft's inference of unicode properties such as script/bidi category based on cmap+GSUB for specific glyphs, we might need that anyway to support Glyphs.app's RTL kerning #658 (comment) |
So, what do we want to be able to pass in? A |
Access to the Designspace is solved with a new |
ok let's do that in a different pr though |
I believe my WIP does what we need, all class-to-class pairings now seem to have a disjoint kern1 classes I believe, from looking at output for yanone's private real world font right here. I did spot two things though in an excerpt, one weird (two kern2 classes for the same kern1 parent that were almost identical except for one additional glyph???) and the other a possible size optimization opportunity. Consider the following class to class pairings:
can we collapse them into the following?
Or is this an optimization that only the otlLib subtable builder could do because kern2s have to be disjoint per subtable? |
bidi types may not be treated right, see test_kern_split_and_mix_common -> nkoo [skip ci]
[skip ci]
[skip ci]
[skip ci]
[skip ci]
This pulls the commits for #636 and some follow-ups aside, to unblock releases from main until the code is more thoroughly tested.
Relevant issues:
Todo:
Figure out what would need to be done to make variable fonts compile and behave correctly when not all kerning pairs are defined across all sources. The issue already existed before, but since we were splitting by direction, which is a much coarser property, it rarely was problematic.separate issueCloses #658