Support FC_WIDTH as double as well

This commit is contained in:
Behdad Esfahbod 2018-01-03 16:51:18 +00:00
parent 1fa9cb78c1
commit 37fb4a989e
1 changed files with 7 additions and 9 deletions

View File

@ -1172,7 +1172,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
FcPattern *pat;
int slant = -1;
double weight = -1;
int width = -1;
double width = -1;
FcBool decorative = FcFalse;
FcBool variable = FcFalse;
FcBool variable_weight = FcFalse;
@ -1695,10 +1695,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
printf ("\tos2 weight class %d multiplier %g maps to weight %g\n",
os2->usWeightClass, weight_mult, weight);
/* TODO:
* Add FcWidthFromOpenTypeDouble and FcWidthToOpenTypeDouble,
* and apply width_mult post-conversion? */
switch ((int) (os2->usWidthClass * width_mult + .5)) {
switch (os2->usWidthClass) {
case 1: width = FC_WIDTH_ULTRACONDENSED; break;
case 2: width = FC_WIDTH_EXTRACONDENSED; break;
case 3: width = FC_WIDTH_CONDENSED; break;
@ -1709,8 +1706,9 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
case 8: width = FC_WIDTH_EXTRAEXPANDED; break;
case 9: width = FC_WIDTH_ULTRAEXPANDED; break;
}
width *= width_mult;
if ((FcDebug() & FC_DBG_SCANV) && width != -1)
printf ("\tos2 width class %d multiplier %g maps to width %d\n",
printf ("\tos2 width class %d multiplier %g maps to width %g\n",
os2->usWidthClass, width_mult, width);
}
if (os2 && (complex_ = FcFontCapabilities(face)))
@ -1825,7 +1823,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
{
width = FcIsWidth ((FcChar8 *) prop.u.atom);
if (FcDebug () & FC_DBG_SCANV)
printf ("\tsetwidth %s maps to %d\n", prop.u.atom, width);
printf ("\tsetwidth %s maps to %g\n", prop.u.atom, width);
}
}
#endif
@ -1845,7 +1843,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
{
width = FcContainsWidth (style);
if (FcDebug() & FC_DBG_SCANV)
printf ("\tStyle %s maps to width %d\n", style, width);
printf ("\tStyle %s maps to width %g\n", style, width);
}
if (slant == -1)
{
@ -1890,7 +1888,7 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
if (!variable_weight && !FcPatternAddDouble (pat, FC_WEIGHT, weight))
goto bail1;
if (!variable_width && !FcPatternAddInteger (pat, FC_WIDTH, width))
if (!variable_width && !FcPatternAddDouble (pat, FC_WIDTH, width))
goto bail1;
if (!FcPatternAddString (pat, FC_FOUNDRY, foundry))