[cogl] cogl-pango-render: Use the glyph size for unknown glyphs
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-pango-render: Use the glyph size for unknown glyphs
- Date: Fri, 10 Jun 2011 13:41:44 +0000 (UTC)
commit db954565d4e9ffeb848a1b1554f1ed568a29b55f
Author: Neil Roberts <neil linux intel com>
Date: Fri Jun 10 14:03:50 2011 +0100
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
cogl-pango/cogl-pango-render.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/cogl-pango/cogl-pango-render.c b/cogl-pango/cogl-pango-render.c
index 091334a..5c12741 100644
--- a/cogl-pango/cogl-pango-render.c
+++ b/cogl-pango/cogl-pango-render.c
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]