Commit 40f5c151 authored by Behdad Esfahbod's avatar Behdad Esfahbod
Browse files

[fc] Use FcWeightTo/FromOpenType() if available

This makes the weight mapping a continuous, as ooposed to a step function.

Last piece of Bug 733764 - Support more / free font weights
parent b30a0470
......@@ -224,6 +224,12 @@ have_fontconfig=false
if $have_harfbuzz ; then
PKG_CHECK_MODULES(FONTCONFIG, fontconfig >= 2.10.91, have_fontconfig=true, AC_MSG_RESULT([no]))
fi
if $have_fontconfig ; then
pango_save_libs=$LIBS
LIBS="$LIBS $FONTCONFIG_LIBS"
AC_CHECK_FUNCS(FcWeightFromOpenType)
LIBS=$pango_save_libs
fi
#
# Checks for FreeType
......
......@@ -1375,6 +1375,9 @@ pango_fc_font_map_list_families (PangoFontMap *fontmap,
static int
pango_fc_convert_weight_to_fc (PangoWeight pango_weight)
{
#ifdef HAVE_FCWEIGHTFROMOPENTYPE
return FcWeightFromOpenType (pango_weight);
#else
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)
......@@ -1399,6 +1402,7 @@ pango_fc_convert_weight_to_fc (PangoWeight pango_weight)
return FC_WEIGHT_BLACK;
else
return FC_WEIGHT_EXTRABLACK;
#endif
}
static int
......@@ -2061,6 +2065,9 @@ pango_fc_font_map_shutdown (PangoFcFontMap *fcfontmap)
static PangoWeight
pango_fc_convert_weight_to_pango (int fc_weight)
{
#ifdef HAVE_FCWEIGHTFROMOPENTYPE
return FcWeightToOpenType (fc_weight);
#else
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)
......@@ -2085,6 +2092,7 @@ pango_fc_convert_weight_to_pango (int fc_weight)
return PANGO_WEIGHT_HEAVY;
else
return PANGO_WEIGHT_ULTRAHEAVY;
#endif
}
static PangoStyle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment