diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2009-01-06 11:33:51 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2009-01-06 11:33:51 +0000 |
commit | 07992d0e2c7cca25032aeac650c847a905079b23 (patch) | |
tree | f5701f0c675eb3ebb22315365beb7a40ae79c31a | |
parent | b072c3353cc2d10d6b26fb86cb13694a967a59cd (diff) | |
download | pango-07992d0e2c7cca25032aeac650c847a905079b23.tar.gz |
Bug 166709 – Handle font variants more consistently
2009-01-06 Behdad Esfahbod <behdad@gnome.org>
Bug 166709 – Handle font variants more consistently
* configure.in: Require fontconfig >= 2.5.0
* pango/fonts.c: Parse "Roman" as style=normal instead of
weight=normal. Doesn't make much difference in reality.
* pango/pangofc-fontmap.c (pango_fc_convert_weight_to_fc),
(pango_fc_convert_weight_to_pango): Update to reflect newly
added weights.
svn path=/trunk/; revision=2788
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | pango/fonts.c | 2 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 73 |
4 files changed, 42 insertions, 48 deletions
@@ -2,6 +2,19 @@ Bug 166709 – Handle font variants more consistently + * configure.in: Require fontconfig >= 2.5.0 + + * pango/fonts.c: Parse "Roman" as style=normal instead of + weight=normal. Doesn't make much difference in reality. + + * pango/pangofc-fontmap.c (pango_fc_convert_weight_to_fc), + (pango_fc_convert_weight_to_pango): Update to reflect newly + added weights. + +2009-01-06 Behdad Esfahbod <behdad@gnome.org> + + Bug 166709 – Handle font variants more consistently + * pango/pango-font.h: Add enum values PANGO_WEIGHT_BOOK and PANGO_WEIGHT_ULTRAHEAVY. diff --git a/configure.in b/configure.in index f74bfc22..d09e6f8d 100644 --- a/configure.in +++ b/configure.in @@ -235,7 +235,7 @@ have_xft=false # # Check for fontconfig # -PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 1.0.1, have_fontconfig=true, AC_MSG_RESULT([no])) +PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.5.0, have_fontconfig=true, AC_MSG_RESULT([no])) # # Checks for FreeType diff --git a/pango/fonts.c b/pango/fonts.c index 1faedff5..76ffc17e 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -848,6 +848,7 @@ typedef struct static const FieldMap style_map[] = { { PANGO_STYLE_NORMAL, "" }, + { PANGO_STYLE_NORMAL, "Roman" }, { PANGO_STYLE_OBLIQUE, "Oblique" }, { PANGO_STYLE_ITALIC, "Italic" } }; @@ -865,7 +866,6 @@ static const FieldMap weight_map[] = { { PANGO_WEIGHT_BOOK, "Book" }, { PANGO_WEIGHT_NORMAL, "" }, { PANGO_WEIGHT_NORMAL, "Regular" }, - { PANGO_WEIGHT_NORMAL, "Roman" }, { PANGO_WEIGHT_MEDIUM, "Medium" }, { PANGO_WEIGHT_SEMIBOLD, "Semi-Bold" }, { PANGO_WEIGHT_SEMIBOLD, "Demi-Bold" }, diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 9339f32e..7982078d 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -716,36 +716,28 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap, static int pango_fc_convert_weight_to_fc (PangoWeight pango_weight) { -#ifdef FC_WEIGHT_ULTRABOLD - /* fontconfig 2.1 only had light/medium/demibold/bold/black */ - if (pango_weight < (PANGO_WEIGHT_ULTRALIGHT + PANGO_WEIGHT_LIGHT) / 2) + if (pango_weight <= (PANGO_WEIGHT_THIN + PANGO_WEIGHT_ULTRALIGHT) / 2) + return FC_WEIGHT_THIN; + else if (pango_weight <= (PANGO_WEIGHT_ULTRALIGHT + PANGO_WEIGHT_LIGHT) / 2) return FC_WEIGHT_ULTRALIGHT; - else if (pango_weight < (PANGO_WEIGHT_LIGHT + PANGO_WEIGHT_NORMAL) / 2) + else if (pango_weight <= (PANGO_WEIGHT_LIGHT + PANGO_WEIGHT_BOOK) / 2) return FC_WEIGHT_LIGHT; - else if (pango_weight < (PANGO_WEIGHT_NORMAL + 500 /* PANGO_WEIGHT_MEDIUM */) / 2) + else if (pango_weight <= (PANGO_WEIGHT_BOOK + PANGO_WEIGHT_NORMAL) / 2) + return FC_WEIGHT_BOOK; + else if (pango_weight <= (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_MEDIUM) / 2) return FC_WEIGHT_NORMAL; - else if (pango_weight < (500 /* PANGO_WEIGHT_MEDIUM */ + PANGO_WEIGHT_SEMIBOLD) / 2) + else if (pango_weight <= (PANGO_WEIGHT_MEDIUM + PANGO_WEIGHT_SEMIBOLD) / 2) return FC_WEIGHT_MEDIUM; - else if (pango_weight < (PANGO_WEIGHT_SEMIBOLD + PANGO_WEIGHT_BOLD) / 2) + else if (pango_weight <= (PANGO_WEIGHT_SEMIBOLD + PANGO_WEIGHT_BOLD) / 2) return FC_WEIGHT_DEMIBOLD; - else if (pango_weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) + else if (pango_weight <= (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) return FC_WEIGHT_BOLD; - else if (pango_weight < (PANGO_WEIGHT_ULTRABOLD + PANGO_WEIGHT_HEAVY) / 2) + else if (pango_weight <= (PANGO_WEIGHT_ULTRABOLD + PANGO_WEIGHT_HEAVY) / 2) return FC_WEIGHT_ULTRABOLD; - else + else if (pango_weight <= (PANGO_WEIGHT_HEAVY + PANGO_WEIGHT_ULTRAHEAVY) / 2) return FC_WEIGHT_BLACK; -#else /* fontconfig < 2.2 */ - if (pango_weight < (PANGO_WEIGHT_LIGHT + PANGO_WEIGHT_NORMAL) / 2) - return FC_WEIGHT_LIGHT; - else if (pango_weight < (500 /* PANGO_WEIGHT_MEDIUM */ + PANGO_WEIGHT_SEMIBOLD) / 2) - return FC_WEIGHT_MEDIUM; - else if (pango_weight < (PANGO_WEIGHT_SEMIBOLD + PANGO_WEIGHT_BOLD) / 2) - return FC_WEIGHT_DEMIBOLD; - else if (pango_weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) - return FC_WEIGHT_BOLD; else - return FC_WEIGHT_BLACK; -#endif + return FC_WEIGHT_EXTRABLACK; } static int @@ -1485,39 +1477,28 @@ pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap) static PangoWeight pango_fc_convert_weight_to_pango (int fc_weight) { -#ifdef FC_WEIGHT_ULTRABOLD - /* fontconfig 2.1 only had light/medium/demibold/bold/black */ - if (fc_weight < (FC_WEIGHT_ULTRALIGHT + FC_WEIGHT_LIGHT) / 2) + if (fc_weight <= (FC_WEIGHT_THIN + FC_WEIGHT_EXTRALIGHT) / 2) + return PANGO_WEIGHT_THIN; + else if (fc_weight <= (FC_WEIGHT_EXTRALIGHT + FC_WEIGHT_LIGHT) / 2) return PANGO_WEIGHT_ULTRALIGHT; - else if (fc_weight < (FC_WEIGHT_LIGHT + FC_WEIGHT_REGULAR) / 2) + else if (fc_weight <= (FC_WEIGHT_LIGHT + FC_WEIGHT_BOOK) / 2) return PANGO_WEIGHT_LIGHT; - else if (fc_weight < (FC_WEIGHT_REGULAR + FC_WEIGHT_DEMIBOLD) / 2) + else if (fc_weight <= (FC_WEIGHT_BOOK + FC_WEIGHT_REGULAR) / 2) + return PANGO_WEIGHT_BOOK; + else if (fc_weight <= (FC_WEIGHT_REGULAR + FC_WEIGHT_MEDIUM) / 2) return PANGO_WEIGHT_NORMAL; - /* We group the 500/MEDIUM weight with normal to reduce confusion - * - * else if (fc_weight < (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) - * return 500; - */ - else if (fc_weight < (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) + else if (fc_weight <= (FC_WEIGHT_MEDIUM + FC_WEIGHT_DEMIBOLD) / 2) + return PANGO_WEIGHT_MEDIUM; + else if (fc_weight <= (FC_WEIGHT_DEMIBOLD + FC_WEIGHT_BOLD) / 2) return PANGO_WEIGHT_SEMIBOLD; - else if (fc_weight < (FC_WEIGHT_BOLD + FC_WEIGHT_ULTRABOLD) / 2) + else if (fc_weight <= (FC_WEIGHT_BOLD + FC_WEIGHT_EXTRABOLD) / 2) return PANGO_WEIGHT_BOLD; - else if (fc_weight < (FC_WEIGHT_ULTRABOLD + FC_WEIGHT_BLACK) / 2) + else if (fc_weight <= (FC_WEIGHT_EXTRABOLD + FC_WEIGHT_BLACK) / 2) return PANGO_WEIGHT_ULTRABOLD; - else + else if (fc_weight <= (FC_WEIGHT_BLACK + FC_WEIGHT_EXTRABLACK) / 2) return PANGO_WEIGHT_HEAVY; -#else /* fontconfig < 2.2 */ - 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 PANGO_WEIGHT_SEMIBOLD; - else if (fc_weight < (FC_WEIGHT_BOLD + FC_WEIGHT_BLACK) / 2) - return PANGO_WEIGHT_BOLD; else - return PANGO_WEIGHT_ULTRABOLD; -#endif + return PANGO_WEIGHT_ULTRAHEAVY; } static PangoStyle |