[cairo] Surface error not set when using cairo_show_text() with invalid utf8
cairouser at yahoo.com
Thu Nov 4 06:12:09 PDT 2010
Andrea Canciani wrote:
> 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).
Attached. When I run this program, both cairo_t and surface status are
returned as 0, but drawing cannot proceed.
cairo-1.9.8 on MacOS 10.6
> 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)?
Indeed, destroying cairo_t and recreating it allows me to continue
1. As I mention, there is no warning - status remains 0
2. Destroying cairo_t is not really possible in my code without
significant refactoring (surface is not exposed to rendering functions)
Honestly, this underscores in my view that the error is not handled in
the best possible way:
1. If it can be "ignored" by simply dropping and re-creating cairo_t -
what's the point of making this a permanent error?
2. The error is "artificially" permanent - it occurs because cairo utf8
validity checker says "string is bad". There is no faulty state or
unrecoverable issue that really prevents further drawing. In fact, a
return with a different status from one of intermediate functions
(without setting surface status to "bad") would be all that's necessary.
3. Finally, *requiring* duplication of functionality seems wrong to me.
Either caller has to check utf8 (and then cairo must draw what is given
to it as best it can) or cairo checks utf8 and then must report the
error without breaking the rest of the drawing (i.e. simply reporting -
"bad utf8"), then user can call again with a different string.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the cairo