Merge pull request #2172 from fonttools/colr-sweep-gradient

COLRv1: add support for PaintSweepGradient
This commit is contained in:
Cosimo Lupo 2021-02-04 11:47:34 +00:00 committed by GitHub
commit 708cb9aef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 191 additions and 80 deletions

View File

@ -549,6 +549,23 @@ class LayerV1ListBuilder:
return ot_paint return ot_paint
def buildPaintSweepGradient(
self,
colorLine: _ColorLineInput,
centerX: _ScalarInput,
centerY: _ScalarInput,
startAngle: _ScalarInput,
endAngle: _ScalarInput,
) -> ot.Paint:
ot_paint = ot.Paint()
ot_paint.Format = int(ot.Paint.Format.PaintSweepGradient)
ot_paint.ColorLine = _to_color_line(colorLine)
ot_paint.centerX = _to_variable_int16(centerX)
ot_paint.centerY = _to_variable_int16(centerY)
ot_paint.startAngle = _to_variable_f16dot16_float(startAngle)
ot_paint.endAngle = _to_variable_f16dot16_float(endAngle)
return ot_paint
def buildPaintGlyph(self, glyph: str, paint: _PaintInput) -> ot.Paint: def buildPaintGlyph(self, glyph: str, paint: _PaintInput) -> ot.Paint:
ot_paint = ot.Paint() ot_paint = ot.Paint()
ot_paint.Format = int(ot.Paint.Format.PaintGlyph) ot_paint.Format = int(ot.Paint.Format.PaintGlyph)

View File

