An incorrect node may be inserted
Opened this issue · 1 comments
-
my environment
macOS Sierra 10.12.4
Glyphs 2.4.1 (983) -
detail
When the first segment and another segment have missing inflections, the inflection node for the first segment may be inserted at wrong location.
Assuming that the length of nodes are 23 at first, after an inflection is inserted at some segment, then the length of nodes becomes 26.
So the nodes of the first segment should be now consist of nodes[23], nodes[24], nodes[25] and nodes[0], but actually nodes[20], nodes[21], nodes[22] and nodes[0] are referenced because numberOfNodes
is not updated. Therefore computeInflection
may calculate a wrong inflectionTime for the first segment.
Some modification as below may resolve this issue and attached test.ufo.zip may be helpful.
--- a/InsertInflections.glyphsFilter/Contents/Resources/InsertInflections.py
+++ b/InsertInflections.glyphsFilter/Contents/Resources/InsertInflections.py
@@ -100,7 +100,8 @@ class GlyphsFilterInsertInflections ( NSObject, GlyphsFilterProtocol ):
for i in range(numberOfNodes-1, -1, -1):
node = thisPath.nodes[i]
if node.type == CURVE:
- nl = [ thisPath.nodes[ (x+numberOfNodes)%numberOfNodes ] for x in range( i-3, i+1 ) ]
+ cur_numberOfNodes = len( thisPath.nodes )
+ nl = [ thisPath.nodes[ (x+cur_numberOfNodes)%cur_numberOfNodes ] for x in range( i-3, i+1 ) ]
inflections = self.computeInflection( nl[0], nl[1], nl[2], nl[3] )
if len(inflections) == 1:
inflectionTime = inflections[0]
I see, will have a look. The idea was to step through segments backwards and thus avoid the problem. But the reference problem exists for what counts as the first segment.