summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-03-07 18:17:32 +0000
committerNeil Roberts <neil@linux.intel.com>2011-06-10 14:58:04 +0100
commit2ec7f74881f9c6f0b13668564cd2a983edb6838f (patch)
tree9a49e55963fc2bbfc7007d92af2299efd1040171
parent49448d0991a60e239ea80728694daeced8e0664d (diff)
downloadclutter-2ec7f74881f9c6f0b13668564cd2a983edb6838f.tar.gz
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 is backported from commit db954565d4e9ffeb in Cogl master.
-rw-r--r--clutter/cogl/pango/cogl-pango-render.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/clutter/cogl/pango/cogl-pango-render.c b/clutter/cogl/pango/cogl-pango-render.c
index a56c19998..e6b3da366 100644
--- a/clutter/cogl/pango/cogl-pango-render.c
+++ b/clutter/cogl/pango/cogl-pango-render.c
@@ -710,10 +710,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,
@@ -723,14 +720,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