[cairo-commit] 2 commits - src/cairo-ft-font.c src/cairo-scaled-font-subsets.c

Chris Wilson ickle at kemper.freedesktop.org
Fri May 25 04:39:47 PDT 2007


 src/cairo-ft-font.c             |   15 +++++++++++----
 src/cairo-scaled-font-subsets.c |    4 ++++
 2 files changed, 15 insertions(+), 4 deletions(-)

New commits:
diff-tree 5b2b008048d2bcbb0b558a6c02aee1093311db39 (from c175cf7b833b03c38c8ddea183333ce84c6fdfec)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri May 11 10:14:57 2007 +0100

    [cairo-scaled-font-subsets] Shortcut empty subset.
    
    If the font_subset if empty, avoid allocating zero bytes and iterating
    over the empty hash table.

diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index b327963..65b1cdc 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -618,6 +618,10 @@ _cairo_scaled_font_subsets_foreach_inter
         collection.glyphs_size = font_subsets->max_glyphs_per_scaled_subset_used;
     else
         collection.glyphs_size = font_subsets->max_glyphs_per_unscaled_subset_used;
+
+    if (! collection.glyphs_size)
+	return CAIRO_STATUS_SUCCESS;
+
     collection.glyphs = malloc (collection.glyphs_size * sizeof(unsigned long));
     if (collection.glyphs == NULL)
 	return CAIRO_STATUS_NO_MEMORY;
diff-tree c175cf7b833b03c38c8ddea183333ce84c6fdfec (from f382c3e110f8078e83cbb9d73cfbb43b1506a11b)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu May 17 17:04:14 2007 +0100

    [cairo-ft-font] Remove erroneous cached font faces.
    
    Only return a font face from the cache if it is not in an error condition.
    Otherwise unlink the bad font face from the cache and construct a new one.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 6e23963..23dbf4f 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2221,17 +2221,24 @@ static cairo_font_face_t *
 _cairo_ft_font_face_create (cairo_ft_unscaled_font_t *unscaled,
 			    cairo_ft_options_t	     *ft_options)
 {
-    cairo_ft_font_face_t *font_face;
+    cairo_ft_font_face_t *font_face, **prev_font_face;
 
     /* Looked for an existing matching font face */
-    for (font_face = unscaled->faces;
+    for (font_face = unscaled->faces, prev_font_face = &unscaled->faces;
 	 font_face;
-	 font_face = font_face->next)
+	 prev_font_face = &font_face->next, font_face = font_face->next)
     {
 	if (font_face->ft_options.load_flags == ft_options->load_flags &&
 	    font_face->ft_options.extra_flags == ft_options->extra_flags &&
 	    cairo_font_options_equal (&font_face->ft_options.base, &ft_options->base))
-	    return cairo_font_face_reference (&font_face->base);
+	{
+	    if (! font_face->base.status)
+		return cairo_font_face_reference (&font_face->base);
+
+	    /* The font_face has been left in an error state, abandon it. */
+	    *prev_font_face = font_face->next;
+	    break;
+	}
     }
 
     /* No match found, create a new one */


More information about the cairo-commit mailing list