From 1ea1fadf7ec53fcd27b8ed8acd655d913e72e091 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 12 Sep 2007 17:45:11 -0400 Subject: [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. (cherry picked from commit 79d975f84bcc32e91db517d71a7312e2e1d653d4) --- src/cairo-ft-font.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 69e35d25e..d8bb64ac6 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -1091,7 +1091,9 @@ _render_glyph_bitmap (FT_Face face, * 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; } @@ -1885,8 +1887,9 @@ _cairo_ft_scaled_glyph_init (void *abstract_font, 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; } @@ -2036,8 +2039,9 @@ _cairo_ft_scaled_glyph_init (void *abstract_font, 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; -- cgit v1.2.3