Fix the case where the first and last points are both off-curve

This commit is contained in:
Patrick Walton 2017-02-13 11:56:10 -08:00
parent cd11deab46
commit b000f6d882
1 changed files with 11 additions and 0 deletions

View File

@ -197,6 +197,17 @@ impl<'a> GlyfTable<'a> {
// We're about to close the path. Emit the initial off curve point if there was one.
if let Some(initial_off_curve_point) = initial_off_curve_point {
if last_point_was_off_curve {
// Another important edge case!
let position = position + (initial_off_curve_point - position) / 2;
callback(&Point {
position: position,
index_in_contour: point_index_in_contour,
on_curve: true,
});
point_index_in_contour += 1
}
callback(&Point {
position: initial_off_curve_point,
on_curve: false,