From 6c9e853b93be4c01027e625427787e38be9b99f3 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 3 Feb 2006 02:46:17 +0000 Subject: Finish the 'glyph 0' work of this morning: PANGO_GLYPH_NULL that I 2006-02-02 Behdad Esfahbod 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. --- pango/pangowin32.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'pango/pangowin32.c') diff --git a/pango/pangowin32.c b/pango/pangowin32.c index 77970285..e3af31c7 100644 --- a/pango/pangowin32.c +++ b/pango/pangowin32.c @@ -311,11 +311,12 @@ pango_win32_render (HDC hdc, * point zero (just spacing). */ while (i < glyphs->num_glyphs && - (glyphs->glyphs[i].glyph == PANGO_GLYPH_NULL || cur_y_offset == glyphs->glyphs[i].geometry.y_offset)) + (glyphs->glyphs[i].glyph == PANGO_GLYPH_EMPTY || + cur_y_offset == glyphs->glyphs[i].geometry.y_offset)) { - if (glyphs->glyphs[i].glyph == PANGO_GLYPH_NULL) + if (glyphs->glyphs[i].glyph == PANGO_GLYPH_EMPTY) { - /* PANGO_GLYPH_NULL glyphs should not be rendered, but their + /* PANGO_GLYPH_EMPTY glyphs should not be rendered, but their * indicated width (set up by PangoLayout) should be taken * into account. */ @@ -460,6 +461,15 @@ pango_win32_font_get_glyph_extents (PangoFont *font, MAT2 m = {{0,1}, {0,0}, {0,0}, {0,1}}; PangoWin32GlyphInfo *info; + if (glyph == PANGO_GLYPH_EMPTY) + { + if (ink_rect) + ink_rect->x = ink_rect->width = ink_rect->y = ink_rect->height = 0; + if (logical_rect) + logical_rect->x = logical_rect->width = logical_rect->y = logical_rect->height = 0; + return; + } + if (glyph & PANGO_GLYPH_UNKNOWN_FLAG) glyph_index = glyph = 0; @@ -467,17 +477,7 @@ pango_win32_font_get_glyph_extents (PangoFont *font, if (!info) { - info = g_new (PangoWin32GlyphInfo, 1); - - info->ink_rect.x = 0; - info->ink_rect.width = 0; - info->ink_rect.y = 0; - info->ink_rect.height = 0; - - info->logical_rect.x = 0; - info->logical_rect.width = 0; - info->logical_rect.y = 0; - info->logical_rect.height = 0; + info = g_new0 (PangoWin32GlyphInfo, 1); memset (&gm, 0, sizeof (gm)); @@ -1365,7 +1365,8 @@ font_get_cmap (PangoFont *font) * @font: a #PangoFont. * @wc: a Unicode character. * - * Obtains the index of the glyph for @wc in @font. + * Obtains the index of the glyph for @wc in @font, or 0, if not + * covered. * * Return value: the glyph index for @wc. **/ @@ -1381,7 +1382,7 @@ pango_win32_font_get_glyph_index (PangoFont *font, cmap = font_get_cmap (font); if (cmap == NULL) - return PANGO_GLYPH_NULL; + return 0; if (win32font->win32face->cmap_format == 4) { @@ -1394,10 +1395,10 @@ pango_win32_font_get_glyph_index (PangoFont *font, guint16 ch = wc; if (wc > 0xFFFF) - return PANGO_GLYPH_NULL; + return 0; if (!find_segment (cmap4, ch, &segment)) - return PANGO_GLYPH_NULL; + return 0; id_range_offset = get_id_range_offset (cmap4); id_delta = get_id_delta (cmap4); @@ -1413,7 +1414,7 @@ pango_win32_font_get_glyph_index (PangoFont *font, if (id) glyph = (id_delta[segment] + id) %65536; else - glyph = PANGO_GLYPH_NULL; + glyph = 0; } } else if (win32font->win32face->cmap_format == 12) @@ -1421,7 +1422,7 @@ pango_win32_font_get_glyph_index (PangoFont *font, struct format_12_cmap *cmap12 = cmap; guint32 i; - glyph = PANGO_GLYPH_NULL; + glyph = 0; for (i = 0; i < cmap12->count; i++) { if (cmap12->groups[i*3+0] <= wc && wc <= cmap12->groups[i*3+1]) -- cgit v1.2.1