[cairo] Surface error not set when using cairo_show_text() with invalid utf8

Andrea Canciani ranma42 at gmail.com
Wed Nov 3 11:42:34 PDT 2010

On Mon, Nov 1, 2010 at 7:31 PM, cu <cairouser at yahoo.com> wrote:
> As the subject says,  looks like cairo_show_text() does not set the
> surface error (to be queried later by cairo_surface_status()) when
> provided invalid utf8 input (doesn't matter what it is - just has to be
> something that can't be properly decoded). Surface will not allow any
> more operations (i.e. any subsequent drawing is discarded) but at the
> same time status is still reported as "success". This is tested with
> cairo 1.9.8.

Could you please provide a test program?

I tried to reproduce your problem, but the error was reported (through the
status of the cairo context I'm using for the drawing operations).

> Ideally I would prefer that surface would continue working after this
> error (since the error is in external data and seems to be caught early
> by utf8 validation function  _cairo_utf8_to_ucs4). But at a very least,
> surface that can no longer be drawn into should be properly marked as such.

In my test program the error only affected the cairo_t. The surface status
was not affected, so destroying the cairo_t and creating it again on the same
surface would allow drawing operations to resume.

Can you confirm whether you're seeing the same behavior?
Does this solve your problem (getting warned about the error and being able to
continue drawing)?


PS: I only tried a trivial test with a string that only contained
invalid characters,
but skimming through the code I would suppose that the whole string is validated
by cairo before being drawn, so you should be able to resume drawing from a
well-known point.

More information about the cairo mailing list