Add debug tests
This commit is contained in:
parent
8869e0dec7
commit
70b514270e
@ -114,12 +114,16 @@ class BuilderTest(unittest.TestCase):
|
|||||||
lines.append(line.rstrip() + os.linesep)
|
lines.append(line.rstrip() + os.linesep)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def expect_ttx(self, font, expected_ttx):
|
def expect_ttx(self, font, expected_ttx, replace=None):
|
||||||
path = self.temp_path(suffix=".ttx")
|
path = self.temp_path(suffix=".ttx")
|
||||||
font.saveXML(path, tables=['head', 'name', 'BASE', 'GDEF', 'GSUB',
|
font.saveXML(path, tables=['head', 'name', 'BASE', 'GDEF', 'GSUB',
|
||||||
'GPOS', 'OS/2', 'hhea', 'vhea'])
|
'GPOS', 'OS/2', 'hhea', 'vhea'])
|
||||||
actual = self.read_ttx(path)
|
actual = self.read_ttx(path)
|
||||||
expected = self.read_ttx(expected_ttx)
|
expected = self.read_ttx(expected_ttx)
|
||||||
|
if replace:
|
||||||
|
for i in range(len(expected)):
|
||||||
|
for k,v in replace.items():
|
||||||
|
expected[i] = expected[i].replace(k,v)
|
||||||
if actual != expected:
|
if actual != expected:
|
||||||
for line in difflib.unified_diff(
|
for line in difflib.unified_diff(
|
||||||
expected, actual, fromfile=expected_ttx, tofile=path):
|
expected, actual, fromfile=expected_ttx, tofile=path):
|
||||||
@ -133,12 +137,18 @@ class BuilderTest(unittest.TestCase):
|
|||||||
|
|
||||||
def check_feature_file(self, name):
|
def check_feature_file(self, name):
|
||||||
font = makeTTFont()
|
font = makeTTFont()
|
||||||
addOpenTypeFeatures(font, self.getpath("%s.fea" % name))
|
feapath = self.getpath("%s.fea" % name)
|
||||||
|
addOpenTypeFeatures(font, feapath)
|
||||||
self.expect_ttx(font, self.getpath("%s.ttx" % name))
|
self.expect_ttx(font, self.getpath("%s.ttx" % name))
|
||||||
# Make sure we can produce binary OpenType tables, not just XML.
|
# Make sure we can produce binary OpenType tables, not just XML.
|
||||||
for tag in ('GDEF', 'GSUB', 'GPOS'):
|
for tag in ('GDEF', 'GSUB', 'GPOS'):
|
||||||
if tag in font:
|
if tag in font:
|
||||||
font[tag].compile(font)
|
font[tag].compile(font)
|
||||||
|
debugttx = self.getpath("%s-debug.ttx" % name)
|
||||||
|
if os.path.exists(debugttx):
|
||||||
|
addOpenTypeFeatures(font, feapath,
|
||||||
|
debug=True)
|
||||||
|
self.expect_ttx(font, debugttx, replace = { "__PATH__": feapath })
|
||||||
|
|
||||||
def check_fea2fea_file(self, name, base=None, parser=Parser):
|
def check_fea2fea_file(self, name, base=None, parser=Parser):
|
||||||
font = makeTTFont()
|
font = makeTTFont()
|
||||||
@ -618,7 +628,6 @@ class BuilderTest(unittest.TestCase):
|
|||||||
"} test;")
|
"} test;")
|
||||||
captor.assertRegex('Already defined position for pair A V at')
|
captor.assertRegex('Already defined position for pair A V at')
|
||||||
|
|
||||||
|
|
||||||
def generate_feature_file_test(name):
|
def generate_feature_file_test(name):
|
||||||
return lambda self: self.check_feature_file(name)
|
return lambda self: self.check_feature_file(name)
|
||||||
|
|
||||||
|
80
Tests/feaLib/data/lookup-debug.ttx
Normal file
80
Tests/feaLib/data/lookup-debug.ttx
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ttFont>
|
||||||
|
|
||||||
|
<GSUB>
|
||||||
|
<Version value="0x00010000"/>
|
||||||
|
<ScriptList>
|
||||||
|
<!-- ScriptCount=1 -->
|
||||||
|
<ScriptRecord index="0">
|
||||||
|
<ScriptTag value="DFLT"/>
|
||||||
|
<Script>
|
||||||
|
<DefaultLangSys>
|
||||||
|
<ReqFeatureIndex value="65535"/>
|
||||||
|
<!-- FeatureCount=4 -->
|
||||||
|
<FeatureIndex index="0" value="0"/>
|
||||||
|
<FeatureIndex index="1" value="1"/>
|
||||||
|
<FeatureIndex index="2" value="2"/>
|
||||||
|
<FeatureIndex index="3" value="3"/>
|
||||||
|
</DefaultLangSys>
|
||||||
|
<!-- LangSysCount=0 -->
|
||||||
|
</Script>
|
||||||
|
</ScriptRecord>
|
||||||
|
</ScriptList>
|
||||||
|
<FeatureList>
|
||||||
|
<!-- FeatureCount=4 -->
|
||||||
|
<FeatureRecord index="0">
|
||||||
|
<FeatureTag value="tst1"/>
|
||||||
|
<Feature>
|
||||||
|
<!-- LookupCount=1 -->
|
||||||
|
<LookupListIndex index="0" value="0"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
|
<FeatureRecord index="1">
|
||||||
|
<FeatureTag value="tst2"/>
|
||||||
|
<Feature>
|
||||||
|
<!-- LookupCount=1 -->
|
||||||
|
<LookupListIndex index="0" value="0"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
|
<FeatureRecord index="2">
|
||||||
|
<FeatureTag value="tst3"/>
|
||||||
|
<Feature>
|
||||||
|
<!-- LookupCount=1 -->
|
||||||
|
<LookupListIndex index="0" value="1"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
|
<FeatureRecord index="3">
|
||||||
|
<FeatureTag value="tst4"/>
|
||||||
|
<Feature>
|
||||||
|
<!-- LookupCount=1 -->
|
||||||
|
<LookupListIndex index="0" value="1"/>
|
||||||
|
</Feature>
|
||||||
|
</FeatureRecord>
|
||||||
|
</FeatureList>
|
||||||
|
<LookupList>
|
||||||
|
<!-- LookupCount=2 -->
|
||||||
|
<!-- SomeLookup: __PATH__:4:5 in tst2 (DFLT/dflt) -->
|
||||||
|
<Lookup index="0">
|
||||||
|
<LookupType value="4"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<LigatureSubst index="0">
|
||||||
|
<LigatureSet glyph="f">
|
||||||
|
<Ligature components="f,i" glyph="f_f_i"/>
|
||||||
|
<Ligature components="i" glyph="f_i"/>
|
||||||
|
</LigatureSet>
|
||||||
|
</LigatureSubst>
|
||||||
|
</Lookup>
|
||||||
|
<!-- EmbeddedLookup: __PATH__:18:9 in tst4 (DFLT/dflt) -->
|
||||||
|
<Lookup index="1">
|
||||||
|
<LookupType value="1"/>
|
||||||
|
<LookupFlag value="0"/>
|
||||||
|
<!-- SubTableCount=1 -->
|
||||||
|
<SingleSubst index="0">
|
||||||
|
<Substitution in="A" out="A.sc"/>
|
||||||
|
</SingleSubst>
|
||||||
|
</Lookup>
|
||||||
|
</LookupList>
|
||||||
|
</GSUB>
|
||||||
|
|
||||||
|
</ttFont>
|
Loading…
x
Reference in New Issue
Block a user