diff options
author | Manish Singh <yosh@gimp.org> | 2004-03-12 01:48:57 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 2004-03-12 01:48:57 +0000 |
commit | e62c49f406f43d02eae00f76b58046f342e6ad36 (patch) | |
tree | 683e39134e53a9ef63aa1fc319823c30eb87f74c | |
parent | dc1eddd4e771c77e03afae60ff6b54ff3f960226 (diff) | |
download | pango-e62c49f406f43d02eae00f76b58046f342e6ad36.tar.gz |
Convert PangoStretch to and from FC_WIDTH, so we can actually get
Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org>
* pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH,
so we can actually get fontconfig to match on condensed and expanded
versions of fonts, and have the info survive a pango_fc_face_describe
roundtrip. Fixes #131561.
* pango/pangox-fontmap.c: Remove unused function
free_coverages_foreach.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 10 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 10 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 224 | ||||
-rw-r--r-- | pango/pangox-fontmap.c | 8 |
7 files changed, 207 insertions, 75 deletions
@@ -1,3 +1,13 @@ +Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org> + + * pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH, + so we can actually get fontconfig to match on condensed and expanded + versions of fonts, and have the info survive a pango_fc_face_describe + roundtrip. Fixes #131561. + + * pango/pangox-fontmap.c: Remove unused function + free_coverages_foreach. + Tue Mar 9 09:21:07 2004 Owen Taylor <otaylor@redhat.com> * === Released 1.3.6 === diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index e134f66a..a5ec17be 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,13 @@ +Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org> + + * pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH, + so we can actually get fontconfig to match on condensed and expanded + versions of fonts, and have the info survive a pango_fc_face_describe + roundtrip. Fixes #131561. + + * pango/pangox-fontmap.c: Remove unused function + free_coverages_foreach. + Tue Mar 9 09:21:07 2004 Owen Taylor <otaylor@redhat.com> * === Released 1.3.6 === diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index e134f66a..a5ec17be 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,13 @@ +Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org> + + * pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH, + so we can actually get fontconfig to match on condensed and expanded + versions of fonts, and have the info survive a pango_fc_face_describe + roundtrip. Fixes #131561. + + * pango/pangox-fontmap.c: Remove unused function + free_coverages_foreach. + Tue Mar 9 09:21:07 2004 Owen Taylor <otaylor@redhat.com> * === Released 1.3.6 === diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index e134f66a..a5ec17be 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,13 @@ +Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org> + + * pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH, + so we can actually get fontconfig to match on condensed and expanded + versions of fonts, and have the info survive a pango_fc_face_describe + roundtrip. Fixes #131561. + + * pango/pangox-fontmap.c: Remove unused function + free_coverages_foreach. + Tue Mar 9 09:21:07 2004 Owen Taylor <otaylor@redhat.com> * === Released 1.3.6 === diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index e134f66a..a5ec17be 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,13 @@ +Thu Mar 11 17:28:06 2004 Manish Singh <yosh@gimp.org> + + * pango/pangofc-fontmap.c: Convert PangoStretch to and from FC_WIDTH, + so we can actually get fontconfig to match on condensed and expanded + versions of fonts, and have the info survive a pango_fc_face_describe + roundtrip. Fixes #131561. + + * pango/pangox-fontmap.c: Remove unused function + free_coverages_foreach. + Tue Mar 9 09:21:07 2004 Owen Taylor <otaylor@redhat.com> * === Released 1.3.6 === diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index f3e44ecc..26129836 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -486,60 +486,95 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap, } static int -pango_fc_convert_weight (PangoWeight pango_weight) +pango_fc_convert_weight_to_fc (PangoWeight pango_weight) { - int weight; - if (pango_weight < (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_LIGHT) / 2) - weight = FC_WEIGHT_LIGHT; + return FC_WEIGHT_LIGHT; else if (pango_weight < (PANGO_WEIGHT_NORMAL + 600) / 2) - weight = FC_WEIGHT_MEDIUM; + return FC_WEIGHT_MEDIUM; else if (pango_weight < (600 + PANGO_WEIGHT_BOLD) / 2) - weight = FC_WEIGHT_DEMIBOLD; + return FC_WEIGHT_DEMIBOLD; else if (pango_weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) - weight = FC_WEIGHT_BOLD; + return FC_WEIGHT_BOLD; else - weight = FC_WEIGHT_BLACK; - - return weight; + return FC_WEIGHT_BLACK; } static int -pango_fc_convert_slant (PangoStyle pango_style) +pango_fc_convert_slant_to_fc (PangoStyle pango_style) { - int slant; - - if (pango_style == PANGO_STYLE_ITALIC) - slant = FC_SLANT_ITALIC; - else if (pango_style == PANGO_STYLE_OBLIQUE) - slant = FC_SLANT_OBLIQUE; - else - slant = FC_SLANT_ROMAN; - - return slant; + switch (pango_style) + { + case PANGO_STYLE_NORMAL: + return FC_SLANT_ROMAN; + case PANGO_STYLE_ITALIC: + return FC_SLANT_ITALIC; + case PANGO_STYLE_OBLIQUE: + return FC_SLANT_OBLIQUE; + default: + return FC_SLANT_ROMAN; + } } +#ifdef FC_WIDTH +static int +pango_fc_convert_width_to_fc (PangoStretch pango_stretch) +{ + switch (pango_stretch) + { + case PANGO_STRETCH_NORMAL: + return FC_WIDTH_NORMAL; + case PANGO_STRETCH_ULTRA_CONDENSED: + return FC_WIDTH_ULTRACONDENSED; + case PANGO_STRETCH_EXTRA_CONDENSED: + return FC_WIDTH_EXTRACONDENSED; + case PANGO_STRETCH_CONDENSED: + return FC_WIDTH_CONDENSED; + case PANGO_STRETCH_SEMI_CONDENSED: + return FC_WIDTH_SEMICONDENSED; + case PANGO_STRETCH_SEMI_EXPANDED: + return FC_WIDTH_SEMIEXPANDED; + case PANGO_STRETCH_EXPANDED: + return FC_WIDTH_EXPANDED; + case PANGO_STRETCH_EXTRA_EXPANDED: + return FC_WIDTH_EXTRAEXPANDED; + case PANGO_STRETCH_ULTRA_EXPANDED: + return FC_WIDTH_ULTRAEXPANDED; + default: + return FC_WIDTH_NORMAL; + } +} +#endif static FcPattern * pango_fc_make_pattern (const PangoFontDescription *description) { FcPattern *pattern; - PangoStyle pango_style; int slant; int weight; + double size; char **families; int i; +#ifdef FC_WIDTH + int width; +#endif - pango_style = pango_font_description_get_style (description); + slant = pango_fc_convert_slant_to_fc (pango_font_description_get_style (description)); + weight = pango_fc_convert_weight_to_fc (pango_font_description_get_weight (description)); +#ifdef FC_WIDTH + width = pango_fc_convert_width_to_fc (pango_font_description_get_stretch (description)); +#endif - slant = pango_fc_convert_slant (pango_style); - weight = pango_fc_convert_weight (pango_font_description_get_weight (description)); + size = (double) pango_font_description_get_size (description) / PANGO_SCALE; pattern = FcPatternBuild (0, - FC_WEIGHT, FcTypeInteger, weight, - FC_SLANT, FcTypeInteger, slant, - FC_SIZE, FcTypeDouble, (double)pango_font_description_get_size (description)/PANGO_SCALE, - NULL); + FC_WEIGHT, FcTypeInteger, weight, + FC_SLANT, FcTypeInteger, slant, +#ifdef FC_WIDTH + FC_WIDTH, FcTypeInteger, width, +#endif + FC_SIZE, FcTypeDouble, size, + NULL); families = g_strsplit (pango_font_description_get_family (description), ",", -1); @@ -670,19 +705,22 @@ pango_fc_font_map_get_patterns (PangoFontMap *fontmap, patterns->cache_link = NULL; for (f = 0; f < font_patterns->nfont; f++) - { - font_pattern = FcFontRenderPrepare (NULL, pattern, - font_patterns->fonts[f]); + { + font_pattern = FcFontRenderPrepare (NULL, pattern, + font_patterns->fonts[f]); + + if (font_pattern) + { #ifdef FC_PATTERN - /* The FC_PATTERN element, which points back to our the original patterm - * defeats our hash tables. - */ - FcPatternDel (font_pattern, FC_PATTERN); + /* The FC_PATTERN element, which points back to our the original + * pattern defeats our hash tables. + */ + FcPatternDel (font_pattern, FC_PATTERN); #endif /* FC_PATTERN */ - if (font_pattern) - patterns->patterns[patterns->n_patterns++] = uniquify_pattern (fcfontmap, font_pattern); - } + patterns->patterns[patterns->n_patterns++] = uniquify_pattern (fcfontmap, font_pattern); + } + } FcPatternDestroy (pattern); @@ -995,7 +1033,70 @@ pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap) g_hash_table_destroy (priv->fonts); priv->fonts = NULL; priv->closed = TRUE; -} +} + +static PangoWeight +pango_fc_convert_weight_to_pango (int fc_weight) +{ + if (fc_weight < FC_WEIGHT_LIGHT) + return PANGO_WEIGHT_ULTRALIGHT; + else if (fc_weight < (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2) + return PANGO_WEIGHT_LIGHT; + else if (fc_weight < (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) + return PANGO_WEIGHT_NORMAL; + else if (fc_weight < (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) + return 600; + else if (fc_weight < (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2) + return PANGO_WEIGHT_BOLD; + else + return PANGO_WEIGHT_ULTRABOLD; +} + +static PangoStyle +pango_fc_convert_slant_to_pango (int fc_style) +{ + switch (fc_style) + { + case FC_SLANT_ROMAN: + return PANGO_STYLE_NORMAL; + case FC_SLANT_ITALIC: + return PANGO_STYLE_ITALIC; + case FC_SLANT_OBLIQUE: + return PANGO_STYLE_OBLIQUE; + default: + return PANGO_STYLE_NORMAL; + } +} + +#ifdef FC_WIDTH +static PangoStretch +pango_fc_convert_width_to_pango (int fc_stretch) +{ + switch (fc_stretch) + { + case FC_WIDTH_NORMAL: + return PANGO_STRETCH_NORMAL; + case FC_WIDTH_ULTRACONDENSED: + return PANGO_STRETCH_ULTRA_CONDENSED; + case FC_WIDTH_EXTRACONDENSED: + return PANGO_STRETCH_EXTRA_CONDENSED; + case FC_WIDTH_CONDENSED: + return PANGO_STRETCH_CONDENSED; + case FC_WIDTH_SEMICONDENSED: + return PANGO_STRETCH_SEMI_CONDENSED; + case FC_WIDTH_SEMIEXPANDED: + return PANGO_STRETCH_SEMI_EXPANDED; + case FC_WIDTH_EXPANDED: + return PANGO_STRETCH_EXPANDED; + case FC_WIDTH_EXTRAEXPANDED: + return PANGO_STRETCH_EXTRA_EXPANDED; + case FC_WIDTH_ULTRAEXPANDED: + return PANGO_STRETCH_ULTRA_EXPANDED; + default: + return PANGO_STRETCH_NORMAL; + } +} +#endif /** * pango_fc_font_description_from_pattern: @@ -1019,6 +1120,7 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz PangoFontDescription *desc; PangoStyle style; PangoWeight weight; + PangoStretch stretch; double size; FcChar8 *s; @@ -1033,44 +1135,32 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz pango_font_description_set_family (desc, (gchar *)s); if (FcPatternGetInteger (pattern, FC_SLANT, 0, &i) == FcResultMatch) - { - if (i == FC_SLANT_ROMAN) - style = PANGO_STYLE_NORMAL; - else if (i == FC_SLANT_OBLIQUE) - style = PANGO_STYLE_OBLIQUE; - else - style = PANGO_STYLE_ITALIC; - } + style = pango_fc_convert_slant_to_pango (i); else style = PANGO_STYLE_NORMAL; pango_font_description_set_style (desc, style); if (FcPatternGetInteger (pattern, FC_WEIGHT, 0, &i) == FcResultMatch) - { - if (i < FC_WEIGHT_LIGHT) - weight = PANGO_WEIGHT_ULTRALIGHT; - else if (i < (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2) - weight = PANGO_WEIGHT_LIGHT; - else if (i < (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) - weight = PANGO_WEIGHT_NORMAL; - else if (i < (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) - weight = 600; - else if (i < (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2) - weight = PANGO_WEIGHT_BOLD; - else - weight = PANGO_WEIGHT_ULTRABOLD; - } + weight = pango_fc_convert_weight_to_pango (i); else weight = PANGO_WEIGHT_NORMAL; - - if (include_size && FcPatternGetDouble (pattern, FC_SIZE, 0, &size) == FcResultMatch) - pango_font_description_set_size (desc, size * PANGO_SCALE); pango_font_description_set_weight (desc, weight); + +#ifdef FC_WIDTH + if (FcPatternGetInteger (pattern, FC_WIDTH, 0, &i) == FcResultMatch) + stretch = pango_fc_convert_width_to_pango (i); + else +#endif + stretch = PANGO_STRETCH_NORMAL; + + pango_font_description_set_stretch (desc, stretch); pango_font_description_set_variant (desc, PANGO_VARIANT_NORMAL); - pango_font_description_set_stretch (desc, PANGO_STRETCH_NORMAL); + + if (include_size && FcPatternGetDouble (pattern, FC_SIZE, 0, &size) == FcResultMatch) + pango_font_description_set_size (desc, size * PANGO_SCALE); return desc; } @@ -1111,7 +1201,7 @@ pango_fc_face_describe (PangoFontFace *face) return make_alias_description (fcfamily, FALSE, FALSE); else if (strcmp (fcface->style, "Bold") == 0) return make_alias_description (fcfamily, TRUE, FALSE); - else if (strcmp (fcface->style, "Italic") == 0) + else if (strcmp (fcface->style, "Italic") == 0) return make_alias_description (fcfamily, FALSE, TRUE); else /* Bold Italic */ return make_alias_description (fcfamily, TRUE, TRUE); diff --git a/pango/pangox-fontmap.c b/pango/pangox-fontmap.c index 308d5621..b99ee2e4 100644 --- a/pango/pangox-fontmap.c +++ b/pango/pangox-fontmap.c @@ -1328,14 +1328,6 @@ pango_x_make_matching_xlfd (PangoFontMap *fontmap, char *xlfd, const char *chars return result; } -static void -free_coverages_foreach (gpointer key, - gpointer value, - gpointer data) -{ - pango_coverage_unref (value); -} - /** * pango_x_font_map_get_font_cache: * @font_map: a #PangoXFontMap. |