]> granicus.if.org Git - libass/commitdiff
Fix fix_freetype_stroker
authorOleg Oshmyan <chortos@inbox.lv>
Thu, 22 Nov 2012 02:19:17 +0000 (02:19 +0000)
committerOleg Oshmyan <chortos@inbox.lv>
Fri, 28 Dec 2012 16:54:27 +0000 (18:54 +0200)
The first point in a countour is not allowed to be a cubic control
point, which is sometimes violated by blindly reversing a countour,
producing the following errors:

    [ass] FT_Stroker_ParseOutline failed, error: 20
    [ass] Failed to rasterize glyph: 1

To avoid this, let the first point remain the first
and only reverse the order of the remaining points.

libass/ass_font.c

index 92a2eff369762580d50b50b788d8732f7f3572cf..6840e2fd16b199d2e0ffe1c54e2236eb94703932 100644 (file)
@@ -711,12 +711,12 @@ void fix_freetype_stroker(FT_Outline *outline, int border_x, int border_y)
             /* "inside" contour but we can't find anything it could be
              * inside of - assume the font is buggy and it should be
              * an "outside" contour, and reverse it */
-            for (j = 0; j < (end + 1 - start) / 2; j++) {
-                FT_Vector temp = outline->points[start + j];
-                char temp2 = outline->tags[start + j];
-                outline->points[start + j] = outline->points[end - j];
+            for (j = 0; j < (end - start) / 2; j++) {
+                FT_Vector temp = outline->points[start + 1 + j];
+                char temp2 = outline->tags[start + 1 + j];
+                outline->points[start + 1 + j] = outline->points[end - j];
                 outline->points[end - j] = temp;
-                outline->tags[start + j] = outline->tags[end - j];
+                outline->tags[start + 1 + j] = outline->tags[end - j];
                 outline->tags[end - j] = temp2;
             }
             dir ^= 1;