cogl-pango-render: Use the glyph size for unknown glyphs

When rendering a box for an unknown glyph it would previously just use
the average glyph size for the font. This causes problems because the
size calculations for the layout assume a different size so it can end
up rendering outside of the expected ink rectangle. This patch changes
it to query the size of the glyph in the font. Pango should end up
reporting the size of what would be the hex box which should be the
same as the sized used for the extents calculation.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2599
This commit is contained in:
Neil Roberts 2011-06-10 14:03:50 +01:00
parent abb3631e71
commit db954565d4

View File

@ -788,10 +788,7 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
if ((gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG))
{
PangoFontMetrics *metrics;
if (font == NULL ||
(metrics = pango_font_get_metrics (font, NULL)) == NULL)
if (font == NULL)
{
cogl_pango_renderer_draw_box (renderer,
x,
@ -801,14 +798,16 @@ cogl_pango_renderer_draw_glyphs (PangoRenderer *renderer,
}
else
{
cogl_pango_renderer_draw_box (renderer,
x,
y,
metrics->approximate_char_width
/ PANGO_SCALE,
metrics->ascent / PANGO_SCALE);
PangoRectangle ink_rect;
pango_font_metrics_unref (metrics);
pango_font_get_glyph_extents (font, gi->glyph, &ink_rect, NULL);
pango_extents_to_pixels (&ink_rect, NULL);
cogl_pango_renderer_draw_box (renderer,
x + ink_rect.x,
y + ink_rect.y + ink_rect.height,
ink_rect.width,
ink_rect.height);
}
}
else