diff options
author | Alex Larsson <alexl@redhat.com> | 2002-02-28 23:08:37 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2002-02-28 23:08:37 +0000 |
commit | dd0df5d218b03ee0f16ed4310dc81225810e3503 (patch) | |
tree | b8a73baf2212139b4daf8add37d1caea1b80c906 | |
parent | b826d3f5673d197458d1aaad7d9cc12bf893e8f7 (diff) | |
download | pango-dd0df5d218b03ee0f16ed4310dc81225810e3503.tar.gz |
Check for errors when loading font face, fall back to sans, exit with
2002-02-28 Alex Larsson <alexl@redhat.com>
* pango/pangoft2.c (pango_ft2_font_get_face):
Check for errors when loading font face, fall back to sans,
exit with warning if no font found.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 6 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 6 | ||||
-rw-r--r-- | pango/pangoft2.c | 54 |
8 files changed, 89 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index d9ac36b3..2fcf3fc1 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,9 @@ +2002-02-28 Alex Larsson <alexl@redhat.com> + + * pango/pangoft2.c (pango_ft2_font_get_face): + Check for errors when loading font face, fall back to sans, + exit with warning if no font found. + 2002-02-28 Sven Neumann <sven@gimp.org> * modules/arabic/Makefile.am: don't link libpango-ot into the module. diff --git a/pango/pangoft2.c b/pango/pangoft2.c index 01b1f354..f13d0e44 100644 --- a/pango/pangoft2.c +++ b/pango/pangoft2.c @@ -147,16 +147,56 @@ pango_ft2_font_get_face (PangoFont *font) error = FT_New_Face (_pango_ft2_font_map_get_library (ft2font->fontmap), filename, id, &ft2font->face); + if (error) + { + MiniXftPattern *sans; + MiniXftPattern *matched; + MiniXftResult result; + char *filename2 = NULL; + gchar *name; + + bail0: + + sans = MiniXftPatternBuild (0, + XFT_FAMILY, MiniXftTypeString, "sans", + XFT_ENCODING, MiniXftTypeString, "glyphs-fontspecific", + XFT_SIZE, MiniXftTypeDouble, (double)pango_font_description_get_size (ft2font->description)/PANGO_SCALE, + NULL); + + matched = MiniXftFontMatch ((Display *)1, 0, sans, &result); + + if (MiniXftPatternGetString (matched, XFT_FILE, 0, &filename2) != MiniXftResultMatch) + goto bail1; + + if (MiniXftPatternGetInteger (matched, XFT_INDEX, 0, &id) != MiniXftResultMatch) + goto bail1; + + error = FT_New_Face (_pango_ft2_font_map_get_library (ft2font->fontmap), + filename2, id, &ft2font->face); + + + if (error) + { + bail1: + name = pango_font_description_to_string (ft2font->description); + g_warning ("Unable to open font file %s for font %s, exiting\n", filename2, name); + exit (1); + } + else + { + name = pango_font_description_to_string (ft2font->description); + g_warning ("Unable to open font file %s for font %s, falling back to %s\n", filename, name, filename2); + g_free (name); + } + + MiniXftPatternDestroy (sans); + MiniXftPatternDestroy (matched); + } ft2font->face->generic.data = 0; } - bail0: - - if (!ft2font->face) - { - g_warning ("Cannot load font\n"); - return NULL; - } + g_assert (ft2font->face); + face = ft2font->face; if (ft2font->size != GPOINTER_TO_UINT (face->generic.data)) |