colorLib_test: check that duplicate base glyphs share share the same PaintColrLayers
this test currently fails; currently the second, third, etc. base glyphs with the same layers gets a unique PaintColrLayers with NumLayers:1 that in turn contains the shared PaintColrLayers. They should instead all share the same PaintColrLayers. Fix in the next commit
This commit is contained in:
parent
eded208670
commit
e68a5a173c
@ -1,3 +1,4 @@
|
|||||||
|
from copy import deepcopy
|
||||||
from fontTools.ttLib import newTable
|
from fontTools.ttLib import newTable
|
||||||
from fontTools.ttLib.tables import otTables as ot
|
from fontTools.ttLib.tables import otTables as ot
|
||||||
from fontTools.colorLib import builder
|
from fontTools.colorLib import builder
|
||||||
@ -1692,6 +1693,33 @@ class BuildCOLRTest(object):
|
|||||||
assert clipBoxes["a"].Format == 2
|
assert clipBoxes["a"].Format == 2
|
||||||
assert clipBoxes["c"].Format == 1
|
assert clipBoxes["c"].Format == 1
|
||||||
|
|
||||||
|
def test_duplicate_base_glyphs(self):
|
||||||
|
# If > 1 base glyphs refer to equivalent list of layers we expect them to share
|
||||||
|
# the same PaintColrLayers.
|
||||||
|
layers = {
|
||||||
|
"Format": ot.PaintFormat.PaintColrLayers,
|
||||||
|
"Layers": [
|
||||||
|
(ot.PaintFormat.PaintGlyph, (ot.PaintFormat.PaintSolid, 0), "d"),
|
||||||
|
(ot.PaintFormat.PaintGlyph, (ot.PaintFormat.PaintSolid, 1), "e"),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
# I copy the layers to ensure equality is by content, not by identity
|
||||||
|
colr = builder.buildCOLR(
|
||||||
|
{"a": layers, "b": deepcopy(layers), "c": deepcopy(layers)}
|
||||||
|
).table
|
||||||
|
|
||||||
|
baseGlyphs = colr.BaseGlyphList.BaseGlyphPaintRecord
|
||||||
|
assert len(baseGlyphs) == 3
|
||||||
|
|
||||||
|
assert baseGlyphs[0].BaseGlyph == "a"
|
||||||
|
assert baseGlyphs[1].BaseGlyph == "b"
|
||||||
|
assert baseGlyphs[2].BaseGlyph == "c"
|
||||||
|
|
||||||
|
expected = {"Format": 1, "FirstLayerIndex": 0, "NumLayers": 2}
|
||||||
|
assert baseGlyphs[0].Paint.__dict__ == expected
|
||||||
|
assert baseGlyphs[1].Paint.__dict__ == expected
|
||||||
|
assert baseGlyphs[2].Paint.__dict__ == expected
|
||||||
|
|
||||||
|
|
||||||
class TrickyRadialGradientTest:
|
class TrickyRadialGradientTest:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user