Skip to content
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 (third attempt) #679

Merged
merged 43 commits into from
Dec 6, 2022

Conversation

madig
Copy link
Collaborator

@madig madig commented Nov 14, 2022

This is a clean-up PR for #667.

This implements:

  • Making classifyGlyphs also deal with tuples instead of just lists and sets.
  • Making the KernFeatureWriter emit scripts independently of the globally declared languagesystems. This is arguably a separate concern. I removed some tests that no longer make sense.
    • The code now looks at the declared languagesystems and the font's codepoints that have just one script associated with them, as a heuristic for what the font is supposed to support. We don't depend on the designer to add all desired script declarations.
  • Having KerningPair deal with just pair information, and deal with scripts and bidi metadata outside. This simplifies the code a lot by collecting concerns in one place.
  • A method of not triggering erroneous subtable breaks in otlLib (swallowing kerning) by:
    • Using a simpler kern splitter that passes kerning validation and produces no overlapping kerning groups
    • Sorting the kerning pairs (glyph-to-glyph first, then glyph-to-class, class-to-glyph and class-to-class)
  • Some more tests to test bidi and script splitting
  • Dropping kerning classes from being written to the feature file
  • Various code simplifications of the KernFeatureWriter.

Note that for reasons I have not investigated, various Noto Serif Tamil sources have some errant kerning, but they have the same problem with the current mainline kern writer.

Closes #658

simoncozens and others added 7 commits November 4, 2022 19:49
This makes the KernFeatureWriter independent of the globally declared languagesystems.
This also requires a change to FeatureCompiler to catch feature compilation errors in setContext.
This prepares making KeringPairs immutable later.

It also removes some direct tests of the getKerningPair API which we won't need going forward.
* This paves the way to removing scripts and bidiTypes from KerningPair.
* Pairs are now sorted in one place instead of in getKerningPairs, which was undone later during splitting
* Rewrite some tests that were testing now obsolete APIs
* Restore test_ambiguous_direction_pair to assert that nothing is generated. This was wrong before.
* Remove unused _intersectPairs method
This also literalises all classes. See code comments.
This cuts out the need to convert types into feature AST early; instead do it in _makePairPosRule. This makes the code more straightforward.
@madig madig marked this pull request as ready for review November 15, 2022 18:04
On a certain project, reduces time spent in _makePairPosRule from 1.79s
to 240ms. A small win, but still.
Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly LGTM, thanks!

One thing before I think we can merge is, we should try to keep using named FEA classes in the generated feature code, either for the original classes that needed no split and for the split ones that occurred more than once; having no named classes (repeatedly spelling out all the [a b c] and such) makes the feature code harder to debug; and the alleged feaLib bug whereby some pairs may get lost if one mixes named and unnamed classes isn't sufficient to warrant ditching the named classes altogether, and we need to fix that on its own.

@anthrotype
Copy link
Member

while reading old issues, I stumbled on a long comment of mine that details the way the ufo2ft kernFeatureWriter worked:

unified-font-object/ufo-spec#16 (comment)

It would be nice to have a similar write up for the newly porposed split-by-scripts algorithm..

Copy link
Member

@anthrotype anthrotype left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I propose we merge and cut a pre-release and ask users to test this with their fonts to prevent the need to revert this once again.

Thanks a lot to both Simon and Nikolaus for working on this!

@madig madig merged commit e0b810b into main Dec 6, 2022
@khaledhosny khaledhosny deleted the kern-splitter-v3 branch March 8, 2023 21:59
@khaledhosny khaledhosny mentioned this pull request Dec 24, 2023
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 this pull request may close these issues.

RTL kerning missing from font
6 participants