[cairo-commit] src/cairo-ft-font.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Sep 17 17:56:07 PDT 2007


 src/cairo-ft-font.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
diff-tree 79d975f84bcc32e91db517d71a7312e2e1d653d4 (from 21ab44f11d3d20eead5d988c7a6cf48eebff08c7)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Sep 12 17:45:11 2007 -0400

    [cairo-ft-font] Ignore FT_Load_Glyph errors other than out-of-memory
    Same for FT_Render_Glyph.
    
    When the user asks us to render a glyph that is not available in the font,
    it's mostly an unavoidable kind of error for them, as in, they can't
    avoid such a call.  So it's not nice to put cairo_t in an error state and
    refuse any further drawying.
    
    Many PDF files are created using buggy software and cause such glpyh-not-found
    errors for CID 0 for example.
    
    Eventually we should propagate these kind of errors up and return it from
    the function call causing it, but that needs API change to add return value
    to all text functions, so for now we just ignore these errors.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 8136502..0161dae 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -1092,7 +1092,9 @@ _render_glyph_bitmap (FT_Face		      fac
      * we avoid the FT_LOAD_NO_RECURSE flag.
      */
     error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
-    if (error) {
+    /* XXX ignoring all other errors for now.  They are not fatal, typically
+     * just a glyph-not-found. */
+    if (error == FT_Err_Out_Of_Memory) {
 	_cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return CAIRO_STATUS_NO_MEMORY;
     }
@@ -1887,8 +1889,9 @@ _cairo_ft_scaled_glyph_init (void			*abs
     error = FT_Load_Glyph (scaled_font->unscaled->face,
 			   _cairo_scaled_glyph_index(scaled_glyph),
 			   load_flags);
-
-    if (error) {
+    /* XXX ignoring all other errors for now.  They are not fatal, typically
+     * just a glyph-not-found. */
+    if (error == FT_Err_Out_Of_Memory) {
 	status = CAIRO_STATUS_NO_MEMORY;
 	goto FAIL;
     }
@@ -2038,8 +2041,9 @@ _cairo_ft_scaled_glyph_init (void			*abs
 	    error = FT_Load_Glyph (face,
 				   _cairo_scaled_glyph_index(scaled_glyph),
 				   load_flags | FT_LOAD_NO_BITMAP);
-
-	    if (error) {
+	    /* XXX ignoring all other errors for now.  They are not fatal, typically
+	     * just a glyph-not-found. */
+	    if (error == FT_Err_Out_Of_Memory) {
 		_cairo_ft_unscaled_font_unlock_face (unscaled);
 		_cairo_error (CAIRO_STATUS_NO_MEMORY);
 		return CAIRO_STATUS_NO_MEMORY;


More information about the cairo-commit mailing list