[cairo-commit] cairo/src cairo-cache.c, 1.13, 1.14 cairo-ft-font.c, 1.101, 1.102

Carl Worth commit at pdx.freedesktop.org
Wed Aug 17 09:51:11 PDT 2005


Committed by: cworth

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv23467/src

Modified Files:
	cairo-cache.c cairo-ft-font.c 
Log Message:

2005-08-17  Carl Worth  <cworth at cworth.org>

        Fixes for bug #4110:

        * src/cairo-ft-font.c (_cairo_ft_unscaled_font_init): Don't call
        _cairo_ft_unscaled_font_init_key in the from_face case, just clear
        filename and id instead. Initialize unscaled->base first so that
        initialization order matches the structure declaration order.

        * src/cairo-cache.c (_cairo_hash_string): Fix to accept a NULL
        string and hash it identically to a zero-length string.

        * test/Makefile.am:
        * test/ft-font-create-for-ft-face: Add a test that calls
        cairo_ft_font_create_for_ft_face to demonstrate bug #4110.


Index: cairo-cache.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-cache.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- cairo-cache.c	26 Jun 2005 06:24:19 -0000	1.13
+++ cairo-cache.c	17 Aug 2005 16:51:09 -0000	1.14
@@ -512,7 +512,7 @@
 {
     /* This is the djb2 hash. */
     unsigned long hash = 5381;
-    while (*c)
+    while (c && *c)
 	hash = ((hash << 5) + hash) + *c++;
     return hash;
 }

Index: cairo-ft-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ft-font.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- cairo-ft-font.c	15 Aug 2005 02:25:05 -0000	1.101
+++ cairo-ft-font.c	17 Aug 2005 16:51:09 -0000	1.102
@@ -290,22 +290,25 @@
 			      int			id,
 			      FT_Face			face)
 {
-    char *filename_copy = NULL;
-
-    if (filename) {
-	filename_copy = strdup (filename);
-	if (filename_copy == NULL)
-	    return CAIRO_STATUS_NO_MEMORY;
-    }
-
-    _cairo_ft_unscaled_font_init_key (unscaled, filename_copy, id);
+    _cairo_unscaled_font_init (&unscaled->base,
+			       &cairo_ft_unscaled_font_backend);
 
     if (face) {
-	unscaled->from_face = 1;
+	unscaled->from_face = TRUE;
 	unscaled->face = face;
+	unscaled->filename = NULL;
+	unscaled->id = 0;
     } else {
-	unscaled->from_face = 0;
+	char *filename_copy;
+
+	unscaled->from_face = FALSE;
 	unscaled->face = NULL;
+
+	filename_copy = strdup (filename);
+	if (filename_copy == NULL)
+	    return CAIRO_STATUS_NO_MEMORY;
+
+	_cairo_ft_unscaled_font_init_key (unscaled, filename_copy, id);
     }
 
     unscaled->have_scale = 0;
@@ -313,9 +316,6 @@
     
     unscaled->faces = NULL;
 
-    _cairo_unscaled_font_init (&unscaled->base,
-			       &cairo_ft_unscaled_font_backend);
-
     return CAIRO_STATUS_SUCCESS;
 }
 



More information about the cairo-commit mailing list