From 1928306a050ff2b22979af4d4db2b60be7d22a13 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 6 Jun 2012 13:45:31 -0400 Subject: [PATCH] Fixes #913. Paths that start with an "OFF" point should use their last point as an initial MOVETO. This is the SVG-specific corrolory to #905. --- src/ft2font.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/ft2font.cpp b/src/ft2font.cpp index 26a3fe42ad7f..7bfdadbe3db0 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -536,6 +536,7 @@ FT2Font::get_path() for (n = 0; n < outline.n_contours; n++) { int last; // index of last point in contour + bool starts_with_last; last = outline.contours[n]; limit = outline.points + last; @@ -554,13 +555,22 @@ FT2Font::get_path() { throw Py::RuntimeError("A contour cannot start with a cubic control point"); } + else if (tag == FT_CURVE_TAG_CONIC) + { + starts_with_last = true; + } else { + starts_with_last = false; + } count++; while (point < limit) { - point++; - tags++; + if (!starts_with_last) { + point++; + tags++; + } + starts_with_last = false; tag = FT_CURVE_TAG(tags[0]); switch (tag) @@ -656,7 +666,8 @@ FT2Font::get_path() first = 0; for (n = 0; n < outline.n_contours; n++) { - int last; // index of last point in contour + int last; // index of last point in contour + bool starts_with_last; last = outline.contours[n]; limit = outline.points + last; @@ -670,16 +681,29 @@ FT2Font::get_path() tags = outline.tags + first; tag = FT_CURVE_TAG(tags[0]); - double x = conv(v_start.x); - double y = flip_y ? -conv(v_start.y) : conv(v_start.y); + double x, y; + if (tag != FT_CURVE_TAG_ON) + { + x = conv(v_last.x); + y = flip_y ? -conv(v_last.y) : conv(v_last.y); + starts_with_last = true; + } else { + x = conv(v_start.x); + y = flip_y ? -conv(v_start.y) : conv(v_start.y); + starts_with_last = false; + } + *(outpoints++) = x; *(outpoints++) = y; *(outcodes++) = MOVETO; while (point < limit) { - point++; - tags++; + if (!starts_with_last) { + point++; + tags++; + } + starts_with_last = false; tag = FT_CURVE_TAG(tags[0]); switch (tag)