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

Wrong rules generated in feature file when multiple lookups exist in contextual rule #5374

Open
8 tasks done
NadAlaba opened this issue Feb 12, 2024 · 2 comments · May be fixed by #5384
Open
8 tasks done

Wrong rules generated in feature file when multiple lookups exist in contextual rule #5374

NadAlaba opened this issue Feb 12, 2024 · 2 comments · May be fixed by #5384

Comments

@NadAlaba
Copy link

NadAlaba commented Feb 12, 2024

When reporting a bug/issue:

  • Screenshot
  • The FontForge version and the operating system you're using
  • The behavior you expect to see, and the actual behavior
  • Steps to reproduce the behavior
  • (optional) Possible solution/fix/workaround

When you open an issue for a change/improvement/feature request:

  • A description of the problem you're trying to solve, including why you think this is a problem
  • If the feature changes current behavior, reasons why your solution is better
  • (optional) Possible solution/fix/workaround

Describing the problem:

When Generating feature files for a font that has more than one lookup in one contextual rule, only the first lookup of that rule is written to the feature file, and all other lookups are discarded.
This problem affects the UFO generated with FontForge too.

FontForge Version: 20230101 a1dad3e Built: 2023-01-01 05:31 UTC-ML-TtfDb-D-GDK3
OS: Windows 10 Pro 22H2

Steps to reproduce:

  1. Start FontForge app and open a new font.
  2. Create 4 dummy glyphs (I created A, B, C, and D).
    1
  3. Create 3 GSUB lookups (a single substitution 'Single 1' that replaces A by B, an other single substitution 'Single 2' that replaces C by D, and a contextual substitution By Glyphs that has the following rule: "A @<Single 1> C @<Single 2>", which will replace A by B and C by D if C camer after A.
    2
    5
  4. Save the newly created lookups, and then try them in a metrics window, to ensure that it is correctly created (We can see that the sequence "ABACD" is getting substituted by "ABBDD" as expected.)
    6
  5. "Save Feature File..." and inspect its contents:

...
lookup caltContextualAlternatesinLatinlookup1 {
lookupflag 0;
sub \A'lookup Single1 \C' ;
} caltContextualAlternatesinLatinlookup1;
...

  1. We can see that the rule omitted the second lookup (Single2). Furthermore, removing old lookups from fontforge completely, and then trying to "Merge Feature Info..." of our previously exported feature file would change our substitution rules, and would not produce the same expected result in the test of step 4.

Expected behavior:

  1. The previously quoted contextual substitution lookup in the feature file should have the rule:
sub \A'lookup Single1  \C'lookup Single2 ;

Possible solution:

  1. I think this problem is related to the lookup_in_rule() function, where the condition to check in the for loop should be seq > r->lookups[i].seq instead of seq < r->lookups[i].seq. Otherwise, the loop would never increment i.
@NadAlaba NadAlaba changed the title Wrong lookup rules in generated feature file when multiple lookups are in one rule Wrong rules generated in feature file when multiple lookups exist in one rule Feb 12, 2024
@iorsh
Copy link
Contributor

iorsh commented Feb 24, 2024

GW comments in lookup_in_rule():

    /* Suppose there are two lookups which affect the same sequence pos? */
    /* That's legal in otf, but I don't think it can be specified in the */
    /*  feature file. It doesn't seem likely to be used so I ignore it */

Could it be related to this case?

@NadAlaba
Copy link
Author

GW comments in lookup_in_rule():

    /* Suppose there are two lookups which affect the same sequence pos? */
    /* That's legal in otf, but I don't think it can be specified in the */
    /*  feature file. It doesn't seem likely to be used so I ignore it */

Could it be related to this case?

No, not really. The comment is talking about having 2 lookups that affect the same sequence position, whereas the bug happens whenever there is more than one lookup in one rule, even if each lookup has a unique sequence position.

Looking at my example, the bug happened when the lookup Single 1 affected position 0 (the letter A), and lookup Single 2 affected position 1 (the letter C).

@NadAlaba NadAlaba changed the title Wrong rules generated in feature file when multiple lookups exist in one rule Wrong rules generated in feature file when multiple lookups exist in contextual rule Mar 3, 2024
@NadAlaba NadAlaba linked a pull request Mar 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants