diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-02-06 11:08:44 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-02-06 11:08:44 +0000 |
commit | 9f81790eaec937ced41c31fb6204d63a377a00a7 (patch) | |
tree | d00c3ce91fcb08f5742b1a03a1b72ec03fee7b41 /pango/pango-fontmap.c | |
parent | 3293001b8aa09a4e812af974b389843c952871bb (diff) | |
download | pango-9f81790eaec937ced41c31fb6204d63a377a00a7.tar.gz |
Warn only once per font-description that cannot be loaded.
2006-02-06 Behdad Esfahbod <behdad@gnome.org>
* pango/pango-fontmap.c (pango_font_map_real_load_fontset): Warn
only once per font-description that cannot be loaded.
* pango/pangox.c: Make it not crash if no font found, like other
backends.
Diffstat (limited to 'pango/pango-fontmap.c')
-rw-r--r-- | pango/pango-fontmap.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/pango/pango-fontmap.c b/pango/pango-fontmap.c index b6991c9d..2d97a16b 100644 --- a/pango/pango-fontmap.c +++ b/pango/pango-fontmap.c @@ -152,6 +152,7 @@ pango_font_map_real_load_fontset (PangoFontMap *fontmap, char **families; int i; PangoFontsetSimple *fonts; + static GHashTable *warned_fonts = NULL; families = g_strsplit (pango_font_description_get_family (desc), ",", -1); @@ -178,11 +179,20 @@ pango_font_map_real_load_fontset (PangoFontMap *fontmap, ctmp1 = pango_font_description_to_string (desc); pango_font_description_set_family_static (tmp_desc, "Sans"); - ctmp2 = pango_font_description_to_string (tmp_desc); - - g_warning ("Couldn't load font \"%s\" falling back to \"%s\"", ctmp1, ctmp2); + + if (!warned_fonts || !g_hash_table_lookup (warned_fonts, ctmp1)) + { + if (!warned_fonts) + warned_fonts = g_hash_table_new (g_str_hash, g_str_equal); + + g_hash_table_insert (warned_fonts, g_strdup (ctmp1), GINT_TO_POINTER (1)); + + ctmp2 = pango_font_description_to_string (tmp_desc); + g_warning ("couldn't load font \"%s\", falling back to \"%s\", " + "expect ugly output.", ctmp1, ctmp2); + g_free (ctmp2); + } g_free (ctmp1); - g_free (ctmp2); pango_font_map_fontset_add_fonts (fontmap, context, @@ -203,11 +213,19 @@ pango_font_map_real_load_fontset (PangoFontMap *fontmap, pango_font_description_set_weight (tmp_desc, PANGO_WEIGHT_NORMAL); pango_font_description_set_variant (tmp_desc, PANGO_VARIANT_NORMAL); pango_font_description_set_stretch (tmp_desc, PANGO_STRETCH_NORMAL); - ctmp2 = pango_font_description_to_string (tmp_desc); + + if (!warned_fonts || !g_hash_table_lookup (warned_fonts, ctmp1)) + { + g_hash_table_insert (warned_fonts, g_strdup (ctmp1), GINT_TO_POINTER (1)); + + ctmp2 = pango_font_description_to_string (tmp_desc); - g_warning ("Couldn't load font \"%s\" falling back to \"%s\"", ctmp1, ctmp2); + g_warning ("couldn't load font \"%s\", falling back to \"%s\", " + "expect ugly output.", ctmp1, ctmp2); + g_free (ctmp2); + } + g_free (ctmp1); - g_free (ctmp2); pango_font_map_fontset_add_fonts (fontmap, context, |