[clutter/clutter-1.6] cogl-pango-render: Use the glyph size for unknown glyphs
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.6] cogl-pango-render: Use the glyph size for unknown glyphs
- Date: Fri, 10 Jun 2011 14:30:36 +0000 (UTC)
commit 2ec7f74881f9c6f0b13668564cd2a983edb6838f
Author: Neil Roberts <neil linux intel com>
Date: Mon Mar 7 18:17:32 2011 +0000
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.
clutter/cogl/pango/cogl-pango-render.c | 21 ++++++++++-----------
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 a56c199..e6b3da3 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]