A fix from Tom to fix the last=first point problem if it is a control point.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c
index a48176f..bcdaece 100644
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -500,9 +500,11 @@
/* is located on the first point. */
if ( outline->n_points > 1 )
{
- FT_Int first = 0;
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Int first = 0;
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
+
if ( outline->n_contours > 1 )
{
@@ -510,8 +512,11 @@
p1 = outline->points + first;
}
+ /* `delete' last point only if it coincides with the first */
+ /* point and it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
- outline->n_points--;
+ if ( *control == FT_Curve_Tag_On )
+ outline->n_points--;
}
if ( outline->n_contours > 0 )
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index b6bf532..7645891 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -1238,13 +1238,15 @@
{
FT_Outline* outline = builder->current;
+
/* XXXX: We must not include the last point in the path if it */
/* is located on the first point. */
if ( outline->n_points > 1 )
{
- FT_Int first = 0;
- FT_Vector* p1 = outline->points + first;
- FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Int first = 0;
+ FT_Vector* p1 = outline->points + first;
+ FT_Vector* p2 = outline->points + outline->n_points - 1;
+ FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
if ( outline->n_contours > 1 )
@@ -1253,8 +1255,11 @@
p1 = outline->points + first;
}
+ /* `delete' last point only if it coincides with the first */
+ /* point and it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
- outline->n_points--;
+ if ( *control == FT_Curve_Tag_On )
+ outline->n_points--;
}
if ( outline->n_contours > 0 )