[cairo-commit] 2 commits - src/cairo-truetype-subset.c src/cairo-truetype-subset-private.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Apr 4 07:48:23 PDT 2009


 src/cairo-truetype-subset-private.h |    2 +-
 src/cairo-truetype-subset.c         |   14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit fe97e815e81f4429889fd52bb525c260f9967356
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Apr 5 01:04:12 2009 +1030

    Fix TrueType subsetting bug
    
    Fix incorrect counting of arguments in composite glyphs

diff --git a/src/cairo-truetype-subset-private.h b/src/cairo-truetype-subset-private.h
index 397a9f3..978256f 100644
--- a/src/cairo-truetype-subset-private.h
+++ b/src/cairo-truetype-subset-private.h
@@ -185,7 +185,7 @@ typedef struct _tt_name {
 typedef struct _tt_composite_glyph {
     uint16_t flags;
     uint16_t index;
-    uint16_t args[7]; /* 1 to 7 arguments depending on value of flags */
+    uint16_t args[6]; /* 1 to 6 arguments depending on value of flags */
 } tt_composite_glyph_t;
 
 typedef struct _tt_glyph_data {
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 323a10c..59be905 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -105,8 +105,8 @@ check (tt_maxp_t,	32);
 check (tt_name_record_t, 12);
 check (tt_name_t,	18);
 check (tt_name_t,	18);
-check (tt_composite_glyph_t, 18);
-check (tt_glyph_data_t,	28);
+check (tt_composite_glyph_t, 16);
+check (tt_glyph_data_t,	26);
 #undef check
 
 static cairo_status_t
@@ -508,13 +508,15 @@ cairo_truetype_font_remap_composite_glyph (cairo_truetype_font_t	*font,
         num_args = 1;
         if (flags & TT_ARG_1_AND_2_ARE_WORDS)
             num_args += 1;
-        if (flags & TT_WE_HAVE_A_SCALE)
+
+	if (flags & TT_WE_HAVE_A_SCALE)
             num_args += 1;
         else if (flags & TT_WE_HAVE_AN_X_AND_Y_SCALE)
             num_args += 2;
         else if (flags & TT_WE_HAVE_A_TWO_BY_TWO)
-            num_args += 3;
-        composite_glyph = (tt_composite_glyph_t *) &(composite_glyph->args[num_args]);
+            num_args += 4;
+
+	composite_glyph = (tt_composite_glyph_t *) &(composite_glyph->args[num_args]);
     } while (has_more_components);
 
     return CAIRO_STATUS_SUCCESS;
commit 9b496af5c214283c297a52c90a04743f9da9f6a3
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Apr 5 00:44:02 2009 +1030

    Fix buffer size check in TrueType subsetting
    
    Andrew Cowie reported a problem with the Charis SIL font being
    embedded as a fallback font.
    
    The buffer size check for composite glyphs was incorrect causing the
    subsetting to fail for some fonts.

diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 8d1b597..323a10c 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -495,7 +495,7 @@ cairo_truetype_font_remap_composite_glyph (cairo_truetype_font_t	*font,
 
     composite_glyph = &glyph_data->glyph;
     do {
-	if ((unsigned char *)(&composite_glyph->args[1]) >= end)
+	if ((unsigned char *)(&composite_glyph->args[0]) >= end)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 
 	flags = be16_to_cpu (composite_glyph->flags);


More information about the cairo-commit mailing list