summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2009-04-01 08:03:37 +0200
committerWerner Lemberg <wl@gnu.org>2009-04-01 08:03:37 +0200
commitfbdf127904c26714ed69c2c1298c6eb7d564031e (patch)
tree1e08bd6e00984687c33522853f8ef649ed9fd19d
parent0315bb20ce9660b92118df816d07f94adbd47ad3 (diff)
downloadfreetype2-fbdf127904c26714ed69c2c1298c6eb7d564031e.tar.gz
Ignore empty contours in CFF glyphs.
Problem reported by Albert Astals Cid <aacid@kde.org>. * src/cff/cffgload.c (cff_builder_close_contour): Synchronize with t1_builder_close_contour.
-rw-r--r--ChangeLog9
-rw-r--r--src/cff/cffgload.c29
2 files changed, 27 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index ed62412ca..eddfd04eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-01 Werner Lemberg <wl@gnu.org>
+
+ Ignore empty contours in CFF glyphs.
+
+ Problem reported by Albert Astals Cid <aacid@kde.org>.
+
+ * src/cff/cffgload.c (cff_builder_close_contour): Synchronize with
+ t1_builder_close_contour.
+
2009-03-21 Werner Lemberg <wl@gnu.org>
Another redundant header inclusion.
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 0bd297b81..03956cab8 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -552,27 +552,24 @@
cff_builder_close_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
+ FT_Int first;
if ( !outline )
return;
- /* XXXX: We must not include the last point in the path if it */
- /* is located on the first point. */
+ first = outline->n_contours <= 1
+ ? 0 : outline->contours[outline->n_contours - 2] + 1;
+
+ /* 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_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
- if ( outline->n_contours > 1 )
- {
- first = outline->contours[outline->n_contours - 2] + 1;
- p1 = outline->points + first;
- }
-
/* `delete' last point only if it coincides with the first */
/* point and if it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
@@ -581,8 +578,18 @@
}
if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] =
- (short)( outline->n_points - 1 );
+ {
+ /* Don't add contours only consisting of one point, i.e., */
+ /* check whether begin point and last point are the same. */
+ if ( first == outline->n_points - 1 )
+ {
+ outline->n_contours--;
+ outline->n_points--;
+ }
+ else
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+ }
}