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. --- modules/arabic/arabic-fc.c | 6 +++--- modules/basic/basic-atsui.c | 2 +- modules/basic/basic-fc.c | 6 +++--- modules/basic/basic-win32.c | 4 ++-- modules/basic/basic-x.c | 8 ++++---- modules/hangul/hangul-fc.c | 34 +++++++++++++++++----------------- modules/hebrew/hebrew-fc.c | 4 ++-- modules/indic/indic-fc.c | 9 ++++----- modules/khmer/khmer-fc.c | 2 +- modules/syriac/syriac-fc.c | 6 +++--- modules/thai/thai-fc.c | 2 +- modules/tibetan/tibetan-fc.c | 2 +- 12 files changed, 42 insertions(+), 43 deletions(-) (limited to 'modules') diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c index 84663d45..355646a7 100644 --- a/modules/arabic/arabic-fc.c +++ b/modules/arabic/arabic-fc.c @@ -209,13 +209,13 @@ fallback_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) index = pango_fc_font_get_unknown_glyph (fc_font, wc); set_glyph (font, glyphs, i, p - text, index); @@ -317,7 +317,7 @@ arabic_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) /* Zero-width characters */ { - pango_ot_buffer_add_glyph (buffer, 0, properties[i], p - text); + pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, properties[i], p - text); } else { diff --git a/modules/basic/basic-atsui.c b/modules/basic/basic-atsui.c index 72d83db4..b394102c 100644 --- a/modules/basic/basic-atsui.c +++ b/modules/basic/basic-atsui.c @@ -160,7 +160,7 @@ basic_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index f73f1a56..5b8d90bf 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -166,13 +166,13 @@ fallback_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) { index = pango_fc_font_get_unknown_glyph (fc_font, wc); set_glyph (font, glyphs, i, p - text, index); @@ -382,7 +382,7 @@ basic_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) /* Zero-width characters */ { - pango_ot_buffer_add_glyph (buffer, 0, unknown_property, p - text); + pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, unknown_property, p - text); } else { diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 433eb21a..2b6c6017 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -1003,12 +1003,12 @@ basic_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { index = find_char (font, wc); - if (index != PANGO_GLYPH_NULL) + if (index) { set_glyph (font, glyphs, i, p - text, index); diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c index 1e0a66a0..ffd07329 100644 --- a/modules/basic/basic-x.c +++ b/modules/basic/basic-x.c @@ -284,7 +284,7 @@ find_char (CharCache *cache, PangoFont *font, gunichar wc, const char *input) } } - return PANGO_GLYPH_NULL; + return 0; } static void @@ -610,12 +610,12 @@ basic_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { index = find_char (cache, font, wc, input); - if (index != PANGO_GLYPH_NULL) + if (index) { set_glyph (font, glyphs, i, p - text, index); @@ -680,7 +680,7 @@ basic_engine_covers (PangoEngineShape *engine, g_unichar_to_utf8 (wc, buf); - return find_char (cache, font, wc, buf) != PANGO_GLYPH_NULL ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE; + return find_char (cache, font, wc, buf) ? PANGO_COVERAGE_EXACT : PANGO_COVERAGE_NONE; } static void diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c index 5d3e0f73..0b12c94a 100644 --- a/modules/hangul/hangul-fc.c +++ b/modules/hangul/hangul-fc.c @@ -138,7 +138,7 @@ render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, index = find_char (font, tone); pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index != PANGO_GLYPH_NULL) + if (index) { set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index); } @@ -146,7 +146,7 @@ render_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, { /* fall back : HTONE1(0x302e) => middle-dot, HTONE2(0x302f) => colon */ index = find_char (font, tone == HTONE1 ? 0x00b7 : 0x003a); - if (index != PANGO_GLYPH_NULL) + if (index) { set_glyph_tone (font, glyphs, *n_glyphs, cluster_offset, index); } @@ -167,11 +167,11 @@ render_isolated_tone (PangoFont *font, gunichar tone, PangoGlyphString *glyphs, /* Find a base character to render the mark on */ int index = find_char (font, 0x25cc); /* DOTTED CIRCLE */ - if (index == PANGO_GLYPH_NULL) + if (!index) index = find_char (font, 0x25cb); /* WHITE CIRCLE, in KSC-5601 */ - if (index == PANGO_GLYPH_NULL) + if (!index) index = find_char (font, ' '); /* Space */ - if (index == PANGO_GLYPH_NULL) /* Unknown glyph box with 0000 in it */ + if (!index) /* Unknown glyph box with 0000 in it */ index = find_char (font, get_unknown_glyph (font, 0)); /* Add the base character @@ -217,7 +217,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, wc = S_FROM_LV(text[0], text[1]); index = find_char (font, wc); pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index == PANGO_GLYPH_NULL) + if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, get_unknown_glyph (font, wc)); else @@ -236,7 +236,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, continue; index = find_char (font, text[i]); - if (index != PANGO_GLYPH_NULL) + if (index) { pango_glyph_string_set_size (glyphs, *n_glyphs + 1); set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); @@ -250,9 +250,9 @@ render_syllable (PangoFont *font, gunichar *text, int length, for (j = 0; j < 3 && (__jamo_to_ksc5601[jindex][j] != 0); j++) { wc = __jamo_to_ksc5601[jindex][j] - KSC_JAMOBASE + UNI_JAMOBASE; - index = (wc >= 0x3131) ? find_char (font, wc) : PANGO_GLYPH_NULL; + index = (wc >= 0x3131) ? find_char (font, wc) : 0; pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index == PANGO_GLYPH_NULL) + if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, get_unknown_glyph (font, index)); else @@ -264,7 +264,7 @@ render_syllable (PangoFont *font, gunichar *text, int length, { index = find_char (font, 0x3164); pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index == PANGO_GLYPH_NULL) + if (!index) set_glyph (font, glyphs, *n_glyphs, cluster_offset, get_unknown_glyph (font, index)); else @@ -285,17 +285,17 @@ render_basic (PangoFont *font, gunichar wc, if (wc == 0xa0) /* non-break-space */ wc = 0x20; - index = find_char (font, wc); pango_glyph_string_set_size (glyphs, *n_glyphs + 1); - if (index != PANGO_GLYPH_NULL) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); + + if (pango_is_zero_width (wc)) + set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GLYPH_EMPTY); else { - if (pango_is_zero_width (wc)) - set_glyph (font, glyphs, *n_glyphs, cluster_offset, PANGO_GLYPH_NULL); + index = find_char (font, wc); + if (index) + set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); else - set_glyph (font, glyphs, *n_glyphs, cluster_offset, - get_unknown_glyph (font, wc)); + set_glyph (font, glyphs, *n_glyphs, cluster_offset, get_unknown_glyph (font, wc)); } (*n_glyphs)++; } diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c index fd12d983..b396fa92 100644 --- a/modules/hebrew/hebrew-fc.c +++ b/modules/hebrew/hebrew-fc.c @@ -348,13 +348,13 @@ hebrew_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) /* Zero-width characters */ { - pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_NULL, unknown_property, p - text); + pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, unknown_property, p - text); } else { index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) { pango_ot_buffer_add_glyph (buffer, pango_fc_font_get_unknown_glyph (fc_font, wc), unknown_property, p - text); diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c index 187067cb..4cfcf7ae 100644 --- a/modules/indic/indic-fc.c +++ b/modules/indic/indic-fc.c @@ -266,22 +266,21 @@ set_glyphs (PangoFont *font, fc_font = PANGO_FC_FONT (font); - for (i = 0; i < n_glyphs; i += 1) + for (i = 0; i < n_glyphs; i++) { guint glyph; if (pango_is_zero_width (wcs[i]) && (!process_zwj || wcs[i] != 0x200D)) - glyph = PANGO_GLYPH_NULL; + glyph = PANGO_GLYPH_EMPTY; else { glyph = pango_fc_font_get_glyph (fc_font, wcs[i]); - if (glyph == PANGO_GLYPH_NULL) + if (!glyph) glyph = pango_fc_font_get_unknown_glyph (fc_font, wcs[i]); - - pango_ot_buffer_add_glyph (buffer, glyph, tags[i], i); } + pango_ot_buffer_add_glyph (buffer, glyph, tags[i], i); } } diff --git a/modules/khmer/khmer-fc.c b/modules/khmer/khmer-fc.c index ee585d31..75cebf87 100644 --- a/modules/khmer/khmer-fc.c +++ b/modules/khmer/khmer-fc.c @@ -508,7 +508,7 @@ static PangoGlyph get_index (PangoFcFont *fc_font, gunichar wc) { PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) index = pango_fc_font_get_unknown_glyph (fc_font, wc); return index; } diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c index 60cadd36..876e725d 100644 --- a/modules/syriac/syriac-fc.c +++ b/modules/syriac/syriac-fc.c @@ -201,13 +201,13 @@ fallback_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_NULL); + set_glyph (font, glyphs, i, p - text, PANGO_GLYPH_EMPTY); } else { index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) index = pango_fc_font_get_unknown_glyph (fc_font, wc); set_glyph (font, glyphs, i, p - text, index); @@ -301,7 +301,7 @@ syriac_engine_shape (PangoEngineShape *engine, if (pango_is_zero_width (wc)) { - pango_ot_buffer_add_glyph (buffer, 0, properties[i], p - text); + pango_ot_buffer_add_glyph (buffer, PANGO_GLYPH_EMPTY, properties[i], p - text); } else { diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c index 46d77e71..9a038e8b 100644 --- a/modules/thai/thai-fc.c +++ b/modules/thai/thai-fc.c @@ -228,7 +228,7 @@ thai_make_glyph_uni (ThaiFontInfo *font_info, gunichar uc) PangoFcFont *fc_font = (PangoFcFont *)font_info->font; result = pango_fc_font_get_glyph (fc_font, uc); - if (result != PANGO_GLYPH_NULL) + if (result) return result; else return pango_fc_font_get_unknown_glyph (fc_font, uc); diff --git a/modules/tibetan/tibetan-fc.c b/modules/tibetan/tibetan-fc.c index 7294724b..77a10ca7 100644 --- a/modules/tibetan/tibetan-fc.c +++ b/modules/tibetan/tibetan-fc.c @@ -473,7 +473,7 @@ static PangoGlyph get_index (PangoFcFont *fc_font, gunichar wc) { PangoGlyph index = pango_fc_font_get_glyph (fc_font, wc); - if (index == PANGO_GLYPH_NULL) + if (!index) index = pango_fc_font_get_unknown_glyph (fc_font, wc); return index; } -- cgit v1.2.1