[glyf] Simplify contour end logic
So no need for infinite loop here
This commit is contained in:
parent
132fcfbc47
commit
4cdaa9d1f4
|
@ -1054,8 +1054,6 @@ struct glyf
|
||||||
draw_helper.init (funcs, user_data);
|
draw_helper.init (funcs, user_data);
|
||||||
first_oncurve = first_offcurve = last_offcurve = optional_point_t ();
|
first_oncurve = first_offcurve = last_offcurve = optional_point_t ();
|
||||||
}
|
}
|
||||||
void end_of_contour ()
|
|
||||||
{ first_oncurve = first_offcurve = last_offcurve = optional_point_t (); }
|
|
||||||
|
|
||||||
/* based on https://github.com/RazrFalcon/ttf-parser/blob/master/src/glyf.rs#L292 */
|
/* based on https://github.com/RazrFalcon/ttf-parser/blob/master/src/glyf.rs#L292 */
|
||||||
void consume_point (const contour_point_t &point)
|
void consume_point (const contour_point_t &point)
|
||||||
|
@ -1115,37 +1113,32 @@ struct glyf
|
||||||
|
|
||||||
if (point.is_end_point)
|
if (point.is_end_point)
|
||||||
{
|
{
|
||||||
for (;;)
|
if (!first_offcurve.is_null && !last_offcurve.is_null)
|
||||||
{
|
{
|
||||||
if (!first_offcurve.is_null && !last_offcurve.is_null)
|
optional_point_t mid = last_offcurve.lerp (first_offcurve, .5f);
|
||||||
{
|
draw_helper.quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y),
|
||||||
optional_point_t mid = last_offcurve.lerp (first_offcurve, .5f);
|
font->em_scalef_x (mid.x), font->em_scalef_y (mid.y));
|
||||||
draw_helper.quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y),
|
last_offcurve = optional_point_t ();
|
||||||
font->em_scalef_x (mid.x), font->em_scalef_y (mid.y));
|
/* now check the rest */
|
||||||
last_offcurve = optional_point_t ();
|
|
||||||
}
|
|
||||||
else if (!first_offcurve.is_null && last_offcurve.is_null)
|
|
||||||
{
|
|
||||||
if (!first_oncurve.is_null)
|
|
||||||
draw_helper.quadratic_to (font->em_scalef_x (first_offcurve.x), font->em_scalef_y (first_offcurve.y),
|
|
||||||
font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (first_offcurve.is_null && !last_offcurve.is_null)
|
|
||||||
{
|
|
||||||
if (!first_oncurve.is_null)
|
|
||||||
draw_helper.quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y),
|
|
||||||
font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else /* first_offcurve.is_null && last_offcurve.is_null */
|
|
||||||
{
|
|
||||||
if (!first_oncurve.is_null)
|
|
||||||
draw_helper.line_to (font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end_of_contour ();
|
|
||||||
|
if (!first_offcurve.is_null && last_offcurve.is_null)
|
||||||
|
{
|
||||||
|
if (!first_oncurve.is_null)
|
||||||
|
draw_helper.quadratic_to (font->em_scalef_x (first_offcurve.x), font->em_scalef_y (first_offcurve.y),
|
||||||
|
font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
||||||
|
}
|
||||||
|
else if (first_offcurve.is_null && !last_offcurve.is_null)
|
||||||
|
{
|
||||||
|
if (!first_oncurve.is_null)
|
||||||
|
draw_helper.quadratic_to (font->em_scalef_x (last_offcurve.x), font->em_scalef_y (last_offcurve.y),
|
||||||
|
font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
||||||
|
}
|
||||||
|
else /* first_offcurve.is_null && last_offcurve.is_null */
|
||||||
|
if (!first_oncurve.is_null)
|
||||||
|
draw_helper.line_to (font->em_scalef_x (first_oncurve.x), font->em_scalef_y (first_oncurve.y));
|
||||||
|
|
||||||
|
first_oncurve = first_offcurve = last_offcurve = optional_point_t ();
|
||||||
draw_helper.end_path ();
|
draw_helper.end_path ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue