Skip to content

Conversation

madig
Copy link
Collaborator

@madig madig commented May 23, 2025

We found this one during the development of a font. The GSUB table builder seems to discard defined language systems when they have no lookups. This is a problem when we add feature variations in a later step, like we do when we compile a Designspace with rules.

When like in the test code no lookup is defined for latn and dflt, just for the CAT language, the GSUB table won't have a dflt LangSysRecord that

if scriptRecord.Script.DefaultLangSys is None:
needs to attach itself to.

TODO:

  • Come up with a fix.

@behdad
Copy link
Member

behdad commented May 23, 2025

A no-lookup langsys is overriding the dflt langsys, so it changes font behavior if you drop it.

@behdad
Copy link
Member

behdad commented May 23, 2025

And for dropping dflt, yes, indeed, you need to either never drop it, or only drop it if it has no data whatsoever, including variations.

@madig
Copy link
Collaborator Author

madig commented May 23, 2025

The problem here is that we want a latn dflt to attach some feature variation (Designspace rules) in a later step, but it is completely empty and therefore dropped when building the table with just the provided feature file. I assume there was no problem if the feature variations were written into the feature file.

@behdad
Copy link
Member

behdad commented May 23, 2025

The problem here is that we want a latn dflt to attach some feature variation (Designspace rules) in a later step, but it is completely empty and therefore dropped when building the table with just the provided feature file. I assume there was no problem if the feature variations were written into the feature file.

You can create it on demand. Isn't that complicated at all.

@behdad
Copy link
Member

behdad commented May 23, 2025

But my point stands that only empty dflt can be dropped, not any other empty langsys.

@madig
Copy link
Collaborator Author

madig commented May 23, 2025

Right, so the fix would be to change

if scriptRecord.Script.DefaultLangSys is None:
to just create it?

@behdad
Copy link
Member

behdad commented May 23, 2025

Right, so the fix would be to change

if scriptRecord.Script.DefaultLangSys is None:

to just create it?

I think so.

@madig madig requested review from behdad and anthrotype May 27, 2025 11:12
@madig madig marked this pull request as ready for review May 27, 2025 11:13
@madig madig force-pushed the enforce-script-dflt-presence branch from 6ed71a3 to 40bee3c Compare May 27, 2025 11:15
@madig madig changed the title Ensure we have a dflt language for all scripts when adding variations later Create a dflt LangSys in a ScriptRecord when adding variations later May 27, 2025
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

pls fix the lint as well thanks

@anthrotype
Copy link
Member

anthrotype commented May 27, 2025

The GSUB table builder seems to discard defined language systems when they have no lookups. This is a problem when we add feature variations in a later step, like we do when we compile a Designspace with rules.

@madig Have you tested if this issue also happens with fontc as well?

@madig
Copy link
Collaborator Author

madig commented May 27, 2025

I have not, can do soon.

By the way, Harry and me were reading https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#scriptlist-table and wondered if a lazily-created "latn dflt" LangSys for feature variations should carry all features of "DFLT dflt"? Our reading of the spec says "no".

@anthrotype
Copy link
Member

I don't think so either

@behdad
Copy link
Member

behdad commented May 27, 2025

By the way, Harry and me were reading https://learn.microsoft.com/en-us/typography/opentype/spec/chapter2#scriptlist-table and wondered if a lazily-created "latn dflt" LangSys for feature variations should carry all features of "DFLT dflt"? Our reading of the spec says "no".

Absolutely not. When the shaper chooses latn, it doesn't look at DFLT at all.

@madig madig force-pushed the enforce-script-dflt-presence branch from 40bee3c to a235494 Compare May 27, 2025 11:45
[skip ci]
@madig madig merged commit b21e538 into main May 27, 2025
1 check passed
@madig madig deleted the enforce-script-dflt-presence branch May 27, 2025 12:22
@madig
Copy link
Collaborator Author

madig commented May 28, 2025

fontc (as of f187844659adae9f56003fb33ff4df93cd406190) seems to do the right thing, as in, I see a "latn dflt" entry for the rclt variation.

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