diagrams/diagrams-cairo

Mac OS X/XQuartz: Can't render single letter

jonashaag opened this issue · 5 comments

I have a very strange issue with XQuartz on OS X (Mavericks).

I can render stuff like text "foo" just fine, but text "f" crashes with

Assertion failed: (!scaled_font->cache_frozen), function _cairo_scaled_glyph_page_destroy,
file cairo-scaled-font.c, line 459.

I traced this down to being an issue with what C.textExtents returns. If I patch the code so that it never calls textExtents on a string of length 1, it works fine.

Code used to debug: https://gist.github.com/jonashaag/8761779

-- Original code when given string of length 1
TextExtents {textExtentsXbearing = 0.0, textExtentsYbearing = -1.0, textExtentsWidth = 1.0,
textExtentsHeight = 1.0, textExtentsXadvance = 1.0, textExtentsYadvance = 0.0}

-- Patched code when given string of length 1, simply makes it a string of length 2
TextExtents {textExtentsXbearing = 0.0, textExtentsYbearing = -1.0, textExtentsWidth = 2.0,
textExtentsHeight = 1.0, textExtentsXadvance = 2.0, textExtentsYadvance = 0.0}

I'm not sure if this is a bug in the Diagrams Cairo backend or some other problem with XQuartz, Cairo, ... you name it. I'm happy for any pointers :)

I hear that we should replace all of our text handling in the Cairo Backend with Pango. See, for example, #19 for more bizarreness.

Ugh. Unfortunately, as @bergey says, this is most likely a bug in cairo, and moreover, the documentation is quite explicit that the text API we are using is just a "toy" and that no one is likely to put any effort into fixing it. We need someone to take on porting the text handling to pango as a project --- though I am not sure how much effort it will be.

Agreed, the cairo based text api should either be deprecated or replaced in favor of pango.

@mgsloan: see #49 which just got merged!

Cool, good stuff @bergey!