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

Fix InDesign default composer kerning when mixing two scripts with a language selected #788

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

belluzj
Copy link
Collaborator

@belluzj belluzj commented Oct 19, 2023

Picture explanation of the issue:

image

It seems that the default composer prefers to trust the Language setting of the text, as opposed to segmenting the text into per-script runs, and only applies features registered in the script of the selected language? Just guessing, no idea how it really works.

It's sort of a regression from previous ufo2ft without kern splitting, because then all LTR kerning was together in one big lookup anyway.

This one feels a bit like walking backwards from the nice split-by-script kerning, but in the spirit of having fonts that work out of box even in sub-optimal settings, we're planning to use this fix anyway.

This could maybe go behind a flag? It's kind of garbage

@belluzj
Copy link
Collaborator Author

belluzj commented Nov 1, 2023

After testing by @behdad (thanks a lot!), this PR makes a sample font 60% slower to shape, due to the extra unnecessary lookups. So this PR shouldn't be the default behaviour of ufo2ft.

@belluzj belluzj marked this pull request as draft November 14, 2023 11:09
@belluzj
Copy link
Collaborator Author

belluzj commented Nov 14, 2023

Another potential problem with this is that if a glyph is used by 2 scripts (e.g. /H -> /h.smcp and /Eta -> /h.smcp) then the kerning for /h.smcp would be in two lookups (which is good) but then by registering both lookups under the same script, the kerning could be applied twice (very unlikely situation but still).

A better approach to both split by script and solve this InDesign issue would be to emit one subtable per script, and make 1 lookup for each script that brings together the subtables of the various scripts (a bit like what the GPOS compaction is doing (split into subtable) or what the subtable break statement is doing in feature code). That's because subtables cannot be applied twice (the first that matches wins). It should in theory also be faster than many lookups because it wouldn't go over the text several times.

We would need to measure the shaping performance.

Anyway I'm making this a draft in the meantime, it's not a good idea to merge as it is.

@madig
Copy link
Collaborator

madig commented May 15, 2024

I believe this partially works in ufo2ft 3.x.

I compiled a test font with cross-script kerning (A, A-cy and Alpha in the same kerning group) and made a document with the string "ΑΤΑ AVA АТА", then with the default (non-world) paragraph composer:

  1. Set the language to "no language"
  2. Set the language to English or Greek or Russian

In both cases, the test string remained kerned. I counter-checked this with the same font compiled with ufo2ft 2.33.4, where in both cases there was unkerning.

However! This only works when the kerning is cross-script (i.e. mixed script kerning groups). If all groups contain just one script (i.e. A, A-cy and Alpha in their own groups), this won't work.

@anthrotype
Copy link
Member

that’s as intended

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.

3 participants