[CFF/T2] Ensure that pen.closePath() gets called for CFF2 charstrings (#2577)
* [CFF/T2] Make sure to call pen.closePath() at the end of a CFF2/T2 charstring. Fixes #2455 * Add test case to verify pen.closePath() behavior
This commit is contained in:
parent
c6cd6cf421
commit
169731c7f5
@ -980,6 +980,7 @@ class T2CharString(object):
|
||||
self.private.nominalWidthX, self.private.defaultWidthX,
|
||||
self.private)
|
||||
extractor.execute(self)
|
||||
extractor.endPath()
|
||||
self.width = extractor.width
|
||||
|
||||
def calcBounds(self, glyphSet):
|
||||
|
@ -8,6 +8,7 @@ from fontTools.misc.psCharStrings import (
|
||||
read_fixed1616,
|
||||
read_realNumber,
|
||||
)
|
||||
from fontTools.pens.recordingPen import RecordingPen
|
||||
import unittest
|
||||
|
||||
|
||||
@ -158,6 +159,14 @@ class T2CharStringTest(unittest.TestCase):
|
||||
self.assertNotIsInstance(expected_arg, str)
|
||||
self.assertAlmostEqual(arg, expected_arg)
|
||||
|
||||
def test_pen_closePath(self):
|
||||
# Test CFF2/T2 charstring: it does NOT end in "endchar"
|
||||
# https://github.com/fonttools/fonttools/issues/2455
|
||||
cs = self.stringToT2CharString("100 100 rmoveto -50 -150 200 0 -50 150 rrcurveto")
|
||||
pen = RecordingPen()
|
||||
cs.draw(pen)
|
||||
self.assertEqual(pen.value[-1], ('closePath', ()))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
Loading…
x
Reference in New Issue
Block a user