summaryrefslogtreecommitdiff
path: root/pango/pangofc-fontmap.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-12-14 23:33:26 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-12-14 23:33:26 +0000
commit51c48b557c6aeaa3dd457e6d034ecdab99a271d6 (patch)
tree82eb1a97d25e4c0cb3f04a12e40ccf548cc4e12f /pango/pangofc-fontmap.c
parent325592919b30fe556c57adf10b6b2d12cfcad93d (diff)
downloadpango-51c48b557c6aeaa3dd457e6d034ecdab99a271d6.tar.gz
Add PANGO_WEIGHT_SEMIBOLD. (#86957, Lars Clausen)
Tue Dec 14 18:08:36 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-font.h: Add PANGO_WEIGHT_SEMIBOLD. (#86957, Lars Clausen) * pango/fonts.c: s/600/PANGO_WEIGHT_SEMIBOLD. * pango/pangofc-fontmap.c (pango_fc_convert_weight_to_fc) * pango/pangofc-fontmap.c (pango_fc_convert_weight_to_pango): Handle PANGO_WEIGHT_SEMIBOLD, use additional weights added in fontconfig-2.2.
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r--pango/pangofc-fontmap.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 8786e04a..0f7b67bb 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -513,16 +513,36 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap,
static int
pango_fc_convert_weight_to_fc (PangoWeight pango_weight)
{
- if (pango_weight < (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_LIGHT) / 2)
+#ifdef FC_WEIGHT_ULTRABOLD
+ /* fontconfig 2.1 only had light/medium/demibold/bold/black */
+ 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)
return FC_WEIGHT_LIGHT;
- else if (pango_weight < (PANGO_WEIGHT_NORMAL + 600) / 2)
+ else if (pango_weight < (PANGO_WEIGHT_NORMAL + 500 /* PANGO_WEIGHT_MEDIUM */) / 2)
+ return FC_WEIGHT_NORMAL;
+ else if (pango_weight < (500 /* PANGO_WEIGHT_MEDIUM */ + PANGO_WEIGHT_SEMIBOLD) / 2)
return FC_WEIGHT_MEDIUM;
- else if (pango_weight < (600 + 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)
return FC_WEIGHT_BOLD;
+ else if (pango_weight < (PANGO_WEIGHT_ULTRABOLD + PANGO_WEIGHT_HEAVY) / 2)
+ return FC_WEIGHT_ULTRABOLD;
else
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_NORMAL;
+ 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
}
static int
@@ -1149,18 +1169,39 @@ pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap)
static PangoWeight
pango_fc_convert_weight_to_pango (int fc_weight)
{
- if (fc_weight < FC_WEIGHT_LIGHT)
+#ifdef FC_WEIGHT_ULTRABOLD
+ /* fontconfig 2.1 only had light/medium/demibold/bold/black */
+ if (fc_weight < (FC_WEIGHT_ULTRALIGHT + FC_WEIGHT_LIGHT) / 2)
return PANGO_WEIGHT_ULTRALIGHT;
- else if (fc_weight < (FC_WEIGHT_LIGHT + FC_WEIGHT_MEDIUM) / 2)
+ else if (fc_weight < (FC_WEIGHT_LIGHT + FC_WEIGHT_REGULAR) / 2)
+ return PANGO_WEIGHT_LIGHT;
+ 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)
+ return PANGO_WEIGHT_SEMIBOLD;
+ else if (fc_weight < (FC_WEIGHT_BOLD + FC_WEIGHT_ULTRABOLD) / 2)
+ return PANGO_WEIGHT_BOLD;
+ else if (fc_weight < (FC_WEIGHT_ULTRABOLD + FC_WEIGHT_BLACK) / 2)
+ return PANGO_WEIGHT_ULTRABOLD;
+ else
+ 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 600;
+ 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
}
static PangoStyle