[cairo-commit] 3 commits - src/cairo-quartz-font.c src/cairo-scaled-font.c util/cairo-script

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 10 09:20:20 PDT 2009


 src/cairo-quartz-font.c                  |    6 --
 src/cairo-scaled-font.c                  |    3 -
 util/cairo-script/cairo-script-file.c    |   10 +--
 util/cairo-script/cairo-script-scanner.c |   81 +++++++++++++++++++------------
 4 files changed, 59 insertions(+), 41 deletions(-)

New commits:
commit 2e8ce34454a4d93986f590b1d2b024d1a1eb6bde
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 10 16:51:07 2009 +0100

    [quartz] Use the implementation font-face not the associated
    
    As the associated is now explicitly the font-face used to create the font
    by the user, whereas what we require is the current implementation
    (quartz) font.

diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 91c1654..a8a9fc5 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -345,10 +345,8 @@ static cairo_quartz_font_face_t *
 _cairo_quartz_scaled_to_face (void *abstract_font)
 {
     cairo_quartz_scaled_font_t *sfont = (cairo_quartz_scaled_font_t*) abstract_font;
-    cairo_font_face_t *font_face = cairo_scaled_font_get_font_face (&sfont->base);
-    if (!font_face || font_face->backend->type != CAIRO_FONT_TYPE_QUARTZ)
-	return NULL;
-
+    cairo_font_face_t *font_face = sfont->base.font_face;
+    assert (font_face->backend->type == CAIRO_FONT_TYPE_QUARTZ);
     return (cairo_quartz_font_face_t*) font_face;
 }
 
commit a4dc372bab8ebe75a9f7d17a9a2e6fc8d9d2d747
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 10 16:50:00 2009 +0100

    [scaled-font] Update API documentation
    
    Now that the toy-font-face is exposed to the user, it is expected to be
    returned when the user queries the font face associated with a scaled font.

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 3238c84..3d357a2 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2712,8 +2712,7 @@ _cairo_scaled_font_get_max_scale (cairo_scaled_font_t *scaled_font)
  * @scaled_font: a #cairo_scaled_font_t
  *
  * Gets the font face that this scaled font uses.  This is the
- * font face passed to cairo_scaled_font_create() if that font face
- * was not of type %CAIRO_FONT_TYPE_TOY.
+ * font face passed to cairo_scaled_font_create().
  *
  * Return value: The #cairo_font_face_t with which @scaled_font was
  * created.
commit c4828666b9b4dad39c3f17fdfd7d1dd3cbb83cbc
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 10 16:45:41 2009 +0100

    [script] Handle translation of compressed strings.
    
    After introducing the new syntax to mark a deflated string, we also need
    to add the equivalent binary tokens.

diff --git a/util/cairo-script/cairo-script-file.c b/util/cairo-script/cairo-script-file.c
index 2a7296d..9ebfdaf 100644
--- a/util/cairo-script/cairo-script-file.c
+++ b/util/cairo-script/cairo-script-file.c
@@ -174,18 +174,16 @@ csi_file_new_from_string (csi_t *ctx,
 	    return _csi_error (CAIRO_STATUS_NO_MEMORY);
 	}
 
-	file->type = BYTES;
-	file->src = tmp_str;
+	file->src  = tmp_str;
 	file->data = tmp_str->string;
-	file->bp   = file->data;
 	file->rem  = tmp_str->len;
     } else {
-	file->type = BYTES;
-	file->src = src; src->base.ref++;
+	file->src  = src; src->base.ref++;
 	file->data = src->string;
-	file->bp   = file->data;
 	file->rem  = src->len;
     }
+    file->type = BYTES;
+    file->bp   = file->data;
 
     obj->type = CSI_OBJECT_TYPE_FILE;
     obj->datum.file = file;
diff --git a/util/cairo-script/cairo-script-scanner.c b/util/cairo-script/cairo-script-scanner.c
index adb6138..587e765 100644
--- a/util/cairo-script/cairo-script-scanner.c
+++ b/util/cairo-script/cairo-script-scanner.c
@@ -678,8 +678,27 @@ scan_read (csi_scanner_t *scan, csi_file_t *src, void *ptr, int len)
     } while (_csi_unlikely (len));
 }
 
+#if WORDS_BIGENDIAN
+#define le16(x) bswap_16 (x)
+#define le32(x) bswap_32 (x)
+#define be16(x) x
+#define be32(x) x
+#define to_be32(x) x
+#else
+#define le16(x) x
+#define le32(x) x
+#define be16(x) bswap_16 (x)
+#define be32(x) bswap_32 (x)
+#define to_be32(x) bswap_32 (x)
+#endif
+
 static void
