[cairo-commit] src/cairo-cff-subset.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Thu Sep 8 03:01:23 PDT 2011


 src/cairo-cff-subset.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 80fc566eaf9ba0307d3f556e20b4a20c47b37afc
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Sep 8 19:29:16 2011 +0930

    cff: strip subset tag when reading font name
    
    so we don't end up with two subset tags in the font name when cairo
    appends its own subset tag.

diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index fde3665..6c71795 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -844,17 +844,32 @@ cairo_cff_font_read_name (cairo_cff_font_t *font)
     cairo_array_t index;
     cairo_int_status_t status;
     cff_index_element_t *element;
+    unsigned char *p;
+    int i, len;
 
     cff_index_init (&index);
     status = cff_index_read (&index, &font->current_ptr, font->data_end);
     if (!font->is_opentype) {
         element = _cairo_array_index (&index, 0);
-        font->ps_name = malloc (element->length + 1);
+	p = element->data;
+	len = element->length;
+
+	/* If font name is prefixed with a subset tag, strip it off. */
+	if (len > 7 && p[6] == '+') {
+	    for (i = 0; i < 6; i++)
+		if (p[i] < 'A' || p[i] > 'Z')
+		    break;
+	    if (i == 6) {
+		p += 7;
+		len -= 7;
+	    }
+	}
+        font->ps_name = malloc (len + 1);
         if (unlikely (font->ps_name == NULL))
             return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-        memcpy (font->ps_name, element->data, element->length);
-        font->ps_name[element->length] = 0;
+        memcpy (font->ps_name, p, len);
+        font->ps_name[len] = 0;
     }
     cff_index_fini (&index);
 


More information about the cairo-commit mailing list