diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 11 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 11 | ||||
-rw-r--r-- | pango/pango-context.c | 148 | ||||
-rw-r--r-- | pango/pangox-fontmap.c | 29 |
9 files changed, 206 insertions, 48 deletions
@@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 15457fb3..fe4fcdf9 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,14 @@ +Mon Aug 21 22:02:38 2000 Owen Taylor <otaylor@redhat.com> + + * pango/pango-context.c (load_font): Don't produce a warning + unless loading all fonts fails, if loading all fonts fails, + try with "Sans [style]", if that fails, try with "Sans", + if that fails, exit - we are completely screwed. + + * pango/pangox-fontmap.c (pango_x_font_map_load_font): Equate + PANGO_STYLE_OBLIQUE and PANGO_STYLE_ITALIC, but with a big + penalty. + 2000-08-21 Tor Lillqvist <tml@iki.fi> * pango/pangoft2-fontmap.c: Get font directory path with diff --git a/pango/pango-context.c b/pango/pango-context.c index df18ddea..7179dde2 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -20,6 +20,7 @@ */ #include <string.h> +#include <stdlib.h> #include <fribidi/fribidi.h> #include <pango/pango-context.h> @@ -667,7 +668,110 @@ get_font (PangoFont **fonts, return result; } - + +/* FIXME: Remove this artificial limit */ +#define MAX_FAMILIES 16 + +static void +load_font (PangoContext *context, + char *lang, + PangoFontDescription *desc, + PangoFont **current_fonts, + PangoCoverage **current_coverages, + int *n_families) +{ + char **families; + char *orig_family; + int j; + + for (j=0; j < *n_families; j++) + { + if (current_fonts[j]) + { + g_object_unref (G_OBJECT (current_fonts[j])); + pango_coverage_unref (current_coverages[j]); + } + } + + orig_family = desc->family_name; + families = g_strsplit (orig_family, ",", -1); + + *n_families = 0; + for (j=0; families[j] && *n_families < MAX_FAMILIES; j++) + { + desc->family_name = families[j]; + current_fonts[*n_families] = pango_context_load_font (context, desc); + + if (current_fonts[*n_families]) + { + current_coverages[*n_families] = pango_font_get_coverage (current_fonts[*n_families], lang); + (*n_families)++; + } + } + + g_strfreev (families); + + /* The font description was completely unloadable, try with + * family == "Sans" + */ + if (*n_families == 0) + { + char *ctmp1, *ctmp2; + + desc->family_name = orig_family; + + ctmp1 = pango_font_description_to_string (desc); + desc->family_name = "Sans"; + ctmp2 = pango_font_description_to_string (desc); + + g_warning ("Couldn't load font \"%s\" falling back to \"%s\"", ctmp1, ctmp2); + g_free (ctmp1); + g_free (ctmp2); + + desc->family_name = "Sans"; + + current_fonts[0] = pango_context_load_font (context, desc); + if (current_fonts[0]) + { + current_coverages[0] = pango_font_get_coverage (current_fonts[0], lang); + *n_families = 1; + } + } + + /* We couldn't try with Sans and the specified style. Try Sans Normal + */ + if (*n_families == 0) + { + char *ctmp1, *ctmp2; + + ctmp1 = pango_font_description_to_string (desc); + desc->style = PANGO_STYLE_NORMAL; + desc->weight = PANGO_WEIGHT_NORMAL; + desc->variant = PANGO_VARIANT_NORMAL; + desc->stretch = PANGO_STRETCH_NORMAL; + ctmp2 = pango_font_description_to_string (desc); + + g_warning ("Couldn't load font \"%s\" falling back to \"%s\"", ctmp1, ctmp2); + g_free (ctmp1); + g_free (ctmp2); + + current_fonts[0] = pango_context_load_font (context, desc); + if (current_fonts[0]) + { + current_coverages[0] = pango_font_get_coverage (current_fonts[0], lang); + *n_families = 1; + } + } + + /* Everything failed, we are screwed, there is no way to continue + */ + if (n_families == 0) + { + g_warning ("All font failbacks failed!!!!"); + exit (1); + } +} + static void add_engines (PangoContext *context, const gchar *text, @@ -686,10 +790,7 @@ add_engines (PangoContext *context, PangoMap *lang_map = NULL; PangoFontDescription current_desc = { 0 }; - /* FIXME: Remove this artificial limit */ - int n_families = 0; -#define MAX_FAMILIES 16 PangoFont *current_fonts[MAX_FAMILIES]; PangoCoverage *current_coverages[MAX_FAMILIES]; @@ -741,45 +842,10 @@ add_engines (PangoContext *context, if (i == 0 || !pango_font_description_compare (¤t_desc, &next_desc)) { - char **families; - current_desc = next_desc; - for (j=0; j<n_families; j++) - { - if (current_fonts[j]) - { - g_object_unref (G_OBJECT (current_fonts[j])); - pango_coverage_unref (current_coverages[j]); - } - } - - families = g_strsplit (current_desc.family_name, ",", -1); - n_families = 0; - while (families[n_families]) - n_families++; - - if (n_families > MAX_FAMILIES) - n_families = MAX_FAMILIES; - - for (j=0; j<n_families; j++) - { - next_desc.family_name = families[j]; - current_fonts[j] = pango_context_load_font (context, &next_desc); - - if (current_fonts[j]) - current_coverages[j] = pango_font_get_coverage (current_fonts[j], lang); - else - { - char *ctmp; - - ctmp = pango_font_description_to_string (&next_desc); - g_warning ("Couldn't load font \"%s\"", ctmp); - g_free (ctmp); - } - } - - g_strfreev (families); + load_font (context, lang, ¤t_desc, + current_fonts, current_coverages, &n_families); } pango_attr_iterator_range (iterator, NULL, &next_index); diff --git a/pango/pangox-fontmap.c b/pango/pangox-fontmap.c index 4a92c816..a408e3e4 100644 --- a/pango/pangox-fontmap.c +++ b/pango/pangox-fontmap.c @@ -492,22 +492,37 @@ pango_x_font_map_load_font (PangoFontMap *fontmap, if (family_entry) { PangoXFontEntry *best_match = NULL; + int best_distance = G_MAXINT; tmp_list = family_entry->font_entries; while (tmp_list) { PangoXFontEntry *font_entry = tmp_list->data; - if (font_entry->description.style == description->style && - font_entry->description.variant == description->variant && + if (font_entry->description.variant == description->variant && font_entry->description.stretch == description->stretch) { - int distance = abs(font_entry->description.weight - description->weight); - int old_distance = best_match ? abs(best_match->description.weight - description->weight) : G_MAXINT; - - if (distance < old_distance) + if (font_entry->description.style == description->style) + { + int distance = abs(font_entry->description.weight - description->weight); + if (distance < best_distance) + { + best_match = font_entry; + best_distance = distance; + } + } + else if (font_entry->description.style != PANGO_STYLE_NORMAL && + description->style != PANGO_STYLE_NORMAL) { - best_match = font_entry; + /* Equate oblique and italic, but with a big penalty + */ + int distance = PANGO_SCALE * 1000 + abs(font_entry->description.weight - description->weight); + + if (distance < best_distance) + { + best_match = font_entry; + best_distance = distance; + } } } |