From a7d145f027e136006c29b3fddaf17d03914a5691 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 3 Feb 2021 19:11:44 +0000 Subject: [PATCH] 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 = [ " ", " ", " ", + ' ', + ' ', + ' ', + ' ', + " ", + ' ', + " ", + ' ', + ' ', + " ", + ' ', + ' ', + " ", + " ", + ' ', + ' ', + " ", + ' ', + ' ', + " ", + " ", + " ", + ' ', + ' ', + ' ', + ' ', + " ", + ' ', + " ", + " ", "", "", " ",