-string_read (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src, int len, csi_object_t *obj)
+string_read (csi_t *ctx,
+	     csi_scanner_t *scan,
+	     csi_file_t *src,
+	     int len,
+	     int compressed,
+	     csi_object_t *obj)
 {
     csi_status_t status;
 
@@ -687,21 +706,16 @@ string_read (csi_t *ctx, csi_scanner_t *scan, csi_file_t *src, int len, csi_obje
     if (_csi_unlikely (status))
 	longjmp (scan->jmpbuf, status);
 
+    if (compressed) {
+	uint32_t u32;
+	scan_read (scan, src, &u32, 4);
+	obj->datum.string->deflate = be32 (u32);
+    }
+
     scan_read (scan, src, obj->datum.string->string, len);
     obj->datum.string->string[len] = '\0';
 }
 
-#if WORDS_BIGENDIAN
-#define le16(x) bswap_16 (x)
-#define le32(x) bswap_32 (x)
-#define be16(x) x
-#define be32(x) x
-#else
-#define le16(x) x
-#define le32(x) x
-#define be16(x) bswap_16 (x)
-#define be32(x) bswap_32 (x)
-#endif
 static void
 _scan_file (csi_t *ctx, csi_file_t *src)
 {
@@ -845,48 +859,50 @@ scan_none:
 	    break;
 
 #define STRING_1 142
-#define STRING_2_MSB 143
-#define STRING_2_LSB 144
-#define STRING_4_MSB 145
-#define STRING_4_LSB 146
+#define STRING_2_MSB 144
+#define STRING_2_LSB 146
+#define STRING_4_MSB 148
+#define STRING_4_LSB 150
+#define STRING_DEFLATE 1
 	case STRING_1:
+	case STRING_1 | STRING_DEFLATE:
 	    scan_read (scan, src, &u.u8, 1);
-	    string_read (ctx, scan, src, u.u8, &obj);
+	    string_read (ctx, scan, src, u.u8, c & STRING_DEFLATE, &obj);
 	    break;
 	case STRING_2_MSB:
+	case STRING_2_MSB | STRING_DEFLATE:
 	    scan_read (scan, src, &u.u16, 2);
-	    string_read (ctx, scan, src, be16 (u.u16), &obj);
+	    string_read (ctx, scan, src, be16 (u.u16),  c & STRING_DEFLATE, &obj);
 	    break;
 	case STRING_2_LSB:
+	case STRING_2_LSB | STRING_DEFLATE:
 	    scan_read (scan, src, &u.u16, 2);
-	    string_read (ctx, scan, src, le16 (u.u16), &obj);
+	    string_read (ctx, scan, src, le16 (u.u16), c & STRING_DEFLATE, &obj);
 	    break;
 	case STRING_4_MSB:
+	case STRING_4_MSB | STRING_DEFLATE:
 	    scan_read (scan, src, &u.u32, 4);
-	    string_read (ctx, scan, src, be32 (u.u32), &obj);
+	    string_read (ctx, scan, src, be32 (u.u32), c & STRING_DEFLATE, &obj);
 	    break;
 	case STRING_4_LSB:
+	case STRING_4_LSB | STRING_DEFLATE:
 	    scan_read (scan, src, &u.u32, 4);
-	    string_read (ctx, scan, src, le32 (u.u32), &obj);
+	    string_read (ctx, scan, src, le32 (u.u32), c & STRING_DEFLATE, &obj);
 	    break;
 
-	case 147:
+#define OPCODE 152
+	case OPCODE:
 	    scan_read (scan, src, &u.u8, 1);
 	    csi_operator_new (&obj, ctx->opcode[u.u8]);
 	    break;
 
-	case 148:
+	case OPCODE | 1:
 	    scan_read (scan, src, &u.u8, 1);
 	    csi_operator_new (&obj, ctx->opcode[u.u8]);
 	    obj.type &= ~CSI_OBJECT_ATTR_EXECUTABLE;
 	    break;
 
 	    /* unassigned */
-	case 149:
-	case 150:
-	case 151:
-	case 152:
-	case 153:
 	case 154:
 	case 155:
 	case 156:
@@ -1462,11 +1478,18 @@ _translate_string (csi_t *ctx,
 	len = 4;
     }
 #endif
+    if (string->deflate)
+	hdr |= STRING_DEFLATE;
 
     closure->write_func (closure->closure,
 	                 (unsigned char *) &hdr, 1);
     closure->write_func (closure->closure,
 	                 (unsigned char *) &u, len);
+    if (string->deflate) {
+	uint32_t u32 = to_be32 (string->deflate);
+	closure->write_func (closure->closure,
+			     (unsigned char *) &u32, 4);
+    }
     closure->write_func (closure->closure,
 	                 (unsigned char *) string->string, string->len);
 
@@ -1571,7 +1594,7 @@ build_opcodes (csi_t *ctx, csi_dictionary_t **out)
     csi_dictionary_t *dict;
     const csi_operator_def_t *def;
     csi_status_t status;
-    int opcode = 147 << 8;
+    int opcode = OPCODE << 8;
 
     status = csi_dictionary_new (ctx, &obj);
     if (_csi_unlikely (status))


More information about the cairo-commit mailing list