summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-06-10 14:03:50 +0100
committerNeil Roberts <neil@linux.intel.com>2011-06-10 14:03:50 +0100
commitdb954565d4e9ffeb848a1b1554f1ed568a29b55f (patch)
tree1a8d1d8e666190f10928ff0bb5e2f30ded767977
parentabb3631e71c47e8491e036bc5fbe5b7ed960e7a4 (diff)
downloadcogl-db954565d4e9ffeb848a1b1554f1ed568a29b55f.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
-rw-r--r--cogl-pango/cogl-pango-render.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/cogl-pango/cogl-pango-render.c b/cogl-pango/cogl-pango-render.c
index 091334ac..5c127418 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