When attempting to linearly scale a PangoLayout, some font backends do not report correct logical extents
Submitted by Andrew Cowie
Link to original bug (#566488)
Description
A problem that occurs when you use Cairo to linearly scale a Context that you are drawing to with pango_cairo_show_layout(): the height reported in the logical PangoRectangle from pango_layout_line_get_extents() are wrong, as is the word wrapping done in the PangoLayout.
I've prepared a C program that hopefully demonstrates the issue.
I finally tracked it down to calling pango_layout_get_baseline(). I had been calling it before I set any text into the PangoLayout (which is hopefully no shock; you need that for an initial depth before looping over a series of paragraphs).
So it would seem that one bug is that an entire PangoLayout gets screwed if pango_layout_get_baseline() is called on an empty PangoLayout; the workaround in both this test program and in the java-gnome code where this was first noticed was:
pango_layout_set_text(layout, "Hello"); b = pango_layout_get_baseline();
But there's more, and worse:
Serkan Kaba duplicated this bug for me. However, getting it to appear for him was difficult, because...
He didn't have the Liberation font family installed. So whatever his system was falling back to did work. We installed Liberation on his system, and then the bug appeared. Which makes me think that the real problem is in one or more of the Font rendering backends, but that's just speculation on my part.
I tried changing the font description string on the program on my system, and:
"Liberation Serif, 12" - extents borked "Bitstream Vera Sans, 12" - extents borked "Serif, 12" - extents CORRECT!
So what the hell? But if this program works for you, trying playing with the specified font.
AfC
Version: 1.22.x