diff options
Diffstat (limited to 'Tests/colorLib/unbuilder_test.py')
-rw-r--r-- | Tests/colorLib/unbuilder_test.py | 122 |
1 files changed, 74 insertions, 48 deletions
diff --git a/Tests/colorLib/unbuilder_test.py b/Tests/colorLib/unbuilder_test.py index 81169e03..35489680 100644 --- a/Tests/colorLib/unbuilder_test.py +++ b/Tests/colorLib/unbuilder_test.py @@ -12,7 +12,8 @@ TEST_COLOR_GLYPHS = { "Format": int(ot.PaintFormat.PaintGlyph), "Paint": { "Format": int(ot.PaintFormat.PaintSolid), - "Color": {"PaletteIndex": 2, "Alpha": 0.5}, + "PaletteIndex": 2, + "Alpha": 0.5, }, "Glyph": "glyph00011", }, @@ -24,25 +25,32 @@ TEST_COLOR_GLYPHS = { "Extend": "repeat", "ColorStop": [ { - "StopOffset": (0.0, 0), - "Color": {"PaletteIndex": 3, "Alpha": (1.0, 0)}, + "StopOffset": 0.0, + "PaletteIndex": 3, + "Alpha": 1.0, + "VarIndexBase": 0, }, { - "StopOffset": (0.5, 0), - "Color": {"PaletteIndex": 4, "Alpha": (1.0, 0)}, + "StopOffset": 0.5, + "PaletteIndex": 4, + "Alpha": 1.0, + "VarIndexBase": 1, }, { - "StopOffset": (1.0, 0), - "Color": {"PaletteIndex": 5, "Alpha": (1.0, 0)}, + "StopOffset": 1.0, + "PaletteIndex": 5, + "Alpha": 1.0, + "VarIndexBase": 2, }, ], }, - "x0": (1, 0), - "y0": (2, 0), - "x1": (-3, 0), - "y1": (-4, 0), - "x2": (5, 0), - "y2": (6, 0), + "x0": 1, + "y0": 2, + "x1": -3, + "y1": -4, + "x2": 5, + "y2": 6, + "VarIndexBase": 0xFFFFFFFF, }, "Glyph": "glyph00012", }, @@ -57,11 +65,13 @@ TEST_COLOR_GLYPHS = { "ColorStop": [ { "StopOffset": 0, - "Color": {"PaletteIndex": 6, "Alpha": 1.0}, + "PaletteIndex": 6, + "Alpha": 1.0, }, { "StopOffset": 1.0, - "Color": {"PaletteIndex": 7, "Alpha": 0.4}, + "PaletteIndex": 7, + "Alpha": 0.4, }, ], }, @@ -73,12 +83,13 @@ TEST_COLOR_GLYPHS = { "r1": 12, }, "Transform": { - "xx": (-13.0, 0), - "yx": (14.0, 0), - "xy": (15.0, 0), - "yy": (-17.0, 0), - "dx": (18.0, 0), - "dy": (19.0, 0), + "xx": -13.0, + "yx": 14.0, + "xy": 15.0, + "yy": -17.0, + "dx": 18.0, + "dy": 19.0, + "VarIndexBase": 3, }, }, "Glyph": "glyph00013", @@ -93,21 +104,20 @@ TEST_COLOR_GLYPHS = { "Format": int(ot.PaintFormat.PaintGlyph), "Paint": { "Format": int(ot.PaintFormat.PaintSolid), - "Color": {"PaletteIndex": 2, "Alpha": 0.5}, + "PaletteIndex": 2, + "Alpha": 0.5, }, "Glyph": "glyph00011", }, - "xSkewAngle": (-11.0, 0), - "ySkewAngle": (5.0, 0), - "centerX": (253.0, 0), - "centerY": (254.0, 0), + "xSkewAngle": -11.0, + "ySkewAngle": 5.0, + "VarIndexBase": 4, }, "angle": 45.0, - "centerX": 255.0, - "centerY": 256.0, }, - "dx": (257.0, 0), - "dy": (258.0, 0), + "dx": 257.0, + "dy": 258.0, + "VarIndexBase": 5, }, ], }, @@ -143,11 +153,13 @@ TEST_COLOR_GLYPHS = { "ColorStop": [ { "StopOffset": 0.0, - "Color": {"PaletteIndex": 3, "Alpha": 1.0}, + "PaletteIndex": 3, + "Alpha": 1.0, }, { "StopOffset": 1.0, - "Color": {"PaletteIndex": 5, "Alpha": 1.0}, + "PaletteIndex": 5, + "Alpha": 1.0, }, ], }, @@ -165,7 +177,9 @@ TEST_COLOR_GLYPHS = { "Format": int(ot.PaintFormat.PaintGlyph), "Paint": { "Format": int(ot.PaintFormat.PaintVarSolid), - "Color": {"PaletteIndex": 2, "Alpha": (0.5, 0)}, + "PaletteIndex": 2, + "Alpha": 0.5, + "VarIndexBase": 6, }, "Glyph": "glyph00011", }, @@ -177,34 +191,46 @@ TEST_COLOR_GLYPHS = { "Extend": "repeat", "ColorStop": [ { - "StopOffset": (0.0, 0), - "Color": {"PaletteIndex": 3, "Alpha": (1.0, 0)}, + "StopOffset": 0.0, + "PaletteIndex": 3, + "Alpha": 1.0, + "VarIndexBase": 7, }, { - "StopOffset": (0.5, 0), - "Color": {"PaletteIndex": 4, "Alpha": (1.0, 0)}, + "StopOffset": 0.5, + "PaletteIndex": 4, + "Alpha": 1.0, + "VarIndexBase": 8, }, { - "StopOffset": (1.0, 0), - "Color": {"PaletteIndex": 5, "Alpha": (1.0, 0)}, + "StopOffset": 1.0, + "PaletteIndex": 5, + "Alpha": 1.0, + "VarIndexBase": 9, }, ], }, - "x0": (1, 0), - "y0": (2, 0), - "x1": (-3, 0), - "y1": (-4, 0), - "x2": (5, 0), - "y2": (6, 0), + "x0": 1, + "y0": 2, + "x1": -3, + "y1": -4, + "x2": 5, + "y2": 6, + "VarIndexBase": 0xFFFFFFFF, }, "Glyph": "glyph00012", }, ], - }, + } } def test_unbuildColrV1(): - layersV1, baseGlyphsV1 = buildColrV1(TEST_COLOR_GLYPHS) - colorGlyphs = unbuildColrV1(layersV1, baseGlyphsV1) + layers, baseGlyphs = buildColrV1(TEST_COLOR_GLYPHS) + colorGlyphs = unbuildColrV1(layers, baseGlyphs) assert colorGlyphs == TEST_COLOR_GLYPHS + +def test_unbuildColrV1_noLayers(): + _, baseGlyphsV1 = buildColrV1(TEST_COLOR_GLYPHS) + # Just looking to see we don't crash + unbuildColrV1(None, baseGlyphsV1)
\ No newline at end of file |