diff --git a/Lib/fontTools/ttLib/woff2.py b/Lib/fontTools/ttLib/woff2.py index 02e273d2e..3e247b02e 100644 --- a/Lib/fontTools/ttLib/woff2.py +++ b/Lib/fontTools/ttLib/woff2.py @@ -1041,6 +1041,8 @@ class WOFF2GlyfTable(getTableClass("glyf")): def _encodeCoordinates(self, glyph): lastEndPoint = -1 + if _g_l_y_f.flagCubic in glyph.flags: + raise NotImplementedError for endPoint in glyph.endPtsOfContours: ptsOfContour = endPoint - lastEndPoint self.nPointsStream += pack255UShort(ptsOfContour) diff --git a/Tests/ttLib/woff2_test.py b/Tests/ttLib/woff2_test.py index 0a89b8b43..e098eb993 100644 --- a/Tests/ttLib/woff2_test.py +++ b/Tests/ttLib/woff2_test.py @@ -28,6 +28,7 @@ from fontTools.misc import sstruct from fontTools.misc.textTools import Tag, bytechr, byteord from fontTools import fontBuilder from fontTools.pens.ttGlyphPen import TTGlyphPen +from fontTools.pens.recordingPen import RecordingPen from io import BytesIO import struct import os @@ -1505,6 +1506,28 @@ class VarCompositeTest(unittest.TestCase): ttf.save(out) +class CubicTest(unittest.TestCase): + def test_cubic(self): + input_path = os.path.join( + data_dir, "..", "tables", "data", "NotoSans-VF-cubic.subset.ttf" + ) + ttf = ttLib.TTFont(input_path) + pen1 = RecordingPen() + ttf.getGlyphSet()["a"].draw(pen1) + ttf.flavor = "woff2" + out = BytesIO() + ttf.save(out) + + ttf = ttLib.TTFont(out) + ttf.flavor = None + pen2 = RecordingPen() + ttf.getGlyphSet()["a"].draw(pen2) + out = BytesIO() + ttf.save(out) + + assert pen1.value == pen2.value + + if __name__ == "__main__": import sys