[cairo] Patch for cairo-win32-font.c, when GetTextMetrics fails

Patrick Fritzsch Patrick.Fritzsch at cib.de
Mon Nov 9 07:18:17 PST 2015


Hello,

attached is a patch for cairo-win32-font.c, which fixed an issue with a problematic font on windows I had during printing a pdf document on cairo (not using poppler).

Problem:
Cairo uses the winapi GetTextMetrics function, but didn’t check, if the function succeeded. See
https://msdn.microsoft.com/de-de/library/windows/desktop/dd144941(v=vs.85).aspx – it can fail.

If the function fails, windows doesn’t fill the struct, which was given to GetTextMetrics and its values are kept uninitialized – so cairo went depending on a random effect into different parts of code afterwards (symbol fonts / non symbol fonts) and didn’t make a clean error.

Because the font, which fails for GetTextMetrics function, is from a customer document and I don’t have the right to provide the stuff to the outside, I cannot supply it to this list. But it is a reduced truetype font, which contains only a .notdef glyph and one additional glyph, which doesn’t have any contours, mapped to a space.

Question:
When Cairo fails internally for any reason it set sets an error code inside the context – and all content later, which i want to output on this context isn’t processed anymore. In above case it works, that I ignore that error-setting and process the rest of the document.
So how can I achieve, that when I left the erroneous state inside the context, that it works again? I miss something like a cairo_reset_error function.


Best regards,

Patrick


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20151109/04f80227/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-win32-font.patch
Type: application/octet-stream
Size: 901 bytes
Desc: cairo-win32-font.patch
URL: <http://lists.cairographics.org/archives/cairo/attachments/20151109/04f80227/attachment-0001.obj>


More information about the cairo mailing list