From e20ccfcf9f77404317ac5334f375feb5ab45077f Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 4 Feb 2021 12:16:29 +0000 Subject: [PATCH] add unbuildPaintSweepGradient --- Lib/fontTools/colorLib/unbuilder.py | 12 ++++++++++++ Tests/colorLib/unbuilder_test.py | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Lib/fontTools/colorLib/unbuilder.py b/Lib/fontTools/colorLib/unbuilder.py index 6b7a09b30..f7c745984 100644 --- a/Lib/fontTools/colorLib/unbuilder.py +++ b/Lib/fontTools/colorLib/unbuilder.py @@ -113,6 +113,18 @@ class LayerV1ListUnbuilder: "r1": r1, } + def unbuildPaintSweepGradient(self, paint): + return { + "format": int(ot.Paint.Format.PaintSweepGradient), + "colorLine": unbuildColorLine( + paint.ColorLine, ignoreVarIdx=self.ignoreVarIdx + ), + "centerX": self.unbuildVariableValue(paint.centerX), + "centerY": self.unbuildVariableValue(paint.centerY), + "startAngle": self.unbuildVariableValue(paint.startAngle), + "endAngle": self.unbuildVariableValue(paint.endAngle), + } + def unbuildPaintGlyph(self, paint): return { "format": int(ot.Paint.Format.PaintGlyph), diff --git a/Tests/colorLib/unbuilder_test.py b/Tests/colorLib/unbuilder_test.py index 9d115b415..9ba332018 100644 --- a/Tests/colorLib/unbuilder_test.py +++ b/Tests/colorLib/unbuilder_test.py @@ -103,7 +103,25 @@ TEST_COLOR_GLYPHS = { }, }, }, - "glyph00015": [ + "glyph00015": { + "format": int(ot.Paint.Format.PaintGlyph), + "glyph": "glyph00011", + "paint": { + "format": int(ot.Paint.Format.PaintSweepGradient), + "colorLine": { + "stops": [ + {"offset": 0.0, "paletteIndex": 3, "alpha": 1.0}, + {"offset": 1.0, "paletteIndex": 5, "alpha": 1.0}, + ], + "extend": "pad", + }, + "centerX": 259, + "centerY": 300, + "startAngle": 45.0, + "endAngle": 135.0, + }, + }, + "glyph00016": [ { "format": int(ot.Paint.Format.PaintGlyph), "glyph": "glyph00011",