Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction to corner components #958

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
139 changes: 136 additions & 3 deletions tests/data/CornerComponents.glyphs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
.appVersion = "3109";
.appVersion = "3225";
.formatVersion = 3;
DisplayStrings = (
"/_corner.seven/al_unaligned/ai_curved_outstroke/ai_curved_outstroke.expectation"
"/_corner.large/aw_direction",
"/aw_direction.expectation"
);
customParameters = (
{
Expand Down Expand Up @@ -87,7 +88,6 @@ over = -16;
pos = -200;
},
{
over = -16;
}
);
name = Regular;
Expand Down Expand Up @@ -1748,6 +1748,81 @@ width = 600;
);
},
{
category = Letter;
color = 1;
export = 0;
glyphname = _corner.large;
layers = (
{
associatedMasterId = m01;
layerId = "8D56D424-E9A7-400C-A9D5-AD8E3EE2E0AC";
name = "Bold-18pt";
shapes = (
{
closed = 0;
nodes = (
(0,0,l),
(10,-15,l),
(161,-15,l),
(171,0,l)
);
}
);
width = 171;
},
{
associatedMasterId = m01;
layerId = "0C674E7E-91ED-4D44-BE50-73C52ADB0B3C";
name = "Regular-18pt";
shapes = (
{
closed = 0;
nodes = (
(0,0,l),
(10,-11,l),
(105,-11,l),
(115,0,l)
);
}
);
width = 115.26667;
},
{
layerId = m01;
shapes = (
{
closed = 0;
nodes = (
(0,0,l),
(8,-11,l),
(106,-11,l),
(116,0,l)
);
}
);
width = 116;
},
{
associatedMasterId = m01;
layerId = "58998773-F943-4012-9030-873B26EE63FE";
name = "Bold-17pt";
shapes = (
{
closed = 0;
nodes = (
(0,0,l),
(10,-15,l),
(161,-15,l),
(171,0,l)
);
}
);
width = 171;
}
);
subCategory = Fraction;
},
{
export = 0;
glyphname = _corner.seven;
lastChange = "2022-11-22 12:06:08 +0000";
Expand Down Expand Up @@ -1804,6 +1879,64 @@ width = 200;
);
},
{
color = 9;
glyphname = aw_direction;
lastChange = "2023-11-18 04:55:35 +0000";
layers = (
{
hints = (
{
name = _corner.large;
origin = (0,4);
type = Corner;
}
);
layerId = m01;
shapes = (
{
closed = 1;
nodes = (
(246,0,l),
(246,217,l),
(198,154,o),
(92,112,o),
(37,112,c),
(8,0,l)
);
}
);
width = 286;
}
);
},
{
color = 9;
glyphname = aw_direction.expectation;
lastChange = "2023-11-18 04:58:15 +0000";
layers = (
{
layerId = m01;
shapes = (
{
closed = 1;
nodes = (
(246,0,l),
(246,217,l),
(198,154,o),
(92,112,o),
(37,112,c),
(24,107,l),
(0,12,l),
(8,0,l),
(8,0,l)
);
}
);
width = 286;
}
);
},
{
glyphname = ax_curved_instroke2;
lastChange = "2022-11-21 22:09:49 +0000";
layers = (
Expand Down
Loading