Skip to content

Commit

Permalink
[fea-rs] Update fontools test cases
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmyr committed Feb 6, 2024
1 parent 93e8b97 commit a479b74
Show file tree
Hide file tree
Showing 21 changed files with 833 additions and 1,285 deletions.
4 changes: 3 additions & 1 deletion fea-rs/src/util/ttx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ## //
//
Expand All @@ -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.
Expand Down
21 changes: 21 additions & 0 deletions fea-rs/test-data/fonttools-tests/GSUB_2.fea
Original file line number Diff line number Diff line change
Expand Up @@ -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;
121 changes: 118 additions & 3 deletions fea-rs/test-data/fonttools-tests/GSUB_2.ttx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=2 -->
<!-- FeatureCount=6 -->
<FeatureIndex index="0" value="0"/>
<FeatureIndex index="1" value="1"/>
<FeatureIndex index="2" value="2"/>
<FeatureIndex index="3" value="3"/>
<FeatureIndex index="4" value="4"/>
<FeatureIndex index="5" value="5"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
</ScriptList>
<FeatureList>
<!-- FeatureCount=2 -->
<!-- FeatureCount=6 -->
<FeatureRecord index="0">
<FeatureTag value="f1 "/>
<Feature>
Expand All @@ -34,9 +38,37 @@
<LookupListIndex index="0" value="1"/>
</Feature>
</FeatureRecord>
<FeatureRecord index="2">
<FeatureTag value="f3 "/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="2"/>
</Feature>
</FeatureRecord>
<FeatureRecord index="3">
<FeatureTag value="f4 "/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="3"/>
</Feature>
</FeatureRecord>
<FeatureRecord index="4">
<FeatureTag value="f5 "/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="5"/>
</Feature>
</FeatureRecord>
<FeatureRecord index="5">
<FeatureTag value="f6 "/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="6"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<!-- LookupCount=8 -->
<Lookup index="0">
<LookupType value="2"/>
<LookupFlag value="0"/>
Expand All @@ -57,6 +89,89 @@
<Substitution in="f_i" out="f,i"/>
</MultipleSubst>
</Lookup>
<Lookup index="2">
<LookupType value="2"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MultipleSubst index="0">
<Substitution in="f_f_i" out="f,f_i"/>
<Substitution in="f_f_l" out="f,f_l"/>
<Substitution in="f_i" out="f,i"/>
<Substitution in="f_l" out="f,l"/>
</MultipleSubst>
</Lookup>
<Lookup index="3">
<LookupType value="2"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MultipleSubst index="0">
<Substitution in="f_f_i" out="f_f,i"/>
<Substitution in="f_f_l" out="f_f,l"/>
<Substitution in="f_i" out="f,i"/>
<Substitution in="f_l" out="f,l"/>
</MultipleSubst>
</Lookup>
<Lookup index="4">
<LookupType value="2"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MultipleSubst index="0">
<Substitution in="f_i" out="f,i"/>
<Substitution in="f_l" out="f,l"/>
</MultipleSubst>
</Lookup>
<Lookup index="5">
<LookupType value="6"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<ChainContextSubst index="0" Format="3">
<!-- BacktrackGlyphCount=0 -->
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="f_l"/>
<Glyph value="f_i"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="i"/>
<Glyph value="l"/>
</LookAheadCoverage>
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="4"/>
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="6">
<LookupType value="6"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<ChainContextSubst index="0" Format="3">
<!-- BacktrackGlyphCount=0 -->
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="f_i"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="j"/>
</LookAheadCoverage>
<!-- SubstCount=1 -->
<SubstLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="7"/>
</SubstLookupRecord>
</ChainContextSubst>
</Lookup>
<Lookup index="7">
<LookupType value="2"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<MultipleSubst index="0">
<Substitution in="f_i" out="f,i"/>
</MultipleSubst>
</Lookup>
</LookupList>
</GSUB>

Expand Down
Loading

0 comments on commit a479b74

Please sign in to comment.