@ -1612,21 +1612,21 @@ otData = [
('uint16', 'StopCount', None, None, 'Number of Color stops.'), ('uint16', 'StopCount', None, None, 'Number of Color stops.'),
('ColorStop', 'ColorStop', 'StopCount', 0, 'Array of Color stops.'), ('ColorStop', 'ColorStop', 'StopCount', 0, 'Array of Color stops.'),
]), ]),
# PaintColrLayers
('PaintFormat1', [ ('PaintFormat1', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 1'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 1'),
('uint8', 'NumLayers', None, None, 'Number of offsets to Paint to read from LayerV1List.'), ('uint8', 'NumLayers', None, None, 'Number of offsets to Paint to read from LayerV1List.'),
('uint32', 'FirstLayerIndex', None, None, 'Index into LayerV1List.'), ('uint32', 'FirstLayerIndex', None, None, 'Index into LayerV1List.'),
]), ]),
# PaintSolid
('PaintFormat2', [ ('PaintFormat2', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 2'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 2'),
('ColorIndex', 'Color', None, None, 'A solid color paint.'), ('ColorIndex', 'Color', None, None, 'A solid color paint.'),
]), ]),
# PaintLinearGradient
('PaintFormat3', [ ('PaintFormat3', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 3'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 3'),
('Offset24', 'ColorLine', None, None, 'Offset (from beginning of Paint table) to ColorLine subtable.'), ('Offset24', 'ColorLine', None, None, 'Offset (from beginning of PaintLinearGradient table) to ColorLine subtable.'),
('VarInt16', 'x0', None, None, ''), ('VarInt16', 'x0', None, None, ''),
('VarInt16', 'y0', None, None, ''), ('VarInt16', 'y0', None, None, ''),
('VarInt16', 'x1', None, None, ''), ('VarInt16', 'x1', None, None, ''),
@ -1634,10 +1634,10 @@ otData = [
('VarInt16', 'x2', None, None, ''), ('VarInt16', 'x2', None, None, ''),
('VarInt16', 'y2', None, None, ''), ('VarInt16', 'y2', None, None, ''),
]), ]),
# PaintRadialGradient
('PaintFormat4', [ ('PaintFormat4', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 4'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 4'),
('Offset24', 'ColorLine', None, None, 'Offset (from beginning of Paint table) to ColorLine subtable.'), ('Offset24', 'ColorLine', None, None, 'Offset (from beginning of PaintRadialGradient table) to ColorLine subtable.'),
('VarInt16', 'x0', None, None, ''), ('VarInt16', 'x0', None, None, ''),
('VarInt16', 'y0', None, None, ''), ('VarInt16', 'y0', None, None, ''),
('VarUInt16', 'r0', None, None, ''), ('VarUInt16', 'r0', None, None, ''),
@ -1645,50 +1645,59 @@ otData = [
('VarInt16', 'y1', None, None, ''), ('VarInt16', 'y1', None, None, ''),
('VarUInt16', 'r1', None, None, ''), ('VarUInt16', 'r1', None, None, ''),
]), ]),
# PaintSweepGradient
('PaintFormat5', [ ('PaintFormat5', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 5'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 5'),
('Offset24', 'ColorLine', None, None, 'Offset (from beginning of PaintSweepGradient table) to ColorLine subtable.'),
('VarInt16', 'centerX', None, None, 'Center x coordinate.'),
('VarInt16', 'centerY', None, None, 'Center y coordinate.'),
('VarFixed', 'startAngle', None, None, 'Start of the angular range of the gradient.'),
('VarFixed', 'endAngle', None, None, 'End of the angular range of the gradient.'),
]),
# PaintGlyph
('PaintFormat6', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 6'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintGlyph table) to Paint subtable.'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintGlyph table) to Paint subtable.'),
('GlyphID', 'Glyph', None, None, 'Glyph ID for the source outline.'), ('GlyphID', 'Glyph', None, None, 'Glyph ID for the source outline.'),
]), ]),
# PaintColrGlyph
('PaintFormat6', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 6'),
('GlyphID', 'Glyph', None, None, 'Virtual glyph ID for a BaseGlyphV1List base glyph.'),
]),
('PaintFormat7', [ ('PaintFormat7', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 7'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 7'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTransformed table) to Paint subtable.'), ('GlyphID', 'Glyph', None, None, 'Virtual glyph ID for a BaseGlyphV1List base glyph.'),
('Affine2x3', 'Transform', None, None, 'Offset (from beginning of PaintTrasformed table) to Affine2x3 subtable.'),
]), ]),
# PaintTransform
('PaintFormat8', [ ('PaintFormat8', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 8'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 8'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTransform table) to Paint subtable.'),
('Affine2x3', 'Transform', None, None, '2x3 matrix for 2D affine transformations.'),
]),
# PaintTranslate
('PaintFormat9', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 9'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTranslate table) to Paint subtable.'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTranslate table) to Paint subtable.'),
('VarFixed', 'dx', None, None, 'Translation in x direction.'), ('VarFixed', 'dx', None, None, 'Translation in x direction.'),
('VarFixed', 'dy', None, None, 'Translation in y direction.'), ('VarFixed', 'dy', None, None, 'Translation in y direction.'),
]), ]),
# PaintRotate
('PaintFormat9', [ ('PaintFormat10', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 9'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 10'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintRotate table) to Paint subtable.'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintRotate table) to Paint subtable.'),
('VarFixed', 'angle', None, None, ''), ('VarFixed', 'angle', None, None, ''),
('VarFixed', 'centerX', None, None, ''), ('VarFixed', 'centerX', None, None, ''),
('VarFixed', 'centerY', None, None, ''), ('VarFixed', 'centerY', None, None, ''),
]), ]),
# PaintSkew
('PaintFormat10', [ ('PaintFormat11', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 10'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 11'),
('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintSkew table) to Paint subtable.'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintSkew table) to Paint subtable.'),
('VarFixed', 'xSkewAngle', None, None, ''), ('VarFixed', 'xSkewAngle', None, None, ''),
('VarFixed', 'ySkewAngle', None, None, ''), ('VarFixed', 'ySkewAngle', None, None, ''),
('VarFixed', 'centerX', None, None, ''), ('VarFixed', 'centerX', None, None, ''),
('VarFixed', 'centerY', None, None, ''), ('VarFixed', 'centerY', None, None, ''),
]), ]),
# PaintComposite
('PaintFormat11', [ ('PaintFormat12', [
('uint8', 'PaintFormat', None, None, 'Format identifier-format = 11'), ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 12'),
('LOffset24To(Paint)', 'SourcePaint', None, None, 'Offset (from beginning of PaintComposite table) to source Paint subtable.'), ('LOffset24To(Paint)', 'SourcePaint', None, None, 'Offset (from beginning of PaintComposite table) to source Paint subtable.'),
('CompositeMode', 'CompositeMode', None, None, 'A CompositeMode enumeration value.'), ('CompositeMode', 'CompositeMode', None, None, 'A CompositeMode enumeration value.'),
('LOffset24To(Paint)', 'BackdropPaint', None, None, 'Offset (from beginning of PaintComposite table) to backdrop Paint subtable.'), ('LOffset24To(Paint)', 'BackdropPaint', None, None, 'Offset (from beginning of PaintComposite table) to backdrop Paint subtable.'),

View File

@ -1331,13 +1331,14 @@ class Paint(getFormatSwitchingBaseTableClass("uint8")):
PaintSolid = 2 PaintSolid = 2
PaintLinearGradient = 3 PaintLinearGradient = 3
PaintRadialGradient = 4 PaintRadialGradient = 4
PaintGlyph = 5 PaintSweepGradient = 5
PaintColrGlyph = 6 PaintGlyph = 6
PaintTransform = 7 PaintColrGlyph = 7
PaintTranslate = 8 PaintTransform = 8
PaintRotate = 9 PaintTranslate = 9
PaintSkew = 10 PaintRotate = 10
PaintComposite = 11 PaintSkew = 11
PaintComposite = 12
def getFormatName(self): def getFormatName(self):
try: try:

View File

@ -385,6 +385,29 @@ def test_buildPaintRadialGradient():
assert gradient.ColorLine.ColorStop == color_stops assert gradient.ColorLine.ColorStop == color_stops
def test_buildPaintSweepGradient():
layerBuilder = LayerV1ListBuilder()
paint = layerBuilder.buildPaintSweepGradient(
colorLine=builder.buildColorLine(
stops=[
builder.buildColorStop(0.0, 0),
builder.buildColorStop(0.5, 1),
builder.buildColorStop(1.0, 2, alpha=0.8),
],
),
centerX=127,
centerY=129,
startAngle=15,
endAngle=42,
)
assert paint.Format == ot.Paint.Format.PaintSweepGradient
assert paint.centerX.value == 127
assert paint.centerY.value == 129
assert paint.startAngle.value == 15
assert paint.endAngle.value == 42
def test_buildPaintGlyph_Solid(): def test_buildPaintGlyph_Solid():
layerBuilder = LayerV1ListBuilder() layerBuilder = LayerV1ListBuilder()
layer = layerBuilder.buildPaintGlyph("a", 2) layer = layerBuilder.buildPaintGlyph("a", 2)
@ -545,10 +568,10 @@ def test_buildPaintComposite():
composite = layerBuilder.buildPaintComposite( composite = layerBuilder.buildPaintComposite(
mode=ot.CompositeMode.SRC_OVER, mode=ot.CompositeMode.SRC_OVER,
source={ source={
"format": 11, "format": 12,
"mode": "src_over", "mode": "src_over",
"source": {"format": 5, "glyph": "c", "paint": 2}, "source": {"format": 6, "glyph": "c", "paint": 2},
"backdrop": {"format": 5, "glyph": "b", "paint": 1}, "backdrop": {"format": 6, "glyph": "b", "paint": 1},
}, },
backdrop=layerBuilder.buildPaintGlyph( backdrop=layerBuilder.buildPaintGlyph(
"a", layerBuilder.buildPaintSolid(paletteIndex=0, alpha=1.0) "a", layerBuilder.buildPaintSolid(paletteIndex=0, alpha=1.0)
@ -679,7 +702,7 @@ def test_buildColrV1_more_than_255_paints():
colorGlyphs = { colorGlyphs = {
"a": [ "a": [
{ {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": 0, "paint": 0,
"glyph": name, "glyph": name,
} }
@ -775,18 +798,18 @@ def assertNoV0Content(colr):
def test_build_layerv1list_empty(): def test_build_layerv1list_empty():
# Nobody uses PaintColrLayers (format 8), no layerlist # Nobody uses PaintColrLayers (format 1), no layerlist
colr = builder.buildCOLR( colr = builder.buildCOLR(
{ {
"a": { "a": {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8}, "paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8},
"glyph": "b", "glyph": "b",
}, },
# A list of 1 shouldn't become a PaintColrLayers # A list of 1 shouldn't become a PaintColrLayers
"b": [ "b": [
{ {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": { "paint": {
"format": 3, "format": 3,
"colorLine": { "colorLine": {
@ -832,17 +855,17 @@ def test_build_layerv1list_simple():
# All layers use the same solid paint # All layers use the same solid paint
solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8} solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8}
backdrop = { backdrop = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "back", "glyph": "back",
} }
a_foreground = { a_foreground = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "a_fore", "glyph": "a_fore",
} }
b_foreground = { b_foreground = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "b_fore", "glyph": "b_fore",
} }
@ -882,33 +905,33 @@ def test_build_layerv1list_with_sharing():
solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8} solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8}
backdrop = [ backdrop = [
{ {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "back1", "glyph": "back1",
}, },
{ {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "back2", "glyph": "back2",
}, },
] ]
a_foreground = { a_foreground = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "a_fore", "glyph": "a_fore",
} }
b_background = { b_background = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "b_back", "glyph": "b_back",
} }
b_foreground = { b_foreground = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "b_fore", "glyph": "b_fore",
} }
c_background = { c_background = {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": solid_paint, "paint": solid_paint,
"glyph": "c_back", "glyph": "c_back",
} }
@ -951,7 +974,7 @@ def test_build_layerv1list_with_sharing():
def test_build_layerv1list_with_overlaps(): def test_build_layerv1list_with_overlaps():
paints = [ paints = [
{ {
"format": 5, # PaintGlyph "format": 6, # PaintGlyph
"paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8}, "paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8},
"glyph": c, "glyph": c,
} }

View File

@ -106,7 +106,7 @@ COLR_V1_SAMPLE = (
(b"\x00\x00\x00 ", "Offset to LayerRecordArray from beginning of table (32)"), (b"\x00\x00\x00 ", "Offset to LayerRecordArray from beginning of table (32)"),
(b"\x00\x03", "LayerRecordCount (3)"), (b"\x00\x03", "LayerRecordCount (3)"),
(b"\x00\x00\x00,", "Offset to BaseGlyphV1List from beginning of table (44)"), (b"\x00\x00\x00,", "Offset to BaseGlyphV1List from beginning of table (44)"),
(b"\x00\x00\x00\x81", "Offset to LayerV1List from beginning of table (129)"), (b"\x00\x00\x00\xcc", "Offset to LayerV1List from beginning of table (204)"),
(b"\x00\x00\x00\x00", "Offset to VarStore (NULL)"), (b"\x00\x00\x00\x00", "Offset to VarStore (NULL)"),
(b"\x00\x06", "BaseGlyphRecord[0].BaseGlyph (6)"), (b"\x00\x06", "BaseGlyphRecord[0].BaseGlyph (6)"),
(b"\x00\x00", "BaseGlyphRecord[0].FirstLayerIndex (0)"), (b"\x00\x00", "BaseGlyphRecord[0].FirstLayerIndex (0)"),
@ -117,25 +117,33 @@ COLR_V1_SAMPLE = (
(b"\x00\x01", "LayerRecord[1].PaletteIndex (1)"), (b"\x00\x01", "LayerRecord[1].PaletteIndex (1)"),
(b"\x00\t", "LayerRecord[2].LayerGlyph (9)"), (b"\x00\t", "LayerRecord[2].LayerGlyph (9)"),
(b"\x00\x02", "LayerRecord[2].PaletteIndex (2)"), (b"\x00\x02", "LayerRecord[2].PaletteIndex (2)"),
(b"\x00\x00\x00\x02", "BaseGlyphV1List.BaseGlyphCount (2)"), # BaseGlyphV1List
(b"\x00\x00\x00\x03", "BaseGlyphV1List.BaseGlyphCount (3)"),
(b"\x00\n", "BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph (10)"), (b"\x00\n", "BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph (10)"),
(
b"\x00\x00\x00\x10",
"Offset to Paint table from beginning of BaseGlyphV1List (16)",
),
(b"\x00\x0e", "BaseGlyphV1List.BaseGlyphV1Record[1].BaseGlyph (14)"),
( (
b"\x00\x00\x00\x16", b"\x00\x00\x00\x16",
"Offset to Paint table from beginning of BaseGlyphV1List (22)", "Offset to Paint table from beginning of BaseGlyphV1List (22)",
), ),
(b"\x00\x0e", "BaseGlyphV1List.BaseGlyphV1Record[1].BaseGlyph (14)"),
(
b"\x00\x00\x00\x1c",
"Offset to Paint table from beginning of BaseGlyphV1List (28)",
),
(b"\x00\x0f", "BaseGlyphV1List.BaseGlyphV1Record[2].BaseGlyph (15)"),
(
b"\x00\x00\x00\x5b",
"Offset to Paint table from beginning of BaseGlyphV1List (91)",
),
# BaseGlyphV1Record[0]
(b"\x01", "BaseGlyphV1Record[0].Paint.Format (1)"), (b"\x01", "BaseGlyphV1Record[0].Paint.Format (1)"),
(b"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"), (b"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"),
(b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"), (b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"),
(b"\x0B", "BaseGlyphV1Record[1].Paint.Format (11)"), # BaseGlyphV1Record[1]
(b"\x0C", "BaseGlyphV1Record[1].Paint.Format (12)"),
(b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"), (b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"),
(b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"), (b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"),
(b"\x00\x00\x08", "Offset to BackdropPaint from beginning of PaintComposite (8)"), (b"\x00\x00\x08", "Offset to BackdropPaint from beginning of PaintComposite (8)"),
(b"\x07", "BaseGlyphV1Record[1].Paint.BackdropPaint.Format (7)"), (b"\x08", "BaseGlyphV1Record[1].Paint.BackdropPaint.Format (8)"),
(b"\x00\x00\x34", "Offset to Paint from beginning of PaintTransform (52)"), (b"\x00\x00\x34", "Offset to Paint from beginning of PaintTransform (52)"),
(b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.xx.value (1.0)"), (b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.xx.value (1.0)"),
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.xy.value (0.0)"), (b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.xy.value (0.0)"),
@ -143,8 +151,31 @@ COLR_V1_SAMPLE = (
(b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.yy.value (1.0)"), (b"\x00\x01\x00\x00\x00\x00\x00\x00", "Affine2x3.yy.value (1.0)"),
(b"\x01\x2c\x00\x00\x00\x00\x00\x00", "Affine2x3.dx.value (300.0)"), (b"\x01\x2c\x00\x00\x00\x00\x00\x00", "Affine2x3.dx.value (300.0)"),
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"), (b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"),
(b"\x06", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (6)"), (b"\x07", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (7)"),
(b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"), (b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"),
# BaseGlyphV1Record[2]
(b"\x06", "BaseGlyphV1Record[2].Paint.Format (6)"),
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
(b"\x00\x0b", "BaseGlyphV1Record[2].Paint.Glyph (11)"),
(b"\x05", "BaseGlyphV1Record[2].Paint.Paint.Format (5)"),
(b"\x00\x00 ", "Offset to ColorLine from beginning of PaintSweepGradient (32)"),
(b"\x01\x03\x00\x00\x00\x00", "centerX.value (259)"),
(b"\x01\x2c\x00\x00\x00\x00", "centerY.value (300)"),
(b"\x00\x2d\x00\x00\x00\x00\x00\x00", "startAngle (45.0)"),
(b"\x00\x87\x00\x00\x00\x00\x00\x00", "endAngle (135.0)"),
(b"\x00", "ColorLine.Extend (0; pad)"),
(b"\x00\x02", "ColorLine.StopCount (2)"),
(b"\x00\x00", "ColorLine.ColorStop[0].StopOffset.value (0.0)"),
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[0].StopOffset.varIdx (0)"),
(b"\x00\x03", "ColorLine.ColorStop[0].Color.PaletteIndex (3)"),
(b"@\x00", "ColorLine.ColorStop[0].Color.Alpha.value (1.0)"),
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[0].Color.Alpha.varIdx (0)"),
(b"@\x00", "ColorLine.ColorStop[1].StopOffset.value (1.0)"),
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[1].StopOffset.varIdx (0)"),
(b"\x00\x05", "ColorLine.ColorStop[1].Color.PaletteIndex (5)"),
(b"@\x00", "ColorLine.ColorStop[1].Color.Alpha.value (1.0)"),
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.varIdx (0)"),
# LayerV1List
(b"\x00\x00\x00\x04", "LayerV1List.LayerCount (4)"), (b"\x00\x00\x00\x04", "LayerV1List.LayerCount (4)"),
( (
b"\x00\x00\x00\x14", b"\x00\x00\x00\x14",
@ -163,11 +194,11 @@ COLR_V1_SAMPLE = (
"Fourth Offset to Paint table from beginning of LayerV1List (246)", "Fourth Offset to Paint table from beginning of LayerV1List (246)",
), ),
# PaintGlyph glyph00011 # PaintGlyph glyph00011
(b"\x05", "LayerV1List.Paint[0].Format (5)"), (b"\x06", "LayerV1List.Paint[0].Format (6)"),
(b"\x00\x01<", "Offset24 to Paint subtable from beginning of PaintGlyph (316)"), (b"\x00\x01<", "Offset24 to Paint subtable from beginning of PaintGlyph (316)"),
(b"\x00\x0b", "LayerV1List.Paint[0].Glyph (glyph00011)"), (b"\x00\x0b", "LayerV1List.Paint[0].Glyph (glyph00011)"),
# PaintGlyph glyph00012 # PaintGlyph glyph00012
(b"\x05", "LayerV1List.Paint[1].Format (5)"), (b"\x06", "LayerV1List.Paint[1].Format (6)"),
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"), (b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
(b"\x00\x0c", "LayerV1List.Paint[1].Glyph (glyph00012)"), (b"\x00\x0c", "LayerV1List.Paint[1].Glyph (glyph00012)"),
(b"\x03", "LayerV1List.Paint[1].Paint.Format (3)"), (b"\x03", "LayerV1List.Paint[1].Paint.Format (3)"),
@ -202,10 +233,10 @@ COLR_V1_SAMPLE = (
(b"@\x00", "ColorLine.ColorStop[2].Color.Alpha.value (1.0)"), (b"@\x00", "ColorLine.ColorStop[2].Color.Alpha.value (1.0)"),
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[2].Color.Alpha.varIdx (0)"), (b"\x00\x00\x00\x00", "ColorLine.ColorStop[2].Color.Alpha.varIdx (0)"),
# PaintGlyph glyph00013 # PaintGlyph glyph00013
(b"\x05", "LayerV1List.Paint[2].Format (5)"), (b"\x06", "LayerV1List.Paint[2].Format (6)"),
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"), (b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
(b"\x00\r", "LayerV1List.Paint[2].Glyph (13)"), (b"\x00\r", "LayerV1List.Paint[2].Glyph (13)"),
(b"\x07", "LayerV1List.Paint[2].Paint.Format (5)"), (b"\x08", "LayerV1List.Paint[2].Paint.Format (8)"),
(b"\x00\x00\x34", "Offset to Paint subtable from beginning of PaintTransform (52)"), (b"\x00\x00\x34", "Offset to Paint subtable from beginning of PaintTransform (52)"),
(b"\xff\xf3\x00\x00\x00\x00\x00\x00", "Affine2x3.xx.value (-13)"), (b"\xff\xf3\x00\x00\x00\x00\x00\x00", "Affine2x3.xx.value (-13)"),
(b"\x00\x0e\x00\x00\x00\x00\x00\x00", "Affine2x3.xy.value (14)"), (b"\x00\x0e\x00\x00\x00\x00\x00\x00", "Affine2x3.xy.value (14)"),
@ -230,25 +261,25 @@ COLR_V1_SAMPLE = (
(b"\x00\x07", "ColorLine.ColorStop[1].Color.PaletteIndex (7)"), (b"\x00\x07", "ColorLine.ColorStop[1].Color.PaletteIndex (7)"),
(b"\x19\x9a\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.value (0.4)"), (b"\x19\x9a\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.value (0.4)"),
# PaintTranslate # PaintTranslate
(b"\x08", "LayerV1List.Paint[3].Format (8)"), (b"\x09", "LayerV1List.Paint[3].Format (9)"),
(b"\x00\x00\x14", "Offset to Paint subtable from beginning of PaintTranslate (20)"), (b"\x00\x00\x14", "Offset to Paint subtable from beginning of PaintTranslate (20)"),
(b"\x01\x01\x00\x00\x00\x00\x00\x00", "dx.value (257)"), (b"\x01\x01\x00\x00\x00\x00\x00\x00", "dx.value (257)"),
(b"\x01\x02\x00\x00\x00\x00\x00\x00", "dy.value (258)"), (b"\x01\x02\x00\x00\x00\x00\x00\x00", "dy.value (258)"),
# PaintRotate # PaintRotate
(b"\x09", "LayerV1List.Paint[3].Paint.Format (9)"), (b"\x0a", "LayerV1List.Paint[3].Paint.Format (10)"),
(b"\x00\x00\x1c", "Offset to Paint subtable from beginning of PaintRotate (28)"), (b"\x00\x00\x1c", "Offset to Paint subtable from beginning of PaintRotate (28)"),
(b"\x00\x2d\x00\x00\x00\x00\x00\x00", "angle.value (45)"), (b"\x00\x2d\x00\x00\x00\x00\x00\x00", "angle.value (45)"),
(b"\x00\xff\x00\x00\x00\x00\x00\x00", "centerX.value (255)"), (b"\x00\xff\x00\x00\x00\x00\x00\x00", "centerX.value (255)"),
(b"\x01\x00\x00\x00\x00\x00\x00\x00", "centerY.value (256)"), (b"\x01\x00\x00\x00\x00\x00\x00\x00", "centerY.value (256)"),
# PaintSkew # PaintSkew
(b"\x0a", "LayerV1List.Paint[3].Paint.Paint.Format (10)"), (b"\x0b", "LayerV1List.Paint[3].Paint.Paint.Format (11)"),
(b"\x00\x00\x24", "Offset to Paint subtable from beginning of PaintSkew (36)"), (b"\x00\x00\x24", "Offset to Paint subtable from beginning of PaintSkew (36)"),
(b"\xff\xf5\x00\x00\x00\x00\x00\x00", "xSkewAngle (-11)"), (b"\xff\xf5\x00\x00\x00\x00\x00\x00", "xSkewAngle (-11)"),
(b"\x00\x05\x00\x00\x00\x00\x00\x00", "ySkewAngle (5)"), (b"\x00\x05\x00\x00\x00\x00\x00\x00", "ySkewAngle (5)"),
(b"\x00\xfd\x00\x00\x00\x00\x00\x00", "centerX.value (253)"), (b"\x00\xfd\x00\x00\x00\x00\x00\x00", "centerX.value (253)"),
(b"\x00\xfe\x00\x00\x00\x00\x00\x00", "centerY.value (254)"), (b"\x00\xfe\x00\x00\x00\x00\x00\x00", "centerY.value (254)"),
# PaintGlyph # PaintGlyph
(b"\x05", "LayerV1List.Paint[2].Format (5)"), (b"\x06", "LayerV1List.Paint[2].Format (6)"),
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"), (b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
(b"\x00\x0b", "LayerV1List.Paint[2].Glyph (11)"), (b"\x00\x0b", "LayerV1List.Paint[2].Glyph (11)"),
# PaintSolid # PaintSolid
@ -286,7 +317,7 @@ COLR_V1_XML = [
"</LayerRecordArray>", "</LayerRecordArray>",
"<!-- LayerRecordCount=3 -->", "<!-- LayerRecordCount=3 -->",
"<BaseGlyphV1List>", "<BaseGlyphV1List>",
" <!-- BaseGlyphCount=2 -->", " <!-- BaseGlyphCount=3 -->",
' <BaseGlyphV1Record index="0">', ' <BaseGlyphV1Record index="0">',
' <BaseGlyph value="glyph00010"/>', ' <BaseGlyph value="glyph00010"/>',
' <Paint Format="1"><!-- PaintColrLayers -->', ' <Paint Format="1"><!-- PaintColrLayers -->',
@ -296,13 +327,13 @@ COLR_V1_XML = [
" </BaseGlyphV1Record>", " </BaseGlyphV1Record>",
' <BaseGlyphV1Record index="1">', ' <BaseGlyphV1Record index="1">',
' <BaseGlyph value="glyph00014"/>', ' <BaseGlyph value="glyph00014"/>',
' <Paint Format="11"><!-- PaintComposite -->', ' <Paint Format="12"><!-- PaintComposite -->',
' <SourcePaint Format="6"><!-- PaintColrGlyph -->', ' <SourcePaint Format="7"><!-- PaintColrGlyph -->',
' <Glyph value="glyph00010"/>', ' <Glyph value="glyph00010"/>',
" </SourcePaint>", " </SourcePaint>",
' <CompositeMode value="src_over"/>', ' <CompositeMode value="src_over"/>',
' <BackdropPaint Format="7"><!-- PaintTransform -->', ' <BackdropPaint Format="8"><!-- PaintTransform -->',
' <Paint Format="6"><!-- PaintColrGlyph -->', ' <Paint Format="7"><!-- PaintColrGlyph -->',
' <Glyph value="glyph00010"/>', ' <Glyph value="glyph00010"/>',
" </Paint>", " </Paint>",
" <Transform>", " <Transform>",
@ -316,10 +347,40 @@ COLR_V1_XML = [
" </BackdropPaint>", " </BackdropPaint>",
" </Paint>", " </Paint>",
" </BaseGlyphV1Record>", " </BaseGlyphV1Record>",
' <BaseGlyphV1Record index="2">',
' <BaseGlyph value="glyph00015"/>',
' <Paint Format="6"><!-- PaintGlyph -->',
' <Paint Format="5"><!-- PaintSweepGradient -->',
" <ColorLine>",
' <Extend value="pad"/>',
" <!-- StopCount=2 -->",
' <ColorStop index="0">',
' <StopOffset value="0.0"/>',
" <Color>",
' <PaletteIndex value="3"/>',
' <Alpha value="1.0"/>',
" </Color>",
" </ColorStop>",
' <ColorStop index="1">',
' <StopOffset value="1.0"/>',
" <Color>",
' <PaletteIndex value="5"/>',
' <Alpha value="1.0"/>',
" </Color>",
" </ColorStop>",
" </ColorLine>",
' <centerX value="259"/>',
' <centerY value="300"/>',
' <startAngle value="45.0"/>',
' <endAngle value="135.0"/>',
" </Paint>",
' <Glyph value="glyph00011"/>',
" </Paint>",
" </BaseGlyphV1Record>",
"</BaseGlyphV1List>", "</BaseGlyphV1List>",
"<LayerV1List>", "<LayerV1List>",
" <!-- LayerCount=4 -->", " <!-- LayerCount=4 -->",
' <Paint index="0" Format="5"><!-- PaintGlyph -->', ' <Paint index="0" Format="6"><!-- PaintGlyph -->',
' <Paint Format="2"><!-- PaintSolid -->', ' <Paint Format="2"><!-- PaintSolid -->',
" <Color>", " <Color>",
' <PaletteIndex value="2"/>', ' <PaletteIndex value="2"/>',
@ -328,7 +389,7 @@ COLR_V1_XML = [
" </Paint>", " </Paint>",
' <Glyph value="glyph00011"/>', ' <Glyph value="glyph00011"/>',
" </Paint>", " </Paint>",
' <Paint index="1" Format="5"><!-- PaintGlyph -->', ' <Paint index="1" Format="6"><!-- PaintGlyph -->',
' <Paint Format="3"><!-- PaintLinearGradient -->', ' <Paint Format="3"><!-- PaintLinearGradient -->',
" <ColorLine>", " <ColorLine>",
' <Extend value="repeat"/>', ' <Extend value="repeat"/>',
@ -364,8 +425,8 @@ COLR_V1_XML = [
" </Paint>", " </Paint>",
' <Glyph value="glyph00012"/>', ' <Glyph value="glyph00012"/>',
" </Paint>", " </Paint>",
' <Paint index="2" Format="5"><!-- PaintGlyph -->', ' <Paint index="2" Format="6"><!-- PaintGlyph -->',
' <Paint Format="7"><!-- PaintTransform -->', ' <Paint Format="8"><!-- PaintTransform -->',
' <Paint Format="4"><!-- PaintRadialGradient -->', ' <Paint Format="4"><!-- PaintRadialGradient -->',
" <ColorLine>", " <ColorLine>",
' <Extend value="pad"/>', ' <Extend value="pad"/>',
@ -403,10 +464,10 @@ COLR_V1_XML = [
" </Paint>", " </Paint>",
' <Glyph value="glyph00013"/>', ' <Glyph value="glyph00013"/>',
" </Paint>", " </Paint>",
' <Paint index="3" Format="8"><!-- PaintTranslate -->', ' <Paint index="3" Format="9"><!-- PaintTranslate -->',
' <Paint Format="9"><!-- PaintRotate -->', ' <Paint Format="10"><!-- PaintRotate -->',
' <Paint Format="10"><!-- PaintSkew -->', ' <Paint Format="11"><!-- PaintSkew -->',
' <Paint Format="5"><!-- PaintGlyph -->', ' <Paint Format="6"><!-- PaintGlyph -->',
' <Paint Format="2"><!-- PaintSolid -->', ' <Paint Format="2"><!-- PaintSolid -->',
" <Color>", " <Color>",
' <PaletteIndex value="2"/>', ' <PaletteIndex value="2"/>',