From a479b743804bc73ac01b17ce953d3355321be93a Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Tue, 6 Feb 2024 15:50:23 -0500 Subject: [PATCH] [fea-rs] Update fontools test cases This mostly involved deleting a bunch of '.expecte_diff' files we had that represented various small bugs & inconsistencies in fonttools. All of those issues have now been resolved, and our output now matches fonttools more closely. This does involve one 'regression', which is that fontools has implemented an additional optimization that we don't have. I'll open an issue for this separately, and in the meantime I've added a .expected_diff for this case (bug512.fea) I've also had to disable GSUB_2.fea, because it was modified to include fonttools-specific syntax that fea-rs does not yet support. --- fea-rs/src/util/ttx.rs | 4 +- fea-rs/test-data/fonttools-tests/GSUB_2.fea | 21 + fea-rs/test-data/fonttools-tests/GSUB_2.ttx | 121 +++++- .../GSUB_5_formats.expected_diff | 258 ------------ .../fonttools-tests/GSUB_5_formats.ttx | 247 +++++++---- .../GSUB_6_formats.expected_diff | 398 ------------------ .../fonttools-tests/GSUB_6_formats.ttx | 387 +++++++++++------ .../fonttools-tests/bug512.expected_diff | 9 + fea-rs/test-data/fonttools-tests/bug512.ttx | 3 +- .../fonttools-tests/spec4h1.expected_diff | 10 - fea-rs/test-data/fonttools-tests/spec4h1.ttx | 2 +- .../fonttools-tests/spec5d1.expected_diff | 32 -- fea-rs/test-data/fonttools-tests/spec5d1.fea | 10 + fea-rs/test-data/fonttools-tests/spec5d1.ttx | 16 +- .../fonttools-tests/spec5f_ii_3.expected_diff | 222 ---------- .../test-data/fonttools-tests/spec5f_ii_3.ttx | 214 +++++----- .../fonttools-tests/spec8a.expected_diff | 18 - fea-rs/test-data/fonttools-tests/spec8a.ttx | 6 +- .../fonttools-tests/variable_mark_anchor.fea | 10 + .../fonttools-tests/variable_mark_anchor.ttx | 128 ++++++ resources/scripts/fea_ci_requirements.txt | 2 +- 21 files changed, 833 insertions(+), 1285 deletions(-) delete mode 100644 fea-rs/test-data/fonttools-tests/GSUB_5_formats.expected_diff delete mode 100644 fea-rs/test-data/fonttools-tests/GSUB_6_formats.expected_diff create mode 100644 fea-rs/test-data/fonttools-tests/bug512.expected_diff delete mode 100644 fea-rs/test-data/fonttools-tests/spec4h1.expected_diff delete mode 100644 fea-rs/test-data/fonttools-tests/spec5d1.expected_diff delete mode 100644 fea-rs/test-data/fonttools-tests/spec5f_ii_3.expected_diff delete mode 100644 fea-rs/test-data/fonttools-tests/spec8a.expected_diff create mode 100644 fea-rs/test-data/fonttools-tests/variable_mark_anchor.fea create mode 100644 fea-rs/test-data/fonttools-tests/variable_mark_anchor.ttx diff --git a/fea-rs/src/util/ttx.rs b/fea-rs/src/util/ttx.rs index b010c60e8..cd6a00626 100644 --- a/fea-rs/src/util/ttx.rs +++ b/fea-rs/src/util/ttx.rs @@ -20,9 +20,10 @@ use rayon::prelude::*; use serde::{Deserialize, Serialize}; static IGNORED_TESTS: &[&str] = &[ - // ## tests with invalid syntax ## // + // ## tests with unofficial syntax extensiosn we haven't implemented yet ## // "AlternateChained.fea", "GSUB_6.fea", + "GSUB_2.fea", // // ## tests that should be revisited ## // // @@ -32,6 +33,7 @@ static IGNORED_TESTS: &[&str] = &[ "variable_bug2772.fea", "variable_scalar_anchor.fea", "variable_scalar_valuerecord.fea", + "variable_mark_anchor.fea", ]; /// An environment variable that can be set to specify where to write generated files. diff --git a/fea-rs/test-data/fonttools-tests/GSUB_2.fea b/fea-rs/test-data/fonttools-tests/GSUB_2.fea index d2a3cb101..21db452b5 100644 --- a/fea-rs/test-data/fonttools-tests/GSUB_2.fea +++ b/fea-rs/test-data/fonttools-tests/GSUB_2.fea @@ -12,3 +12,24 @@ feature f2 { sub f_i by f i; sub f_f_i by f f i; } f2; + +feature f3 { + sub [f_i f_l f_f_i f_f_l] by f [i l f_i f_l]; +} f3; + +feature f4 { + sub [f_i f_l f_f_i f_f_l] by [f f f_f f_f] [i l i l]; +} f4; + +@class = [f_i f_l]; +lookup l1 { + sub @class by f [i l]; +} l1; + +feature f5 { + sub @class' lookup l1 [i l]; +} f5; + +feature f6 { + sub [f_i f_i]' j by [f f] [i i]; +} f6; diff --git a/fea-rs/test-data/fonttools-tests/GSUB_2.ttx b/fea-rs/test-data/fonttools-tests/GSUB_2.ttx index b91c20fe0..fb87a0590 100644 --- a/fea-rs/test-data/fonttools-tests/GSUB_2.ttx +++ b/fea-rs/test-data/fonttools-tests/GSUB_2.ttx @@ -10,16 +10,20 @@ - + @@ -34,9 +38,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -57,6 +89,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fea-rs/test-data/fonttools-tests/GSUB_5_formats.expected_diff b/fea-rs/test-data/fonttools-tests/GSUB_5_formats.expected_diff deleted file mode 100644 index 2b080f8c9..000000000 --- a/fea-rs/test-data/fonttools-tests/GSUB_5_formats.expected_diff +++ /dev/null @@ -1,258 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. -# -# Note: fonttools generates format 2 subtables, and we generate format 3. -# I believe that this is an error in fonttools: -# -L64 -> -> -> -L64 -< -< -< -< -< -L99 -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -L99 -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< diff --git a/fea-rs/test-data/fonttools-tests/GSUB_5_formats.ttx b/fea-rs/test-data/fonttools-tests/GSUB_5_formats.ttx index 80196aaa4..29d57d5e5 100644 --- a/fea-rs/test-data/fonttools-tests/GSUB_5_formats.ttx +++ b/fea-rs/test-data/fonttools-tests/GSUB_5_formats.ttx @@ -62,9 +62,11 @@ - - - + + + + + @@ -92,91 +94,160 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fea-rs/test-data/fonttools-tests/GSUB_6_formats.expected_diff b/fea-rs/test-data/fonttools-tests/GSUB_6_formats.expected_diff deleted file mode 100644 index 754f9263c..000000000 --- a/fea-rs/test-data/fonttools-tests/GSUB_6_formats.expected_diff +++ /dev/null @@ -1,398 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. -# -# Note: fonttools generates format 2 subtables, and we generate format 3. -# I believe that this is an error in fonttools: -# -L74 -> -> -> -L74 -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -L138 -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -L138 -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< diff --git a/fea-rs/test-data/fonttools-tests/GSUB_6_formats.ttx b/fea-rs/test-data/fonttools-tests/GSUB_6_formats.ttx index ad2a1c5e5..45d5f3a0d 100644 --- a/fea-rs/test-data/fonttools-tests/GSUB_6_formats.ttx +++ b/fea-rs/test-data/fonttools-tests/GSUB_6_formats.ttx @@ -72,9 +72,41 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -101,134 +133,227 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fea-rs/test-data/fonttools-tests/bug512.expected_diff b/fea-rs/test-data/fonttools-tests/bug512.expected_diff new file mode 100644 index 000000000..d52358ed5 --- /dev/null +++ b/fea-rs/test-data/fonttools-tests/bug512.expected_diff @@ -0,0 +1,9 @@ +# generated automatically by fea-rs +# this file represents an acceptable difference between the output of +# fonttools and the output of fea-rs for a given input. +L75 +> +L75 +< +L97 +< diff --git a/fea-rs/test-data/fonttools-tests/bug512.ttx b/fea-rs/test-data/fonttools-tests/bug512.ttx index 693ebeb7c..4ad3af2f9 100644 --- a/fea-rs/test-data/fonttools-tests/bug512.ttx +++ b/fea-rs/test-data/fonttools-tests/bug512.ttx @@ -73,7 +73,7 @@ - + @@ -94,7 +94,6 @@ - diff --git a/fea-rs/test-data/fonttools-tests/spec4h1.expected_diff b/fea-rs/test-data/fonttools-tests/spec4h1.expected_diff deleted file mode 100644 index 7f9704777..000000000 --- a/fea-rs/test-data/fonttools-tests/spec4h1.expected_diff +++ /dev/null @@ -1,10 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. - -# our sorting within a ligature set currently differs from fonttools, but we expect -# fonttools to adopt this: https://github.com/fonttools/fonttools/issues/3428 -L149 -> -L151 -< diff --git a/fea-rs/test-data/fonttools-tests/spec4h1.ttx b/fea-rs/test-data/fonttools-tests/spec4h1.ttx index 0e42fc56e..a399ab2b4 100644 --- a/fea-rs/test-data/fonttools-tests/spec4h1.ttx +++ b/fea-rs/test-data/fonttools-tests/spec4h1.ttx @@ -147,8 +147,8 @@ - + diff --git a/fea-rs/test-data/fonttools-tests/spec5d1.expected_diff b/fea-rs/test-data/fonttools-tests/spec5d1.expected_diff deleted file mode 100644 index 7d37cb4a6..000000000 --- a/fea-rs/test-data/fonttools-tests/spec5d1.expected_diff +++ /dev/null @@ -1,32 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. -# -# our sorting within a ligature set currently differs from fonttools, but we expect -# fonttools to adopt this: https://github.com/fonttools/fonttools/issues/3428 -L45 -> -> -L49 -> -> -L53 -< -< -L57 -< -< -L68 -> -> -L71 -< -L73 -< -L76 -> -> -L79 -< -L81 -< diff --git a/fea-rs/test-data/fonttools-tests/spec5d1.fea b/fea-rs/test-data/fonttools-tests/spec5d1.fea index cf7d76f70..0b5acdd30 100644 --- a/fea-rs/test-data/fonttools-tests/spec5d1.fea +++ b/fea-rs/test-data/fonttools-tests/spec5d1.fea @@ -11,6 +11,16 @@ feature F1 { # if glyph classes are detected in . Thus, the above # example produces an identical representation in the font as if all # the sequences were manually enumerated by the font editor: +# +# NOTE(anthrotype): The previous sentence is no longer entirely true, since we +# now preserve the order in which the ligatures (with same length and first glyph) +# were specified in the feature file and do not sort them alphabetically +# by the ligature component names. Therefore, the way this particular example from +# the FEA spec is written will produce two slightly different representations +# in the font in which the ligatures are enumerated differently, however the two +# lookups are functionally equivalent. +# See: https://github.com/fonttools/fonttools/issues/3428 +# https://github.com/adobe-type-tools/afdko/issues/1727 feature F2 { sub one slash two by onehalf; sub one.oldstyle slash two by onehalf; diff --git a/fea-rs/test-data/fonttools-tests/spec5d1.ttx b/fea-rs/test-data/fonttools-tests/spec5d1.ttx index 77dfc93b8..8763c931e 100644 --- a/fea-rs/test-data/fonttools-tests/spec5d1.ttx +++ b/fea-rs/test-data/fonttools-tests/spec5d1.ttx @@ -43,16 +43,16 @@ - - - - + + + + @@ -62,16 +62,16 @@ - - + + - - + + diff --git a/fea-rs/test-data/fonttools-tests/spec5f_ii_3.expected_diff b/fea-rs/test-data/fonttools-tests/spec5f_ii_3.expected_diff deleted file mode 100644 index 714159831..000000000 --- a/fea-rs/test-data/fonttools-tests/spec5f_ii_3.expected_diff +++ /dev/null @@ -1,222 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. -# NOTE: this is a case where fonttools is choosing a less efficient -# representation; our output matches afdko/makeotf. -# See -L34 -> -> -> -L34 -< -< -< -< -L42 -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -> -L42 -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< -< diff --git a/fea-rs/test-data/fonttools-tests/spec5f_ii_3.ttx b/fea-rs/test-data/fonttools-tests/spec5f_ii_3.ttx index c03a81fb7..6ef871b8a 100644 --- a/fea-rs/test-data/fonttools-tests/spec5f_ii_3.ttx +++ b/fea-rs/test-data/fonttools-tests/spec5f_ii_3.ttx @@ -1,5 +1,5 @@ - + @@ -32,115 +32,111 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/fea-rs/test-data/fonttools-tests/spec8a.expected_diff b/fea-rs/test-data/fonttools-tests/spec8a.expected_diff deleted file mode 100644 index 9342d3719..000000000 --- a/fea-rs/test-data/fonttools-tests/spec8a.expected_diff +++ /dev/null @@ -1,18 +0,0 @@ -# generated automatically by fea-rs -# this file represents an acceptable difference between the output of -# fonttools and the output of fea-rs for a given input. -# -# Note: fonttools currently generates the wrong ordering in aalt. -# see -L101 -> -L105 -< -L108 -> -L110 -< -L113 -> -L115 -< diff --git a/fea-rs/test-data/fonttools-tests/spec8a.ttx b/fea-rs/test-data/fonttools-tests/spec8a.ttx index 787ecfa13..9c8c758ef 100644 --- a/fea-rs/test-data/fonttools-tests/spec8a.ttx +++ b/fea-rs/test-data/fonttools-tests/spec8a.ttx @@ -99,18 +99,18 @@ - + - + - + diff --git a/fea-rs/test-data/fonttools-tests/variable_mark_anchor.fea b/fea-rs/test-data/fonttools-tests/variable_mark_anchor.fea new file mode 100644 index 000000000..39ead93c6 --- /dev/null +++ b/fea-rs/test-data/fonttools-tests/variable_mark_anchor.fea @@ -0,0 +1,10 @@ +markClass macron @MC_top; + +lookup one { + pos base a + mark @MC_top; +} one; +lookup two { + pos base a + mark @MC_top; +} two; diff --git a/fea-rs/test-data/fonttools-tests/variable_mark_anchor.ttx b/fea-rs/test-data/fonttools-tests/variable_mark_anchor.ttx new file mode 100644 index 000000000..962cff741 --- /dev/null +++ b/fea-rs/test-data/fonttools-tests/variable_mark_anchor.ttx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/scripts/fea_ci_requirements.txt b/resources/scripts/fea_ci_requirements.txt index f75242ed3..a23ec038a 100644 --- a/resources/scripts/fea_ci_requirements.txt +++ b/resources/scripts/fea_ci_requirements.txt @@ -1,2 +1,2 @@ # used in CI to install fonttools for ttx tests -fonttools[unicode]==4.47.2 +fonttools[unicode]==4.48.1