From 93c23eaaf7c2ca83d6a6e69a6cd43e89c9204b7f Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 3 Feb 2021 18:21:03 +0000 Subject: [PATCH 1/3] COLRv1: define new PaintSweepGradient, amend tests with new format numbers --- Lib/fontTools/colorLib/builder.py | 17 ++++++++++ Lib/fontTools/ttLib/tables/otData.py | 31 +++++++++++------ Lib/fontTools/ttLib/tables/otTables.py | 15 +++++---- Tests/colorLib/builder_test.py | 34 +++++++++---------- Tests/ttLib/tables/C_O_L_R_test.py | 46 +++++++++++++------------- 5 files changed, 85 insertions(+), 58 deletions(-) diff --git a/Lib/fontTools/colorLib/builder.py b/Lib/fontTools/colorLib/builder.py index 998ab60d1..5a52edbc9 100644 --- a/Lib/fontTools/colorLib/builder.py +++ b/Lib/fontTools/colorLib/builder.py @@ -549,6 +549,23 @@ class LayerV1ListBuilder: 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: ot_paint = ot.Paint() ot_paint.Format = int(ot.Paint.Format.PaintGlyph) diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py index a6f9619e6..59ff40f65 100755 --- a/Lib/fontTools/ttLib/tables/otData.py +++ b/Lib/fontTools/ttLib/tables/otData.py @@ -1648,38 +1648,47 @@ otData = [ ('PaintFormat5', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 5'), - ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintGlyph table) to Paint subtable.'), - ('GlyphID', 'Glyph', None, None, 'Glyph ID for the source outline.'), + ('Offset24', 'ColorLine', None, None, 'Offset (from beginning of PaintSweep 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.'), ]), ('PaintFormat6', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 6'), - ('GlyphID', 'Glyph', None, None, 'Virtual glyph ID for a BaseGlyphV1List base glyph.'), + ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintGlyph table) to Paint subtable.'), + ('GlyphID', 'Glyph', None, None, 'Glyph ID for the source outline.'), ]), ('PaintFormat7', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 7'), - ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTransformed table) to Paint subtable.'), - ('Affine2x3', 'Transform', None, None, 'Offset (from beginning of PaintTrasformed table) to Affine2x3 subtable.'), + ('GlyphID', 'Glyph', None, None, 'Virtual glyph ID for a BaseGlyphV1List base glyph.'), ]), ('PaintFormat8', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 8'), + ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTransformed table) to Paint subtable.'), + ('Affine2x3', 'Transform', None, None, 'Offset (from beginning of PaintTrasformed table) to Affine2x3 subtable.'), + ]), + + ('PaintFormat9', [ + ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 9'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTranslate table) to Paint subtable.'), ('VarFixed', 'dx', None, None, 'Translation in x direction.'), ('VarFixed', 'dy', None, None, 'Translation in y direction.'), ]), - ('PaintFormat9', [ - ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 9'), + ('PaintFormat10', [ + ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 10'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintRotate table) to Paint subtable.'), ('VarFixed', 'angle', None, None, ''), ('VarFixed', 'centerX', None, None, ''), ('VarFixed', 'centerY', None, None, ''), ]), - ('PaintFormat10', [ - ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 10'), + ('PaintFormat11', [ + ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 11'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintSkew table) to Paint subtable.'), ('VarFixed', 'xSkewAngle', None, None, ''), ('VarFixed', 'ySkewAngle', None, None, ''), @@ -1687,8 +1696,8 @@ otData = [ ('VarFixed', 'centerY', None, None, ''), ]), - ('PaintFormat11', [ - ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 11'), + ('PaintFormat12', [ + ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 12'), ('LOffset24To(Paint)', 'SourcePaint', None, None, 'Offset (from beginning of PaintComposite table) to source Paint subtable.'), ('CompositeMode', 'CompositeMode', None, None, 'A CompositeMode enumeration value.'), ('LOffset24To(Paint)', 'BackdropPaint', None, None, 'Offset (from beginning of PaintComposite table) to backdrop Paint subtable.'), diff --git a/Lib/fontTools/ttLib/tables/otTables.py b/Lib/fontTools/ttLib/tables/otTables.py index 7f42921d7..ec5c5db4a 100644 --- a/Lib/fontTools/ttLib/tables/otTables.py +++ b/Lib/fontTools/ttLib/tables/otTables.py @@ -1331,13 +1331,14 @@ class Paint(getFormatSwitchingBaseTableClass("uint8")): PaintSolid = 2 PaintLinearGradient = 3 PaintRadialGradient = 4 - PaintGlyph = 5 - PaintColrGlyph = 6 - PaintTransform = 7 - PaintTranslate = 8 - PaintRotate = 9 - PaintSkew = 10 - PaintComposite = 11 + PaintSweepGradient = 5 + PaintGlyph = 6 + PaintColrGlyph = 7 + PaintTransform = 8 + PaintTranslate = 9 + PaintRotate = 10 + PaintSkew = 11 + PaintComposite = 12 def getFormatName(self): try: diff --git a/Tests/colorLib/builder_test.py b/Tests/colorLib/builder_test.py index 43ec96a41..fae00a419 100644 --- a/Tests/colorLib/builder_test.py +++ b/Tests/colorLib/builder_test.py @@ -545,10 +545,10 @@ def test_buildPaintComposite(): composite = layerBuilder.buildPaintComposite( mode=ot.CompositeMode.SRC_OVER, source={ - "format": 11, + "format": 12, "mode": "src_over", - "source": {"format": 5, "glyph": "c", "paint": 2}, - "backdrop": {"format": 5, "glyph": "b", "paint": 1}, + "source": {"format": 6, "glyph": "c", "paint": 2}, + "backdrop": {"format": 6, "glyph": "b", "paint": 1}, }, backdrop=layerBuilder.buildPaintGlyph( "a", layerBuilder.buildPaintSolid(paletteIndex=0, alpha=1.0) @@ -679,7 +679,7 @@ def test_buildColrV1_more_than_255_paints(): colorGlyphs = { "a": [ { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": 0, "glyph": name, } @@ -775,18 +775,18 @@ def assertNoV0Content(colr): def test_build_layerv1list_empty(): - # Nobody uses PaintColrLayers (format 8), no layerlist + # Nobody uses PaintColrLayers (format 1), no layerlist colr = builder.buildCOLR( { "a": { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8}, "glyph": "b", }, # A list of 1 shouldn't become a PaintColrLayers "b": [ { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": { "format": 3, "colorLine": { @@ -832,17 +832,17 @@ def test_build_layerv1list_simple(): # All layers use the same solid paint solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8} backdrop = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "back", } a_foreground = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "a_fore", } b_foreground = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "b_fore", } @@ -882,33 +882,33 @@ def test_build_layerv1list_with_sharing(): solid_paint = {"format": 2, "paletteIndex": 2, "alpha": 0.8} backdrop = [ { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "back1", }, { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "back2", }, ] a_foreground = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "a_fore", } b_background = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "b_back", } b_foreground = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "b_fore", } c_background = { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": solid_paint, "glyph": "c_back", } @@ -951,7 +951,7 @@ def test_build_layerv1list_with_sharing(): def test_build_layerv1list_with_overlaps(): paints = [ { - "format": 5, # PaintGlyph + "format": 6, # PaintGlyph "paint": {"format": 2, "paletteIndex": 2, "alpha": 0.8}, "glyph": c, } diff --git a/Tests/ttLib/tables/C_O_L_R_test.py b/Tests/ttLib/tables/C_O_L_R_test.py index 7f3f71ea2..b5ee9f5f1 100644 --- a/Tests/ttLib/tables/C_O_L_R_test.py +++ b/Tests/ttLib/tables/C_O_L_R_test.py @@ -131,11 +131,11 @@ COLR_V1_SAMPLE = ( (b"\x01", "BaseGlyphV1Record[0].Paint.Format (1)"), (b"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"), (b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"), - (b"\x0B", "BaseGlyphV1Record[1].Paint.Format (11)"), + (b"\x0C", "BaseGlyphV1Record[1].Paint.Format (12)"), (b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"), (b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"), (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\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)"), @@ -143,7 +143,7 @@ COLR_V1_SAMPLE = ( (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"\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\x00\x00\x04", "LayerV1List.LayerCount (4)"), ( @@ -163,11 +163,11 @@ COLR_V1_SAMPLE = ( "Fourth Offset to Paint table from beginning of LayerV1List (246)", ), # 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\x0b", "LayerV1List.Paint[0].Glyph (glyph00011)"), # 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\x0c", "LayerV1List.Paint[1].Glyph (glyph00012)"), (b"\x03", "LayerV1List.Paint[1].Paint.Format (3)"), @@ -202,10 +202,10 @@ COLR_V1_SAMPLE = ( (b"@\x00", "ColorLine.ColorStop[2].Color.Alpha.value (1.0)"), (b"\x00\x00\x00\x00", "ColorLine.ColorStop[2].Color.Alpha.varIdx (0)"), # 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\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"\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)"), @@ -230,25 +230,25 @@ COLR_V1_SAMPLE = ( (b"\x00\x07", "ColorLine.ColorStop[1].Color.PaletteIndex (7)"), (b"\x19\x9a\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.value (0.4)"), # 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"\x01\x01\x00\x00\x00\x00\x00\x00", "dx.value (257)"), (b"\x01\x02\x00\x00\x00\x00\x00\x00", "dy.value (258)"), # 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\x2d\x00\x00\x00\x00\x00\x00", "angle.value (45)"), (b"\x00\xff\x00\x00\x00\x00\x00\x00", "centerX.value (255)"), (b"\x01\x00\x00\x00\x00\x00\x00\x00", "centerY.value (256)"), # 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"\xff\xf5\x00\x00\x00\x00\x00\x00", "xSkewAngle (-11)"), (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\xfe\x00\x00\x00\x00\x00\x00", "centerY.value (254)"), # 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\x0b", "LayerV1List.Paint[2].Glyph (11)"), # PaintSolid @@ -296,13 +296,13 @@ COLR_V1_XML = [ " ", ' ', ' ', - ' ', - ' ', + ' ', + ' ', ' ', " ", ' ', - ' ', - ' ', + ' ', + ' ', ' ', " ", " ", @@ -319,7 +319,7 @@ COLR_V1_XML = [ "", "", " ", - ' ', + ' ', ' ', " ", ' ', @@ -328,7 +328,7 @@ COLR_V1_XML = [ " ", ' ', " ", - ' ', + ' ', ' ', " ", ' ', @@ -364,8 +364,8 @@ COLR_V1_XML = [ " ", ' ', " ", - ' ', - ' ', + ' ', + ' ', ' ', " ", ' ', @@ -403,10 +403,10 @@ COLR_V1_XML = [ " ", ' ', " ", - ' ', - ' ', - ' ', - ' ', + ' ', + ' ', + ' ', + ' ', ' ', " ", ' ', From a7d145f027e136006c29b3fddaf17d03914a5691 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 3 Feb 2021 19:11:44 +0000 Subject: [PATCH 2/3] update tests for PaintSweepGradient --- Tests/colorLib/builder_test.py | 23 +++++++++ Tests/ttLib/tables/C_O_L_R_test.py | 77 ++++++++++++++++++++++++++---- 2 files changed, 92 insertions(+), 8 deletions(-) diff --git a/Tests/colorLib/builder_test.py b/Tests/colorLib/builder_test.py index fae00a419..73d6089ca 100644 --- a/Tests/colorLib/builder_test.py +++ b/Tests/colorLib/builder_test.py @@ -385,6 +385,29 @@ def test_buildPaintRadialGradient(): 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(): layerBuilder = LayerV1ListBuilder() layer = layerBuilder.buildPaintGlyph("a", 2) diff --git a/Tests/ttLib/tables/C_O_L_R_test.py b/Tests/ttLib/tables/C_O_L_R_test.py index b5ee9f5f1..0560084be 100644 --- a/Tests/ttLib/tables/C_O_L_R_test.py +++ b/Tests/ttLib/tables/C_O_L_R_test.py @@ -106,7 +106,7 @@ COLR_V1_SAMPLE = ( (b"\x00\x00\x00 ", "Offset to LayerRecordArray from beginning of table (32)"), (b"\x00\x03", "LayerRecordCount (3)"), (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\x06", "BaseGlyphRecord[0].BaseGlyph (6)"), (b"\x00\x00", "BaseGlyphRecord[0].FirstLayerIndex (0)"), @@ -117,20 +117,28 @@ COLR_V1_SAMPLE = ( (b"\x00\x01", "LayerRecord[1].PaletteIndex (1)"), (b"\x00\t", "LayerRecord[2].LayerGlyph (9)"), (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\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", "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"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"), (b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"), + # BaseGlyphV1Record[1] (b"\x0C", "BaseGlyphV1Record[1].Paint.Format (12)"), (b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"), (b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"), @@ -145,6 +153,29 @@ COLR_V1_SAMPLE = ( (b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"), (b"\x07", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (7)"), (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\x14", @@ -286,7 +317,7 @@ COLR_V1_XML = [ "", "", "", - " ", + " ", ' ', ' ', ' ', @@ -316,6 +347,36 @@ COLR_V1_XML = [ " ", " ", " ", + ' ', + ' ', + ' ', + ' ', + " ", + ' ', + " ", + ' ', + ' ', + " ", + ' ', + ' ', + " ", + " ", + ' ', + ' ', + " ", + ' ', + ' ', + " ", + " ", + " ", + ' ', + ' ', + ' ', + ' ', + " ", + ' ', + " ", + " ", "", "", " ", From a3d13abcffa52445f229b4f39acf556d9abccdc9 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 4 Feb 2021 11:32:22 +0000 Subject: [PATCH 3/3] otData: fix typo, add comments --- Lib/fontTools/ttLib/tables/otData.py | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/otData.py b/Lib/fontTools/ttLib/tables/otData.py index 59ff40f65..389ac5c42 100755 --- a/Lib/fontTools/ttLib/tables/otData.py +++ b/Lib/fontTools/ttLib/tables/otData.py @@ -1612,21 +1612,21 @@ otData = [ ('uint16', 'StopCount', None, None, 'Number of Color stops.'), ('ColorStop', 'ColorStop', 'StopCount', 0, 'Array of Color stops.'), ]), - + # PaintColrLayers ('PaintFormat1', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 1'), ('uint8', 'NumLayers', None, None, 'Number of offsets to Paint to read from LayerV1List.'), ('uint32', 'FirstLayerIndex', None, None, 'Index into LayerV1List.'), ]), - + # PaintSolid ('PaintFormat2', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 2'), ('ColorIndex', 'Color', None, None, 'A solid color paint.'), ]), - + # PaintLinearGradient ('PaintFormat3', [ ('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', 'y0', None, None, ''), ('VarInt16', 'x1', None, None, ''), @@ -1634,10 +1634,10 @@ otData = [ ('VarInt16', 'x2', None, None, ''), ('VarInt16', 'y2', None, None, ''), ]), - + # PaintRadialGradient ('PaintFormat4', [ ('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', 'y0', None, None, ''), ('VarUInt16', 'r0', None, None, ''), @@ -1645,40 +1645,40 @@ otData = [ ('VarInt16', 'y1', None, None, ''), ('VarUInt16', 'r1', None, None, ''), ]), - + # PaintSweepGradient ('PaintFormat5', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 5'), - ('Offset24', 'ColorLine', None, None, 'Offset (from beginning of PaintSweep table) to ColorLine subtable.'), + ('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.'), ('GlyphID', 'Glyph', None, None, 'Glyph ID for the source outline.'), ]), - + # PaintColrGlyph ('PaintFormat7', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 7'), ('GlyphID', 'Glyph', None, None, 'Virtual glyph ID for a BaseGlyphV1List base glyph.'), ]), - + # PaintTransform ('PaintFormat8', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 8'), - ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintTransformed table) to Paint subtable.'), - ('Affine2x3', 'Transform', None, None, 'Offset (from beginning of PaintTrasformed table) to Affine2x3 subtable.'), + ('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.'), ('VarFixed', 'dx', None, None, 'Translation in x direction.'), ('VarFixed', 'dy', None, None, 'Translation in y direction.'), ]), - + # PaintRotate ('PaintFormat10', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 10'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintRotate table) to Paint subtable.'), @@ -1686,7 +1686,7 @@ otData = [ ('VarFixed', 'centerX', None, None, ''), ('VarFixed', 'centerY', None, None, ''), ]), - + # PaintSkew ('PaintFormat11', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 11'), ('Offset24', 'Paint', None, None, 'Offset (from beginning of PaintSkew table) to Paint subtable.'), @@ -1695,7 +1695,7 @@ otData = [ ('VarFixed', 'centerX', None, None, ''), ('VarFixed', 'centerY', None, None, ''), ]), - + # PaintComposite ('PaintFormat12', [ ('uint8', 'PaintFormat', None, None, 'Format identifier-format = 12'), ('LOffset24To(Paint)', 'SourcePaint', None, None, 'Offset (from beginning of PaintComposite table) to source Paint subtable.'),