[feaLib] Add tests for zero values in contextual positioning

Specifically, contextual positioning statements with in-line single
positioning rules, in horizontal and in vertical contexts. For these
test cases, feaLib and makeotf produce the exact same output.

https://github.com/fonttools/fonttools/issues/633
This commit is contained in:
Sascha Brawer 2017-02-17 13:49:32 +01:00
parent a2e7d96cf4
commit 45c266441e
5 changed files with 197 additions and 0 deletions

View File

@ -67,6 +67,7 @@ class BuilderTest(unittest.TestCase):
name size size2 multiple_feature_blocks omitted_GlyphClassDef
ZeroValue_SinglePos
ZeroValue_PairPos_horizontal ZeroValue_PairPos_vertical
ZeroValue_ChainSinglePos_horizontal ZeroValue_ChainSinglePos_vertical
""".split()
def __init__(self, methodName):

View File

@ -0,0 +1,9 @@
# For contextual positioning statements with in-line single positioning rules,
# zeroes should get compiled to ValueRecord format 0.
# https://github.com/fonttools/fonttools/issues/633
# Zero value in a horizontal context.
feature kern {
pos A G' 0 A; # value format A
pos B G' <0 0 0 0> B; # value format B
} kern;

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="true" ttLibVersion="3.7">
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
</ScriptList>
<FeatureList>
<!-- FeatureCount=1 -->
<FeatureRecord index="0">
<FeatureTag value="kern"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<Lookup index="0">
<LookupType value="8"/>
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
<ChainContextPos index="0" Format="3">
<!-- BacktrackGlyphCount=1 -->
<BacktrackCoverage index="0">
<Glyph value="A"/>
</BacktrackCoverage>
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="G"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="A"/>
</LookAheadCoverage>
<!-- PosCount=1 -->
<PosLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="1"/>
</PosLookupRecord>
</ChainContextPos>
<ChainContextPos index="1" Format="3">
<!-- BacktrackGlyphCount=1 -->
<BacktrackCoverage index="0">
<Glyph value="B"/>
</BacktrackCoverage>
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="G"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="B"/>
</LookAheadCoverage>
<!-- PosCount=1 -->
<PosLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="1"/>
</PosLookupRecord>
</ChainContextPos>
</Lookup>
<Lookup index="1">
<LookupType value="1"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SinglePos index="0" Format="1">
<Coverage>
<Glyph value="G"/>
</Coverage>
<ValueFormat value="0"/>
</SinglePos>
</Lookup>
</LookupList>
</GPOS>
</ttFont>

View File

@ -0,0 +1,9 @@
# For contextual positioning statements with in-line single positioning rules,
# zeroes should get compiled to ValueRecord format 0.
# https://github.com/fonttools/fonttools/issues/633
# Zero value in a vertical context.
feature vkrn {
pos A G' 0 A; # value format A
pos B G' <0 0 0 0> B; # value format B
} vkrn;

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="true" ttLibVersion="3.7">
<GPOS>
<Version value="0x00010000"/>
<ScriptList>
<!-- ScriptCount=1 -->
<ScriptRecord index="0">
<ScriptTag value="DFLT"/>
<Script>
<DefaultLangSys>
<ReqFeatureIndex value="65535"/>
<!-- FeatureCount=1 -->
<FeatureIndex index="0" value="0"/>
</DefaultLangSys>
<!-- LangSysCount=0 -->
</Script>
</ScriptRecord>
</ScriptList>
<FeatureList>
<!-- FeatureCount=1 -->
<FeatureRecord index="0">
<FeatureTag value="vkrn"/>
<Feature>
<!-- LookupCount=1 -->
<LookupListIndex index="0" value="0"/>
</Feature>
</FeatureRecord>
</FeatureList>
<LookupList>
<!-- LookupCount=2 -->
<Lookup index="0">
<LookupType value="8"/>
<LookupFlag value="0"/>
<!-- SubTableCount=2 -->
<ChainContextPos index="0" Format="3">
<!-- BacktrackGlyphCount=1 -->
<BacktrackCoverage index="0">
<Glyph value="A"/>
</BacktrackCoverage>
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="G"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="A"/>
</LookAheadCoverage>
<!-- PosCount=1 -->
<PosLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="1"/>
</PosLookupRecord>
</ChainContextPos>
<ChainContextPos index="1" Format="3">
<!-- BacktrackGlyphCount=1 -->
<BacktrackCoverage index="0">
<Glyph value="B"/>
</BacktrackCoverage>
<!-- InputGlyphCount=1 -->
<InputCoverage index="0">
<Glyph value="G"/>
</InputCoverage>
<!-- LookAheadGlyphCount=1 -->
<LookAheadCoverage index="0">
<Glyph value="B"/>
</LookAheadCoverage>
<!-- PosCount=1 -->
<PosLookupRecord index="0">
<SequenceIndex value="0"/>
<LookupListIndex value="1"/>
</PosLookupRecord>
</ChainContextPos>
</Lookup>
<Lookup index="1">
<LookupType value="1"/>
<LookupFlag value="0"/>
<!-- SubTableCount=1 -->
<SinglePos index="0" Format="1">
<Coverage>
<Glyph value="G"/>
</Coverage>
<ValueFormat value="0"/>
</SinglePos>
</Lookup>
</LookupList>
</GPOS>
</ttFont>