[cairo] error handling

Behdad Esfahbod behdad at behdad.org
Mon May 28 17:28:03 PDT 2007

On Sat, 2007-05-26 at 19:47 -0400, Baz wrote:
> I had a hard-to-find problem today where glyph measurements were
> running unexpectedly fast. The root cause was a misinterpreted error
> from FT_Load_Glyph (FT_Err_Invalid_Argument) being reported as
> CAIRO_STATUS_NO_MEMORY. This made it up as far as the scaled font,
> where it was stored in the status.
> However... the caller was _cairo_gstate_glyph_extents, which just
> returns CAIRO_STATUS_SUCCESS. Is this intentional, or just something
> that needs tidied up? The manual says ' Errors propagate from object
> to object. Setting a pattern in an out-of-memory state as the source
> of a cairo_t puts the type into an error state....Much of the above is
> not yet implemented at the time of this writing' which would suggest
> that its something thats on the list to fix? Or is it considered to
> severe to have a bad glyph stop all drawing?

Hi Baz,

Where does it say so in the manual?  We should remove it as error
handling is pretty much implemented these days.

As for the issue you raise, it has been discussed in the past, in
response to the text-glyph-range test that you added to the test suite.
With the freetype backend that test causes invalid memory accesses with
the PDF backend currently, and is marked XFAIL in the test suite until
we get to clean the mess up.  I tried to do that before a release but it
wasn't quick and easy.

As for the resolution, I believe that an invalid glyph index should not
put a cairo_t (or cairo_scaled_font_t) into an error status.  One way to
make this work may be to change signature of all public functions taking
glyphs to return a cairo_status_t.  We have discussed whether such
changes are allowed in the past and the conclusion was that this is
fine.  So, seems like all that is missing is for someone to go and
implement this.  May as well return a similar error from
cairo_show_text()/cairo_text_path() if no glyph is found for at least
one character in the input text.

> Cheers,
> Baz



"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list