Bug 22356 - Spurious "out of memory" error on system without fonts
Summary: Spurious "out of memory" error on system without fonts
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: freetype font backend (show other bugs)
Version: 1.8.8
Hardware: x86 (IA32) FreeBSD
: medium trivial
Assignee: David Turner
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-18 18:00 UTC by Ben Bullock
Modified: 2009-06-19 03:25 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Ben Bullock 2009-06-18 18:00:21 UTC
If Cairo tries to write text on a system without any fonts installed, it produces an "out of memory" error.

I installed Cairo on a minimal FreeBSD jail without fonts and tried to use cairo_show_text to write some text (this was a mistake, obviously). The text didn't appear and Cairo stopped drawing anything at all after the text. I checked what was happening using the "cairo_status" of the "cairo_t" and found it had an "out of memory" error. Since I was running the program OK on the same system outside the jail, I was sure there was no problem with memory.

Stepping through the program with a debugger, I found that the "out of memory" error was produced when cairo called "FcFontMatch" on line 1697 of cairo-ft-font.c.
Comment 1 Chris Wilson 2009-06-19 03:25:00 UTC
Thanks for the bug report, it reminded that one of the arguments for including a builtin font was precisely so we could fallback and always show text (even if it was completely the wrong font!)

The fix is relatively easy for 1.9, but requires a fair bit more backporting for 1.8. I'm not sure the necessity justifies the extra risk.

commit d3330d7beba0e0d2543e40a0e0e4d81ea9a78b45
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Jun 19 11:15:30 2009 +0100

    [ft] Substitute twin if there are no fonts
    
    Fixes bug 22356 -- Spurious "out of memory" error on system without fonts
    https://bugs.freedesktop.org/show_bug.cgi?id=22356
    
    If FcFontMatch() fails, then it means that there are no fonts available on
    the system (or it may have been a malloc error, we have no way of telling).
    Instead of report NO_MEMORY and disabling all drawing, one of the
    rationales for including a builtin font was so that we could continue even
    in the face of this error and show *something* to the user. (This being a
    last resort (and especially important for demos!) and hopefully easier to
    diagnose than no output at all.)



Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.