From 1a00555cd87c8454301b65fe7939e277b7d67998 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 29 Jan 2006 23:06:59 +0000 Subject: If locking font face failed, do not assert, just return zero glyphs with 2006-01-29 Behdad Esfahbod * modules/arabic/arabic-fc.c, modules/basic/basic-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-ot.c, modules/thai/thai-shaper.c modules/tibetan/tibetan-fc.c: If locking font face failed, do not assert, just return zero glyphs with an implicit warning. * pango/fonts.c, pango/glyphstring.c pango/modules.c pango/pango-color.c, pango/pango-context.c pango/pango-coverage.c, pango/pango-fontmap.c pango/pango-glyph-item.c, pango/pango-item.c pango/pango-layout.c, pango/pango-markup.c pango/pango-ot-buffer.c, pango/pango-script.c pango/pango-tabs.c, pango/pango-utils.c pango/pangoatsui-fontmap.c, pango/pangocairo-fcfont.c pango/pangocairo-fcfontmap.c, pango/pangocairo-fontmap.c pango/pangocairo-win32font.c, pango/pangofc-font.c pango/pangofc-fontmap.c, pango/pangoft2-fontmap.c pango/pangoft2-render.c, pango/pangoft2.c pango/pangowin32-fontcache.c, pango/pangoxft-font.c pango/pangoxft-render.c, pango/break.c pango/ellipsize.c: Use g_slice for allocating all types. Also, change some g_error's to g_critical's... --- modules/arabic/arabic-fc.c | 15 +++++++-------- modules/basic/basic-fc.c | 16 ++++++++-------- modules/hebrew/hebrew-fc.c | 16 +++++++--------- modules/indic/indic-fc.c | 10 +++++----- modules/khmer/khmer-fc.c | 19 +++++++++++++------ modules/syriac/syriac-fc.c | 15 +++++++-------- modules/thai/thai-ot.c | 7 ++----- modules/thai/thai-shaper.c | 13 +++++++++---- modules/tibetan/tibetan-fc.c | 19 +++++++++++++------ 9 files changed, 71 insertions(+), 59 deletions(-) (limited to 'modules') diff --git a/modules/arabic/arabic-fc.c b/modules/arabic/arabic-fc.c index e03e9ba6..d72aebc1 100644 --- a/modules/arabic/arabic-fc.c +++ b/modules/arabic/arabic-fc.c @@ -256,16 +256,16 @@ arabic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - glong n_chars; - gunichar *wcs; - int i; - const char *p; - gulong *properties = NULL; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gulong *properties = NULL; + glong n_chars; + gunichar *wcs; + const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -273,9 +273,8 @@ arabic_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c index caa46cf4..c260f42b 100644 --- a/modules/basic/basic-fc.c +++ b/modules/basic/basic-fc.c @@ -327,27 +327,24 @@ basic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; gint unknown_property = 0; - int n_chars; - int i; + glong n_chars; const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); g_return_if_fail (length >= 0); g_return_if_fail (analysis != NULL); - n_chars = g_utf8_strlen (text, length); - pango_glyph_string_set_size (glyphs, n_chars); - + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); - + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) @@ -360,6 +357,9 @@ basic_engine_shape (PangoEngineShape *engine, buffer = pango_ot_buffer_new (fc_font); pango_ot_buffer_set_rtl (buffer, analysis->level % 2 != 0); + n_chars = g_utf8_strlen (text, length); + pango_glyph_string_set_size (glyphs, n_chars); + p = text; for (i=0; i < n_chars; i++) { diff --git a/modules/hebrew/hebrew-fc.c b/modules/hebrew/hebrew-fc.c index c22f118f..9ffe289c 100644 --- a/modules/hebrew/hebrew-fc.c +++ b/modules/hebrew/hebrew-fc.c @@ -295,14 +295,15 @@ hebrew_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - const gchar *p; - gint i; - glong n_chars; - gint unknown_property = 0; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gint unknown_property = 0; + glong n_chars; + const char *p; + int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -310,9 +311,8 @@ hebrew_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) @@ -327,7 +327,6 @@ hebrew_engine_shape (PangoEngineShape *engine, n_chars = g_utf8_strlen (text, length); p = text; - for (i=0; i < n_chars; i++) { gunichar wc; @@ -335,7 +334,6 @@ hebrew_engine_shape (PangoEngineShape *engine, PangoGlyph index; char buf[6]; const char *input; - int cluster = 0; wc = g_utf8_get_char (p); input = p; diff --git a/modules/indic/indic-fc.c b/modules/indic/indic-fc.c index 4e6fdfcc..3e3ec23e 100644 --- a/modules/indic/indic-fc.c +++ b/modules/indic/indic-fc.c @@ -325,17 +325,17 @@ indic_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { + PangoFcFont *fc_font; + FT_Face face; + PangoOTRuleset *gsub_ruleset, *gpos_ruleset; + PangoOTBuffer *buffer; glong i, n_chars, n_glyphs; gulong *tags = NULL; gunichar *wc_in = NULL, *wc_out = NULL; glong *utf8_offsets = NULL; glong *indices = NULL; - FT_Face face; - PangoOTRuleset *gsub_ruleset = NULL, *gpos_ruleset = NULL; - PangoOTBuffer *buffer; IndicEngineFc *indic_shape_engine = NULL; const PangoIndicInfo *indic_info = NULL; - PangoFcFont *fc_font; MPreFixups *mprefixups; g_return_if_fail (font != NULL); @@ -345,7 +345,7 @@ indic_engine_shape (PangoEngineShape *engine, fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_if_fail (face != NULL); indic_shape_engine = (IndicEngineFc *) engine; diff --git a/modules/khmer/khmer-fc.c b/modules/khmer/khmer-fc.c index 7d768c5e..75cebf87 100644 --- a/modules/khmer/khmer-fc.c +++ b/modules/khmer/khmer-fc.c @@ -522,25 +522,32 @@ khmer_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; - PangoOTBuffer *buffer; PangoOTRuleset *ruleset; - glong n_chars, i; + PangoOTBuffer *buffer; + glong n_chars; gunichar *wcs; const char *p; + int i; glong syllable; KhmerCharClass charClass; glong cursor = 0; - buffer = pango_ot_buffer_new (fc_font); + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); + + buffer = pango_ot_buffer_new (fc_font); wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - p = text; + p = text; /* This loop only exits when we reach the end of a run, which may contain * several syllables. */ diff --git a/modules/syriac/syriac-fc.c b/modules/syriac/syriac-fc.c index ed689d59..300ce5d3 100644 --- a/modules/syriac/syriac-fc.c +++ b/modules/syriac/syriac-fc.c @@ -248,16 +248,16 @@ syriac_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - glong n_chars; - gunichar *wcs; - int i; - const char *p; - gulong *properties = NULL; + PangoFcFont *fc_font; FT_Face face; PangoOTRuleset *ruleset; PangoOTBuffer *buffer; - PangoFcFont *fc_font; + gulong *properties = NULL; + glong n_chars; + gunichar *wcs; + const char *p; int cluster = 0; + int i; g_return_if_fail (font != NULL); g_return_if_fail (text != NULL); @@ -265,9 +265,8 @@ syriac_engine_shape (PangoEngineShape *engine, g_return_if_fail (analysis != NULL); fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); ruleset = get_ruleset (face); if (!ruleset) diff --git a/modules/thai/thai-ot.c b/modules/thai/thai-ot.c index b82033bb..23c20190 100644 --- a/modules/thai/thai-ot.c +++ b/modules/thai/thai-ot.c @@ -76,7 +76,7 @@ thai_ot_get_ruleset (PangoFont *font) fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_val_if_fail (face != NULL, NULL); info = pango_ot_info_get (face); if (info != NULL) @@ -148,7 +148,7 @@ lao_ot_get_ruleset (PangoFont *font) fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); + g_return_val_if_fail (face != NULL, NULL); info = pango_ot_info_get (face); if (info != NULL) @@ -216,9 +216,6 @@ thai_ot_shape (PangoFont *font, PangoOTRuleset *th_ruleset; PangoOTRuleset *lo_ruleset; - g_return_if_fail (font != NULL); - g_return_if_fail (glyphs != NULL); - th_ruleset = thai_ot_get_ruleset (font); lo_ruleset = lao_ot_get_ruleset (font); diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c index a2a5bf37..bb62a9c1 100644 --- a/modules/thai/thai-shaper.c +++ b/modules/thai/thai-shaper.c @@ -531,11 +531,16 @@ thai_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - ThaiFontInfo *font_info; + gint n_chars; const char *p; + ThaiFontInfo *font_info; const char *log_cluster; gunichar cluster[MAX_CLUSTER_CHRS]; - gint num_chrs; + + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); pango_glyph_string_set_size (glyphs, 0); @@ -545,8 +550,8 @@ thai_engine_shape (PangoEngineShape *engine, while (p < text + length) { log_cluster = p; - p = get_next_cluster (p, text + length - p, cluster, &num_chrs); - add_cluster (font_info, glyphs, log_cluster - text, cluster, num_chrs); + p = get_next_cluster (p, text + length - p, cluster, &n_chars); + add_cluster (font_info, glyphs, log_cluster - text, cluster, n_chars); } thai_ot_shape (font, glyphs); } diff --git a/modules/tibetan/tibetan-fc.c b/modules/tibetan/tibetan-fc.c index 5df9906e..77a10ca7 100644 --- a/modules/tibetan/tibetan-fc.c +++ b/modules/tibetan/tibetan-fc.c @@ -487,25 +487,32 @@ tibetan_engine_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { - PangoFcFont *fc_font = PANGO_FC_FONT (font); + PangoFcFont *fc_font; FT_Face face; - PangoOTBuffer *buffer; PangoOTRuleset *ruleset; - glong n_chars, i; + PangoOTBuffer *buffer; + glong n_chars; gunichar *wcs; const char *p; + int i; glong syllable; TibetanCharClass charClass; glong cursor = 0; - buffer = pango_ot_buffer_new (fc_font); + g_return_if_fail (font != NULL); + g_return_if_fail (text != NULL); + g_return_if_fail (length >= 0); + g_return_if_fail (analysis != NULL); + fc_font = PANGO_FC_FONT (font); face = pango_fc_font_lock_face (fc_font); - g_assert (face); + g_return_if_fail (face != NULL); + + buffer = pango_ot_buffer_new (fc_font); wcs = g_utf8_to_ucs4_fast (text, length, &n_chars); - p = text; + p = text; /* This loop only exits when we reach the end of a run, which may contain * several syllables. */ -- cgit v1.2.1