summaryrefslogtreecommitdiff
path: root/pango/pangocairo-render.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-02-03 02:46:17 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-02-03 02:46:17 +0000
commit6c9e853b93be4c01027e625427787e38be9b99f3 (patch)
tree9b1f07249ff96f43ce9f8af61613e067e0e1ea74 /pango/pangocairo-render.c
parentb1e264aa208e43a3d98aa2f985a0eaafdb328bb8 (diff)
downloadpango-6c9e853b93be4c01027e625427787e38be9b99f3.tar.gz
Finish the 'glyph 0' work of this morning: PANGO_GLYPH_NULL that I
2006-02-02 Behdad Esfahbod <behdad@gnome.org> Finish the 'glyph 0' work of this morning: PANGO_GLYPH_NULL that I introduced is renamed to PANGO_GLYPH_EMPTY. It means, no rendering should be performed. The backends however, still return 0 if a glyph is not found. The modules then are free to replace this 0 glyph with an unknown character. * modules/arabic/arabic-fc.c, modules/basic/basic-atsui.c, modules/basic/basic-fc.c, modules/basic/basic-win32.c, modules/basic/basic-x.c, modules/hangul/hangul-fc.c, modules/hebrew/hebrew-fc.c, modules/indic/indic-fc.c, modules/khmer/khmer-fc.c, modules/syriac/syriac-fc.c, modules/thai/thai-fc.c, modules/tibetan/tibetan-fc.c, pango/pangox.c, pango/pangowin32.c: Adapt to above change. Backends return 0 if glyph not found. * pango/fonts.c (pango_font_get_glyph_extents): If font is not usable (!PANGO_IS_FONT (font)), return the generic UNKNOWN_GLYPH metrics. This is used when your backends are misconfigured and you don't find *any* font at all. * pango/pango-engince.c: Add unknown glyphs in fallback shaper, instead of empty glyphs. * pango/shape.c: Call the fall-back shaper if shaper fails, instead of generating a dummy glyph string ourselves. * pango/pango-layout.c (imposed_shape, shape_tab): Use PANGO_GLYPH_EMPTY instead of glyph 0. * pango/pango-renderer.c (pango_renderer_draw_glyph): No-op on PANGO_GLYPH_EMPTY instead of glyph 0. * pango/pangocairo-atsuifont.c, pango/pangocairo-win32font.c, pango/pangocairo-fcfont.c, pango/pangocairo-font.c, pango/pangocairo-private.h: install_font returns a boolean now. * pango/pangocairo-render.c, pango/pangoxft-render.c: Handle font and hex-box failures more gracefully by drawing a generic unknown-box glyph. * pango/pangoft2.c, pango/pangoft2-render.c: Draw the generic unknown-box glyph here too. For unknown glyphs though, if the font is TTF (FT_IS_SFNT), use the zero-indexed glyph, otherwise, draw a box of proper size.
Diffstat (limited to 'pango/pangocairo-render.c')
-rw-r--r--pango/pangocairo-render.c81
1 files changed, 59 insertions, 22 deletions
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index 5a902ad8..08a58def 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -59,6 +59,33 @@ set_color (PangoCairoRenderer *crenderer,
}
static void
+_pango_cairo_renderer_draw_box_glyph (PangoCairoRenderer *crenderer,
+ PangoGlyphInfo *gi,
+ double cx,
+ double cy)
+{
+ double temp_x, temp_y;
+
+ cairo_save (crenderer->cr);
+ cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
+
+ cairo_rectangle (crenderer->cr,
+ cx + 1.5,
+ cy + 1.5 - PANGO_UNKNOWN_GLYPH_HEIGHT,
+ (double)gi->geometry.width / PANGO_SCALE - 3.0,
+ PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0);
+
+ if (!crenderer->do_path)
+ {
+ cairo_set_line_width (crenderer->cr, 1.0);
+ cairo_stroke (crenderer->cr);
+ }
+
+ cairo_move_to (crenderer->cr, temp_x, temp_y);
+ cairo_restore (crenderer->cr);
+}
+
+static void
_pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
PangoFont *font,
PangoGlyphInfo *gi,
@@ -78,20 +105,10 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
cairo_get_current_point (crenderer->cr, &temp_x, &temp_y);
hbi = _pango_cairo_font_get_hex_box_info ((PangoCairoFont *)font);
- if (!hbi)
- {
- cairo_rectangle (crenderer->cr,
- cx + 1.5,
- cy - 1.5,
- (double)gi->geometry.width / PANGO_SCALE - 3.0,
- PANGO_UNKNOWN_GLYPH_HEIGHT - 3.0);
-
- if (!crenderer->do_path)
- {
- cairo_set_line_width (crenderer->cr, 1.0);
- cairo_stroke (crenderer->cr);
- }
+ if (!hbi || !_pango_cairo_font_install (PANGO_CAIRO_FONT (hbi->font), crenderer->cr))
+ {
+ _pango_cairo_renderer_draw_box_glyph (crenderer, gi, cx, cy);
goto done;
}
@@ -103,9 +120,9 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
cairo_rectangle (crenderer->cr,
cx + hbi->pad_x * 1.5,
- cy + hbi->box_descent - hbi->pad_y * 0.5,
+ cy + hbi->box_descent - hbi->box_height + hbi->pad_y * 0.5,
(double)gi->geometry.width / PANGO_SCALE - 3 * hbi->pad_x,
- -(hbi->box_height - hbi->pad_y));
+ (hbi->box_height - hbi->pad_y));
if (!crenderer->do_path)
{
@@ -113,8 +130,6 @@ _pango_cairo_renderer_draw_unknown_glyph (PangoCairoRenderer *crenderer,
cairo_stroke (crenderer->cr);
}
- _pango_cairo_font_install (PANGO_CAIRO_FONT (hbi->font), crenderer->cr);
-
x0 = cx + hbi->pad_x * 3.0;
y0 = cy + hbi->box_descent - hbi->pad_y * 2;
@@ -165,6 +180,27 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
set_color (crenderer, PANGO_RENDER_PART_FOREGROUND);
}
+ if (!_pango_cairo_font_install (PANGO_CAIRO_FONT (font), crenderer->cr))
+ {
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ {
+ PangoGlyphInfo *gi = &glyphs->glyphs[i];
+
+ if (gi->glyph != PANGO_GLYPH_EMPTY)
+ {
+ double cx = crenderer->x_offset +
+ (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
+ double cy = crenderer->y_offset +
+ (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+
+ _pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
+ }
+ x_position += gi->geometry.width;
+ }
+
+ goto done;
+ }
+
if (glyphs->num_glyphs > MAX_STACK)
cairo_glyphs = g_new (cairo_glyph_t, glyphs->num_glyphs);
else
@@ -175,10 +211,12 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
{
PangoGlyphInfo *gi = &glyphs->glyphs[i];
- if (gi->glyph != PANGO_GLYPH_NULL)
+ if (gi->glyph != PANGO_GLYPH_EMPTY)
{
- double cx = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
- double cy = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
+ double cx = crenderer->x_offset +
+ (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE;
+ double cy = crenderer->y_offset +
+ (double)(y + gi->geometry.y_offset) / PANGO_SCALE;
if (gi->glyph & PANGO_GLYPH_UNKNOWN_FLAG)
_pango_cairo_renderer_draw_unknown_glyph (crenderer, font, gi, cx, cy);
@@ -193,8 +231,6 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
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, count);
else
@@ -203,6 +239,7 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer,
if (glyphs->num_glyphs > MAX_STACK)
g_free (cairo_glyphs);
+done:
if (!crenderer->do_path)
cairo_restore (crenderer->cr);