summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2005-05-16 18:00:22 +0000
committerOwen Taylor <otaylor@src.gnome.org>2005-05-16 18:00:22 +0000
commita1d091f8b9fa18792c6d989a5eb7c8bad1c87258 (patch)
tree07faa7897569c0196b7774af26a5fdfdbdfd92b6 /pango
parent774df2fe97bc6180fe55659ccff10c349976a022 (diff)
downloadpango-a1d091f8b9fa18792c6d989a5eb7c8bad1c87258.tar.gz
pango/pangocairo-render.c (pango_cairo_renderer_draw_glyphs): Handle glyph
2005-05-16 Owen Taylor <otaylor@redhat.com> * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_glyph_extents): pango/pangocairo-render.c (pango_cairo_renderer_draw_glyphs): Handle glyph == 0. * modules/indic/indic-ot.h modules/basic/basic-common.h: Treat LINE SEPARATOR as a zero-width character.
Diffstat (limited to 'pango')
-rw-r--r--pango/pangocairo-fcfont.c55
-rw-r--r--pango/pangocairo-render.c18
2 files changed, 48 insertions, 25 deletions
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index f14e8e9a..cde571bf 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -152,40 +152,57 @@ pango_cairo_fc_font_get_glyph_extents (PangoFont *font,
PangoRectangle *logical_rect)
{
cairo_scaled_font_t *scaled_font;
- cairo_text_extents_t extents;
- cairo_glyph_t cairo_glyph;
scaled_font = pango_cairo_fc_font_get_scaled_font (PANGO_CAIRO_FONT (font));
- cairo_glyph.index = glyph;
- cairo_glyph.x = 0;
- cairo_glyph.y = 0;
-
- cairo_scaled_font_glyph_extents (scaled_font,
- &cairo_glyph, 1, &extents);
-
- if (ink_rect)
- {
- ink_rect->x = extents.x_bearing * PANGO_SCALE;
- ink_rect->y = extents.y_bearing * PANGO_SCALE;
- ink_rect->width = extents.width * PANGO_SCALE;
- ink_rect->height = extents.height * PANGO_SCALE;
- }
-
if (logical_rect)
{
/* It may well be worth caching the font_extents here, since getting them
* is pretty expensive.
*/
cairo_font_extents_t font_extents;
-
+
cairo_scaled_font_extents (scaled_font, &font_extents);
logical_rect->x = 0;
logical_rect->y = - font_extents.ascent * PANGO_SCALE;
- logical_rect->width = extents.x_advance * PANGO_SCALE;
+ logical_rect->width = 0;
logical_rect->height = (font_extents.ascent + font_extents.descent) * PANGO_SCALE;
}
+
+ if (glyph)
+ {
+ cairo_text_extents_t extents;
+ cairo_glyph_t cairo_glyph;
+
+ cairo_glyph.index = glyph;
+ cairo_glyph.x = 0;
+ cairo_glyph.y = 0;
+
+ cairo_scaled_font_glyph_extents (scaled_font,
+ &cairo_glyph, 1, &extents);
+
+ if (ink_rect)
+ {
+ ink_rect->x = extents.x_bearing * PANGO_SCALE;
+ ink_rect->y = extents.y_bearing * PANGO_SCALE;
+ ink_rect->width = extents.width * PANGO_SCALE;
+ ink_rect->height = extents.height * PANGO_SCALE;
+ }
+
+ if (logical_rect)
+ logical_rect->width = extents.x_advance * PANGO_SCALE;
+ }
+ else
+ {
+ if (ink_rect)
+ {
+ ink_rect->x = 0;
+ ink_rect->y = 0;
+ ink_rect->width = 0;
+ ink_rect->height = 0;
+ }
+ }
}
static FT_Face
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index 9a1048ce..68ae4981 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -68,7 +68,7 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
/* cairo_glyph_t is 24 bytes */
#define MAX_STACK 40
- int i;
+ int i, count;
int x_position = 0;
cairo_glyph_t *cairo_glyphs;
cairo_glyph_t stack_glyphs[MAX_STACK];
@@ -85,23 +85,29 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
else
cairo_glyphs = stack_glyphs;
+ count = 0;
for (i = 0; i < glyphs->num_glyphs; i++)
{
PangoGlyphInfo *gi = &glyphs->glyphs[i];
- cairo_glyphs[i].index = gi->glyph;
- cairo_glyphs[i].x = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
- cairo_glyphs[i].y = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+ if (gi->glyph)
+ {
+ cairo_glyphs[count].index = gi->glyph;
+ cairo_glyphs[count].x = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
+ cairo_glyphs[count].y = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+ count++;
+ }
+
x_position += gi->geometry.width;
}
_pango_cairo_font_install (PANGO_CAIRO_FONT (font), crenderer->cr);
if (crenderer->do_path)
- cairo_glyph_path (crenderer->cr, cairo_glyphs, glyphs->num_glyphs);
+ cairo_glyph_path (crenderer->cr, cairo_glyphs, count);
else
- cairo_show_glyphs (crenderer->cr, cairo_glyphs, glyphs->num_glyphs);
+ cairo_show_glyphs (crenderer->cr, cairo_glyphs, count);
if (glyphs->num_glyphs > MAX_STACK)
g_free (cairo_glyphs);