As requested: black Tests/otlLib/builder_test.py

This commit is contained in:
Olli Meier 2022-02-11 15:58:34 +01:00
parent 3b1fac049d
commit 86e4795405

View File

@ -918,7 +918,6 @@ class BuilderTest(object):
("A", "zero"): (d0, d50), ("A", "zero"): (d0, d50),
("A", "one"): (None, d20), ("A", "one"): (None, d20),
("B", "five"): (d8020, d50), ("B", "five"): (d8020, d50),
}, },
self.GLYPHMAP, self.GLYPHMAP,
) )
@ -1120,262 +1119,309 @@ class ClassDefBuilderTest(object):
buildStatTable_test_data = [ buildStatTable_test_data = [
([ (
dict( [
tag="wght", dict(
name="Weight", tag="wght",
values=[ name="Weight",
dict(value=100, name='Thin'), values=[
dict(value=400, name='Regular', flags=0x2), dict(value=100, name="Thin"),
dict(value=900, name='Black')])], None, "Regular", [ dict(value=400, name="Regular", flags=0x2),
' <STAT>', dict(value=900, name="Black"),
' <Version value="0x00010001"/>', ],
' <DesignAxisRecordSize value="8"/>', )
' <!-- DesignAxisCount=1 -->', ],
' <DesignAxisRecord>', None,
' <Axis index="0">', "Regular",
' <AxisTag value="wght"/>', [
' <AxisNameID value="257"/> <!-- Weight -->', " <STAT>",
' <AxisOrdering value="0"/>', ' <Version value="0x00010001"/>',
' </Axis>', ' <DesignAxisRecordSize value="8"/>',
' </DesignAxisRecord>', " <!-- DesignAxisCount=1 -->",
' <!-- AxisValueCount=3 -->', " <DesignAxisRecord>",
' <AxisValueArray>', ' <Axis index="0">',
' <AxisValue index="0" Format="1">', ' <AxisTag value="wght"/>',
' <AxisIndex value="0"/>', ' <AxisNameID value="257"/> <!-- Weight -->',
' <Flags value="0"/>', ' <AxisOrdering value="0"/>',
' <ValueNameID value="258"/> <!-- Thin -->', " </Axis>",
' <Value value="100.0"/>', " </DesignAxisRecord>",
' </AxisValue>', " <!-- AxisValueCount=3 -->",
' <AxisValue index="1" Format="1">', " <AxisValueArray>",
' <AxisIndex value="0"/>', ' <AxisValue index="0" Format="1">',
' <Flags value="2"/> <!-- ElidableAxisValueName -->', ' <AxisIndex value="0"/>',
' <ValueNameID value="256"/> <!-- Regular -->', ' <Flags value="0"/>',
' <Value value="400.0"/>', ' <ValueNameID value="258"/> <!-- Thin -->',
' </AxisValue>', ' <Value value="100.0"/>',
' <AxisValue index="2" Format="1">', " </AxisValue>",
' <AxisIndex value="0"/>', ' <AxisValue index="1" Format="1">',
' <Flags value="0"/>', ' <AxisIndex value="0"/>',
' <ValueNameID value="259"/> <!-- Black -->', ' <Flags value="2"/> <!-- ElidableAxisValueName -->',
' <Value value="900.0"/>', ' <ValueNameID value="256"/> <!-- Regular -->',
' </AxisValue>', ' <Value value="400.0"/>',
' </AxisValueArray>', " </AxisValue>",
' <ElidedFallbackNameID value="256"/> <!-- Regular -->', ' <AxisValue index="2" Format="1">',
' </STAT>']), ' <AxisIndex value="0"/>',
([ ' <Flags value="0"/>',
dict( ' <ValueNameID value="259"/> <!-- Black -->',
tag="wght", ' <Value value="900.0"/>',
name=dict(en="Weight", nl="Gewicht"), " </AxisValue>",
values=[ " </AxisValueArray>",
dict(value=100, name=dict(en='Thin', nl='Dun')), ' <ElidedFallbackNameID value="256"/> <!-- Regular -->',
dict(value=400, name='Regular', flags=0x2), " </STAT>",
dict(value=900, name='Black'), ],
]), ),
dict( (
tag="wdth", [
name="Width", dict(
values=[ tag="wght",
dict(value=50, name='Condensed'), name=dict(en="Weight", nl="Gewicht"),
dict(value=100, name='Regular', flags=0x2), values=[
dict(value=200, name='Extended')])], None, 2, [ dict(value=100, name=dict(en="Thin", nl="Dun")),
' <STAT>', dict(value=400, name="Regular", flags=0x2),
' <Version value="0x00010001"/>', dict(value=900, name="Black"),
' <DesignAxisRecordSize value="8"/>', ],
' <!-- DesignAxisCount=2 -->', ),
' <DesignAxisRecord>', dict(
' <Axis index="0">', tag="wdth",
' <AxisTag value="wght"/>', name="Width",
' <AxisNameID value="256"/> <!-- Weight -->', values=[
' <AxisOrdering value="0"/>', dict(value=50, name="Condensed"),
' </Axis>', dict(value=100, name="Regular", flags=0x2),
' <Axis index="1">', dict(value=200, name="Extended"),
' <AxisTag value="wdth"/>', ],
' <AxisNameID value="260"/> <!-- Width -->', ),
' <AxisOrdering value="1"/>', ],
' </Axis>', None,
' </DesignAxisRecord>', 2,
' <!-- AxisValueCount=6 -->', [
' <AxisValueArray>', " <STAT>",
' <AxisValue index="0" Format="1">', ' <Version value="0x00010001"/>',
' <AxisIndex value="0"/>', ' <DesignAxisRecordSize value="8"/>',
' <Flags value="0"/>', " <!-- DesignAxisCount=2 -->",
' <ValueNameID value="257"/> <!-- Thin -->', " <DesignAxisRecord>",
' <Value value="100.0"/>', ' <Axis index="0">',
' </AxisValue>', ' <AxisTag value="wght"/>',
' <AxisValue index="1" Format="1">', ' <AxisNameID value="256"/> <!-- Weight -->',
' <AxisIndex value="0"/>', ' <AxisOrdering value="0"/>',
' <Flags value="2"/> <!-- ElidableAxisValueName -->', " </Axis>",
' <ValueNameID value="258"/> <!-- Regular -->', ' <Axis index="1">',
' <Value value="400.0"/>', ' <AxisTag value="wdth"/>',
' </AxisValue>', ' <AxisNameID value="260"/> <!-- Width -->',
' <AxisValue index="2" Format="1">', ' <AxisOrdering value="1"/>',
' <AxisIndex value="0"/>', " </Axis>",
' <Flags value="0"/>', " </DesignAxisRecord>",
' <ValueNameID value="259"/> <!-- Black -->', " <!-- AxisValueCount=6 -->",
' <Value value="900.0"/>', " <AxisValueArray>",
' </AxisValue>', ' <AxisValue index="0" Format="1">',
' <AxisValue index="3" Format="1">', ' <AxisIndex value="0"/>',
' <AxisIndex value="1"/>', ' <Flags value="0"/>',
' <Flags value="0"/>', ' <ValueNameID value="257"/> <!-- Thin -->',
' <ValueNameID value="261"/> <!-- Condensed -->', ' <Value value="100.0"/>',
' <Value value="50.0"/>', " </AxisValue>",
' </AxisValue>', ' <AxisValue index="1" Format="1">',
' <AxisValue index="4" Format="1">', ' <AxisIndex value="0"/>',
' <AxisIndex value="1"/>', ' <Flags value="2"/> <!-- ElidableAxisValueName -->',
' <Flags value="2"/> <!-- ElidableAxisValueName -->', ' <ValueNameID value="258"/> <!-- Regular -->',
' <ValueNameID value="258"/> <!-- Regular -->', ' <Value value="400.0"/>',
' <Value value="100.0"/>', " </AxisValue>",
' </AxisValue>', ' <AxisValue index="2" Format="1">',
' <AxisValue index="5" Format="1">', ' <AxisIndex value="0"/>',
' <AxisIndex value="1"/>', ' <Flags value="0"/>',
' <Flags value="0"/>', ' <ValueNameID value="259"/> <!-- Black -->',
' <ValueNameID value="262"/> <!-- Extended -->', ' <Value value="900.0"/>',
' <Value value="200.0"/>', " </AxisValue>",
' </AxisValue>', ' <AxisValue index="3" Format="1">',
' </AxisValueArray>', ' <AxisIndex value="1"/>',
' <ElidedFallbackNameID value="2"/> <!-- missing from name table -->', ' <Flags value="0"/>',
' </STAT>']), ' <ValueNameID value="261"/> <!-- Condensed -->',
([ ' <Value value="50.0"/>',
dict( " </AxisValue>",
tag="wght", ' <AxisValue index="4" Format="1">',
name="Weight", ' <AxisIndex value="1"/>',
values=[ ' <Flags value="2"/> <!-- ElidableAxisValueName -->',
dict(value=400, name='Regular', flags=0x2), ' <ValueNameID value="258"/> <!-- Regular -->',
dict(value=600, linkedValue=650, name='Bold')])], None, 18, [ ' <Value value="100.0"/>',
' <STAT>', " </AxisValue>",
' <Version value="0x00010001"/>', ' <AxisValue index="5" Format="1">',
' <DesignAxisRecordSize value="8"/>', ' <AxisIndex value="1"/>',
' <!-- DesignAxisCount=1 -->', ' <Flags value="0"/>',
' <DesignAxisRecord>', ' <ValueNameID value="262"/> <!-- Extended -->',
' <Axis index="0">', ' <Value value="200.0"/>',
' <AxisTag value="wght"/>', " </AxisValue>",
' <AxisNameID value="256"/> <!-- Weight -->', " </AxisValueArray>",
' <AxisOrdering value="0"/>', ' <ElidedFallbackNameID value="2"/> <!-- missing from name table -->',
' </Axis>', " </STAT>",
' </DesignAxisRecord>', ],
' <!-- AxisValueCount=2 -->', ),
' <AxisValueArray>', (
' <AxisValue index="0" Format="1">', [
' <AxisIndex value="0"/>', dict(
' <Flags value="2"/> <!-- ElidableAxisValueName -->', tag="wght",
' <ValueNameID value="257"/> <!-- Regular -->', name="Weight",
' <Value value="400.0"/>', values=[
' </AxisValue>', dict(value=400, name="Regular", flags=0x2),
' <AxisValue index="1" Format="3">', dict(value=600, linkedValue=650, name="Bold"),
' <AxisIndex value="0"/>', ],
' <Flags value="0"/>', )
' <ValueNameID value="258"/> <!-- Bold -->', ],
' <Value value="600.0"/>', None,
' <LinkedValue value="650.0"/>', 18,
' </AxisValue>', [
' </AxisValueArray>', " <STAT>",
' <ElidedFallbackNameID value="18"/> <!-- missing from name table -->', ' <Version value="0x00010001"/>',
' </STAT>']), ' <DesignAxisRecordSize value="8"/>',
([ " <!-- DesignAxisCount=1 -->",
dict( " <DesignAxisRecord>",
tag="opsz", ' <Axis index="0">',
name="Optical Size", ' <AxisTag value="wght"/>',
values=[ ' <AxisNameID value="256"/> <!-- Weight -->',
dict(nominalValue=6, rangeMaxValue=10, name='Small'), ' <AxisOrdering value="0"/>',
dict(rangeMinValue=10, nominalValue=14, rangeMaxValue=24, name='Text', flags=0x2), " </Axis>",
dict(rangeMinValue=24, nominalValue=600, name='Display')])], None, 2, [ " </DesignAxisRecord>",
' <STAT>', " <!-- AxisValueCount=2 -->",
' <Version value="0x00010001"/>', " <AxisValueArray>",
' <DesignAxisRecordSize value="8"/>', ' <AxisValue index="0" Format="1">',
' <!-- DesignAxisCount=1 -->', ' <AxisIndex value="0"/>',
' <DesignAxisRecord>', ' <Flags value="2"/> <!-- ElidableAxisValueName -->',
' <Axis index="0">', ' <ValueNameID value="257"/> <!-- Regular -->',
' <AxisTag value="opsz"/>', ' <Value value="400.0"/>',
' <AxisNameID value="256"/> <!-- Optical Size -->', " </AxisValue>",
' <AxisOrdering value="0"/>', ' <AxisValue index="1" Format="3">',
' </Axis>', ' <AxisIndex value="0"/>',
' </DesignAxisRecord>', ' <Flags value="0"/>',
' <!-- AxisValueCount=3 -->', ' <ValueNameID value="258"/> <!-- Bold -->',
' <AxisValueArray>', ' <Value value="600.0"/>',
' <AxisValue index="0" Format="2">', ' <LinkedValue value="650.0"/>',
' <AxisIndex value="0"/>', " </AxisValue>",
' <Flags value="0"/>', " </AxisValueArray>",
' <ValueNameID value="257"/> <!-- Small -->', ' <ElidedFallbackNameID value="18"/> <!-- missing from name table -->',
' <NominalValue value="6.0"/>', " </STAT>",
' <RangeMinValue value="-32768.0"/>', ],
' <RangeMaxValue value="10.0"/>', ),
' </AxisValue>', (
' <AxisValue index="1" Format="2">', [
' <AxisIndex value="0"/>', dict(
' <Flags value="2"/> <!-- ElidableAxisValueName -->', tag="opsz",
' <ValueNameID value="258"/> <!-- Text -->', name="Optical Size",
' <NominalValue value="14.0"/>', values=[
' <RangeMinValue value="10.0"/>', dict(nominalValue=6, rangeMaxValue=10, name="Small"),
' <RangeMaxValue value="24.0"/>', dict(
' </AxisValue>', rangeMinValue=10,
' <AxisValue index="2" Format="2">', nominalValue=14,
' <AxisIndex value="0"/>', rangeMaxValue=24,
' <Flags value="0"/>', name="Text",
' <ValueNameID value="259"/> <!-- Display -->', flags=0x2,
' <NominalValue value="600.0"/>', ),
' <RangeMinValue value="24.0"/>', dict(rangeMinValue=24, nominalValue=600, name="Display"),
' <RangeMaxValue value="32767.99998"/>', ],
' </AxisValue>', )
' </AxisValueArray>', ],
' <ElidedFallbackNameID value="2"/> <!-- missing from name table -->', None,
' </STAT>']), 2,
([ [
dict( " <STAT>",
tag="wght", ' <Version value="0x00010001"/>',
name="Weight", ' <DesignAxisRecordSize value="8"/>',
ordering=1, " <!-- DesignAxisCount=1 -->",
values=[]), " <DesignAxisRecord>",
dict( ' <Axis index="0">',
tag="ABCD", ' <AxisTag value="opsz"/>',
name="ABCDTest", ' <AxisNameID value="256"/> <!-- Optical Size -->',
ordering=0, ' <AxisOrdering value="0"/>',
values=[ " </Axis>",
dict(value=100, name="Regular", flags=0x2)])], " </DesignAxisRecord>",
[dict(location=dict(wght=300, ABCD=100), name='Regular ABCD')], 18, [ " <!-- AxisValueCount=3 -->",
' <STAT>', " <AxisValueArray>",
' <Version value="0x00010002"/>', ' <AxisValue index="0" Format="2">',
' <DesignAxisRecordSize value="8"/>', ' <AxisIndex value="0"/>',
' <!-- DesignAxisCount=2 -->', ' <Flags value="0"/>',
' <DesignAxisRecord>', ' <ValueNameID value="257"/> <!-- Small -->',
' <Axis index="0">', ' <NominalValue value="6.0"/>',
' <AxisTag value="wght"/>', ' <RangeMinValue value="-32768.0"/>',
' <AxisNameID value="256"/> <!-- Weight -->', ' <RangeMaxValue value="10.0"/>',
' <AxisOrdering value="1"/>', " </AxisValue>",
' </Axis>', ' <AxisValue index="1" Format="2">',
' <Axis index="1">', ' <AxisIndex value="0"/>',
' <AxisTag value="ABCD"/>', ' <Flags value="2"/> <!-- ElidableAxisValueName -->',
' <AxisNameID value="257"/> <!-- ABCDTest -->', ' <ValueNameID value="258"/> <!-- Text -->',
' <AxisOrdering value="0"/>', ' <NominalValue value="14.0"/>',
' </Axis>', ' <RangeMinValue value="10.0"/>',
' </DesignAxisRecord>', ' <RangeMaxValue value="24.0"/>',
' <!-- AxisValueCount=2 -->', " </AxisValue>",
' <AxisValueArray>', ' <AxisValue index="2" Format="2">',
' <AxisValue index="0" Format="4">', ' <AxisIndex value="0"/>',
' <!-- AxisCount=2 -->', ' <Flags value="0"/>',
' <Flags value="0"/>', ' <ValueNameID value="259"/> <!-- Display -->',
' <ValueNameID value="259"/> <!-- Regular ABCD -->', ' <NominalValue value="600.0"/>',
' <AxisValueRecord index="0">', ' <RangeMinValue value="24.0"/>',
' <AxisIndex value="0"/>', ' <RangeMaxValue value="32767.99998"/>',
' <Value value="300.0"/>', " </AxisValue>",
' </AxisValueRecord>', " </AxisValueArray>",
' <AxisValueRecord index="1">', ' <ElidedFallbackNameID value="2"/> <!-- missing from name table -->',
' <AxisIndex value="1"/>', " </STAT>",
' <Value value="100.0"/>', ],
' </AxisValueRecord>', ),
' </AxisValue>', (
' <AxisValue index="1" Format="1">', [
' <AxisIndex value="1"/>', dict(tag="wght", name="Weight", ordering=1, values=[]),
' <Flags value="2"/> <!-- ElidableAxisValueName -->', dict(
' <ValueNameID value="258"/> <!-- Regular -->', tag="ABCD",
' <Value value="100.0"/>', name="ABCDTest",
' </AxisValue>', ordering=0,
' </AxisValueArray>', values=[dict(value=100, name="Regular", flags=0x2)],
' <ElidedFallbackNameID value="18"/> <!-- missing from name table -->', ),
' </STAT>']), ],
[dict(location=dict(wght=300, ABCD=100), name="Regular ABCD")],
18,
[
" <STAT>",
' <Version value="0x00010002"/>',
' <DesignAxisRecordSize value="8"/>',
" <!-- DesignAxisCount=2 -->",
" <DesignAxisRecord>",
' <Axis index="0">',
' <AxisTag value="wght"/>',
' <AxisNameID value="256"/> <!-- Weight -->',
' <AxisOrdering value="1"/>',
" </Axis>",
' <Axis index="1">',
' <AxisTag value="ABCD"/>',
' <AxisNameID value="257"/> <!-- ABCDTest -->',
' <AxisOrdering value="0"/>',
" </Axis>",
" </DesignAxisRecord>",
" <!-- AxisValueCount=2 -->",
" <AxisValueArray>",
' <AxisValue index="0" Format="4">',
" <!-- AxisCount=2 -->",
' <Flags value="0"/>',
' <ValueNameID value="259"/> <!-- Regular ABCD -->',
' <AxisValueRecord index="0">',
' <AxisIndex value="0"/>',
' <Value value="300.0"/>',
" </AxisValueRecord>",
' <AxisValueRecord index="1">',
' <AxisIndex value="1"/>',
' <Value value="100.0"/>',
" </AxisValueRecord>",
" </AxisValue>",
' <AxisValue index="1" Format="1">',
' <AxisIndex value="1"/>',
' <Flags value="2"/> <!-- ElidableAxisValueName -->',
' <ValueNameID value="258"/> <!-- Regular -->',
' <Value value="100.0"/>',
" </AxisValue>",
" </AxisValueArray>",
' <ElidedFallbackNameID value="18"/> <!-- missing from name table -->',
" </STAT>",
],
),
] ]
@pytest.mark.parametrize("axes, axisValues, elidedFallbackName, expected_ttx", buildStatTable_test_data) @pytest.mark.parametrize(
"axes, axisValues, elidedFallbackName, expected_ttx", buildStatTable_test_data
)
def test_buildStatTable(axes, axisValues, elidedFallbackName, expected_ttx): def test_buildStatTable(axes, axisValues, elidedFallbackName, expected_ttx):
font = ttLib.TTFont() font = ttLib.TTFont()
font["name"] = ttLib.newTable("name") font["name"] = ttLib.newTable("name")
@ -1414,7 +1460,13 @@ def test_buildStatTable_platform_specific_names():
wght_values = [ wght_values = [
dict(nominalValue=200, rangeMinValue=200, rangeMaxValue=250, name="ExtraLight"), dict(nominalValue=200, rangeMinValue=200, rangeMaxValue=250, name="ExtraLight"),
dict(nominalValue=300, rangeMinValue=250, rangeMaxValue=350, name="Light"), dict(nominalValue=300, rangeMinValue=250, rangeMaxValue=350, name="Light"),
dict(nominalValue=400, rangeMinValue=350, rangeMaxValue=450, name="Regular", flags=0x2), dict(
nominalValue=400,
rangeMinValue=350,
rangeMaxValue=450,
name="Regular",
flags=0x2,
),
dict(nominalValue=500, rangeMinValue=450, rangeMaxValue=650, name="Medium"), dict(nominalValue=500, rangeMinValue=450, rangeMaxValue=650, name="Medium"),
dict(nominalValue=700, rangeMinValue=650, rangeMaxValue=750, name="Bold"), dict(nominalValue=700, rangeMinValue=650, rangeMaxValue=750, name="Bold"),
dict(nominalValue=800, rangeMinValue=750, rangeMaxValue=850, name="ExtraBold"), dict(nominalValue=800, rangeMinValue=750, rangeMaxValue=850, name="ExtraBold"),
@ -1430,15 +1482,15 @@ def test_buildStatTable_platform_specific_names():
), ),
] ]
font_obj["name"].setName('ExtraLight', 260, 3, 1, 0x409) font_obj["name"].setName("ExtraLight", 260, 3, 1, 0x409)
font_obj["name"].setName('Light', 261, 3, 1, 0x409) font_obj["name"].setName("Light", 261, 3, 1, 0x409)
font_obj["name"].setName('Regular', 262, 3, 1, 0x409) font_obj["name"].setName("Regular", 262, 3, 1, 0x409)
font_obj["name"].setName('Medium', 263, 3, 1, 0x409) font_obj["name"].setName("Medium", 263, 3, 1, 0x409)
font_obj["name"].setName('Bold', 264, 3, 1, 0x409) font_obj["name"].setName("Bold", 264, 3, 1, 0x409)
font_obj["name"].setName('ExtraBold', 265, 3, 1, 0x409) font_obj["name"].setName("ExtraBold", 265, 3, 1, 0x409)
font_obj["name"].setName('Black', 266, 3, 1, 0x409) font_obj["name"].setName("Black", 266, 3, 1, 0x409)
font_obj["name"].setName('Weight', 270, 3, 1, 0x409) font_obj["name"].setName("Weight", 270, 3, 1, 0x409)
expected_names = [x.string for x in font_obj["name"].names] expected_names = [x.string for x in font_obj["name"].names]
@ -1450,7 +1502,7 @@ def test_buildStatTable_platform_specific_names():
assert expected_names == actual_names assert expected_names == actual_names
font_obj["name"].removeNames(nameID=270) font_obj["name"].removeNames(nameID=270)
expected_names = [x.string for x in font_obj["name"].names] + ['Weight'] expected_names = [x.string for x in font_obj["name"].names] + ["Weight"]
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=False) builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=False)
actual_names = [x.string for x in font_obj["name"].names] actual_names = [x.string for x in font_obj["name"].names]
@ -1459,14 +1511,32 @@ def test_buildStatTable_platform_specific_names():
builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=True) builder.buildStatTable(font_obj, AXES, windowsNames=True, macNames=True)
actual_names = [x.string for x in font_obj["name"].names] actual_names = [x.string for x in font_obj["name"].names]
expected_names = ['Weight', 'Weight', 'Weight', expected_names = [
'ExtraLight', 'ExtraLight', 'ExtraLight', "Weight",
'Light', 'Light', 'Light', "Weight",
'Regular', 'Regular', 'Regular', "Weight",
'Medium', 'Medium', 'Medium', "ExtraLight",
'Bold', 'Bold', 'Bold', "ExtraLight",
'ExtraBold', 'ExtraBold', 'ExtraBold', "ExtraLight",
'Black', 'Black', 'Black'] "Light",
"Light",
"Light",
"Regular",
"Regular",
"Regular",
"Medium",
"Medium",
"Medium",
"Bold",
"Bold",
"Bold",
"ExtraBold",
"ExtraBold",
"ExtraBold",
"Black",
"Black",
"Black",
]
# Because there is an inconsistency in the names add new name IDs # Because there is an inconsistency in the names add new name IDs
# for each platform -> windowsNames=True, macNames=True # for each platform -> windowsNames=True, macNames=True
assert sorted(expected_names) == sorted(actual_names) assert sorted(expected_names) == sorted(actual_names)
@ -1482,7 +1552,7 @@ def test_stat_infinities():
class ChainContextualRulesetTest(object): class ChainContextualRulesetTest(object):
def test_makeRulesets(self): def test_makeRulesets(self):
font = ttLib.TTFont() font = ttLib.TTFont()
font.setGlyphOrder(["a","b","c","d","A","B","C","D","E"]) font.setGlyphOrder(["a", "b", "c", "d", "A", "B", "C", "D", "E"])
sb = builder.ChainContextSubstBuilder(font, None) sb = builder.ChainContextSubstBuilder(font, None)
prefix, input_, suffix, lookups = [["a"], ["b"]], [["c"]], [], [None] prefix, input_, suffix, lookups = [["a"], ["b"]], [["c"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
@ -1495,7 +1565,7 @@ class ChainContextualRulesetTest(object):
# Second subtable has some glyph classes # Second subtable has some glyph classes
prefix, input_, suffix, lookups = [["A"]], [["E"]], [], [None] prefix, input_, suffix, lookups = [["A"]], [["E"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
prefix, input_, suffix, lookups = [["A"]], [["C","D"]], [], [None] prefix, input_, suffix, lookups = [["A"]], [["C", "D"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
prefix, input_, suffix, lookups = [["A", "B"]], [["E"]], [], [None] prefix, input_, suffix, lookups = [["A", "B"]], [["E"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
@ -1505,7 +1575,7 @@ class ChainContextualRulesetTest(object):
# Third subtable has no pre/post context # Third subtable has no pre/post context
prefix, input_, suffix, lookups = [], [["E"]], [], [None] prefix, input_, suffix, lookups = [], [["E"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
prefix, input_, suffix, lookups = [], [["C","D"]], [], [None] prefix, input_, suffix, lookups = [], [["C", "D"]], [], [None]
sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups)) sb.rules.append(builder.ChainContextualRule(prefix, input_, suffix, lookups))
rulesets = sb.rulesets() rulesets = sb.rulesets()
@ -1513,7 +1583,7 @@ class ChainContextualRulesetTest(object):
assert rulesets[0].hasPrefixOrSuffix assert rulesets[0].hasPrefixOrSuffix
assert not rulesets[0].hasAnyGlyphClasses assert not rulesets[0].hasAnyGlyphClasses
cd = rulesets[0].format2ClassDefs() cd = rulesets[0].format2ClassDefs()
assert set(cd[0].classes()[1:]) == set([("d",),("b",),("a",)]) assert set(cd[0].classes()[1:]) == set([("d",), ("b",), ("a",)])
assert set(cd[1].classes()[1:]) == set([("c",)]) assert set(cd[1].classes()[1:]) == set([("c",)])
assert set(cd[2].classes()[1:]) == set() assert set(cd[2].classes()[1:]) == set()
@ -1526,7 +1596,7 @@ class ChainContextualRulesetTest(object):
assert rulesets[2].format2ClassDefs() assert rulesets[2].format2ClassDefs()
cd = rulesets[2].format2ClassDefs() cd = rulesets[2].format2ClassDefs()
assert set(cd[0].classes()[1:]) == set() assert set(cd[0].classes()[1:]) == set()
assert set(cd[1].classes()[1:]) == set([("C","D"), ("E",)]) assert set(cd[1].classes()[1:]) == set([("C", "D"), ("E",)])
assert set(cd[2].classes()[1:]) == set() assert set(cd[2].classes()[1:]) == set()