Closed typesupply closed 10 months ago
This is undesired behavior because somewhere in the variable font tool chain an on curve is expected. Here's a demo of the problem:
from fontTools.ufoLib.glifLib import readGlyphFromString def dump(glyph): for contour in glyph: print(contour.getIdentifier()) for i, segment in enumerate(contour.segments): print("+", i, segment.onCurve.getIdentifier()) for i, point in enumerate(contour.points): print("-", (i, point.getIdentifier(), point.x, point.y, point.type)) glif = """ <?xml version='1.0' encoding='UTF-8'?> <glyph name="A" format="2"> <advance width="500"/> <unicode hex="0041"/> <outline> <contour identifier="44XxVKnB2x"> <point x="500" y="250" type="curve" smooth="yes" identifier="sAwqsKyYNW"/> <point x="500" y="388" identifier="6tQSHOf9Ys"/> <point x="388" y="500" identifier="0RDMteuRyw"/> <point x="250" y="500" type="curve" smooth="yes" identifier="Dqlm7jnjuf"/> <point x="112" y="500" identifier="VdNjzcUQ07"/> <point x="0" y="388" identifier="cIkDdREiYg"/> <point x="0" y="250" type="curve" smooth="yes" identifier="6eCPXmIBoJ"/> <point x="0" y="112" identifier="DnlDWVnzCn"/> <point x="112" y="0" identifier="othuknxJCG"/> <point x="250" y="0" type="curve" smooth="yes" identifier="kCNyF3Qqen"/> <point x="388" y="0" identifier="HfzlQB6wyA"/> <point x="500" y="112" identifier="uVNo2cq7Pf"/> </contour> </outline> </glyph> """.strip() glyph = RGlyph() pen = glyph.getPen() readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph.getPointPen()) print("Original:") dump(glyph) print("") contour = glyph.contours[0] contour.setStartSegment(1) print("Changed:") dump(glyph)
Original: 44XxVKnB2x + 0 Dqlm7jnjuf + 1 6eCPXmIBoJ + 2 kCNyF3Qqen + 3 sAwqsKyYNW - (0, 'sAwqsKyYNW', 500, 250, 'curve') - (1, '6tQSHOf9Ys', 500, 388, 'offcurve') - (2, '0RDMteuRyw', 388, 500, 'offcurve') - (3, 'Dqlm7jnjuf', 250, 500, 'curve') - (4, 'VdNjzcUQ07', 112, 500, 'offcurve') - (5, 'cIkDdREiYg', 0, 388, 'offcurve') - (6, '6eCPXmIBoJ', 0, 250, 'curve') - (7, 'DnlDWVnzCn', 0, 112, 'offcurve') - (8, 'othuknxJCG', 112, 0, 'offcurve') - (9, 'kCNyF3Qqen', 250, 0, 'curve') - (10, 'HfzlQB6wyA', 388, 0, 'offcurve') - (11, 'uVNo2cq7Pf', 500, 112, 'offcurve') Changed: 44XxVKnB2x + 0 6eCPXmIBoJ + 1 kCNyF3Qqen + 2 sAwqsKyYNW + 3 Dqlm7jnjuf - (0, '6tQSHOf9Ys', 500, 388, 'offcurve') - (1, '0RDMteuRyw', 388, 500, 'offcurve') - (2, 'Dqlm7jnjuf', 250, 500, 'curve') - (3, 'VdNjzcUQ07', 112, 500, 'offcurve') - (4, 'cIkDdREiYg', 0, 388, 'offcurve') - (5, '6eCPXmIBoJ', 0, 250, 'curve') - (6, 'DnlDWVnzCn', 0, 112, 'offcurve') - (7, 'othuknxJCG', 112, 0, 'offcurve') - (8, 'kCNyF3Qqen', 250, 0, 'curve') - (9, 'HfzlQB6wyA', 388, 0, 'offcurve') - (10, 'uVNo2cq7Pf', 500, 112, 'offcurve') - (11, 'sAwqsKyYNW', 500, 250, 'curve')
This is undesired behavior because somewhere in the variable font tool chain an on curve is expected. Here's a demo of the problem: