Skip to content

Commit

Permalink
Only correct instroke when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncozens committed Nov 18, 2023
1 parent f091f3c commit 473459e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Lib/glyphsLib/filters/cornerComponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def apply(self):
(
instroke_intersection_point,
outstroke_intersection_point,
correction,
) = self.align_my_path_to_main_path()

# Keep hold of the original outstroke segment. Fitting the
Expand All @@ -278,7 +279,7 @@ def apply(self):
# instroke based on where we put the corner component, and
# potentially stretch the corner component so that it meets the
# instroke.
if self.alignment != Alignment.INSTROKE:
if self.alignment != Alignment.INSTROKE and correction:
instroke_intersection_point = self.recompute_instroke_intersection_point()
# The instroke of the corner path may need stretching to fit...
if len(self.first_seg) == 4:
Expand Down Expand Up @@ -364,6 +365,7 @@ def align_my_path_to_main_path(self):
instroke_intersection_point = segmentPointAtT(
as_tuples(reversed(self.instroke)), t2
)
correction = not (math.isclose(t2, 0.0) or math.isclose(t2, 1.0))
instroke_angle = math.atan2(
self.target_node.y - instroke_intersection_point[1],
self.target_node.x - instroke_intersection_point[0],
Expand All @@ -389,7 +391,7 @@ def align_my_path_to_main_path(self):
for pt in path:
pt.x, pt.y = translation.transform(rot).transformPoint((pt.x, pt.y))

return instroke_intersection_point, outstroke_intersection_point
return instroke_intersection_point, outstroke_intersection_point, correction

def recompute_instroke_intersection_point(self):
return unbounded_seg_seg_intersection(
Expand Down

0 comments on commit 473459e

Please sign in to comment.