Convert OpenType weight to Fontconfig weight in font collector

Fixes #108
This commit is contained in:
Myaamori 2021-03-05 15:42:37 +00:00 committed by Ryan Lucia
parent 7a27ee7823
commit 4b2cd7f170

View file

@ -63,8 +63,8 @@ CollectionResult FontConfigFontFileLister::GetFontPaths(std::string const& facen
std::string family = facename[0] == '@' ? facename.substr(1) : facename; std::string family = facename[0] == '@' ? facename.substr(1) : facename;
boost::to_lower(family); boost::to_lower(family);
int weight = bold == 0 ? 80 : int weight = bold == 0 ? 400 :
bold == 1 ? 200 : bold == 1 ? 700 :
bold; bold;
int slant = italic ? 110 : 0; int slant = italic ? 110 : 0;
@ -74,7 +74,7 @@ CollectionResult FontConfigFontFileLister::GetFontPaths(std::string const& facen
FcPatternAddBool(pat, FC_OUTLINE, true); FcPatternAddBool(pat, FC_OUTLINE, true);
FcPatternAddInteger(pat, FC_SLANT, slant); FcPatternAddInteger(pat, FC_SLANT, slant);
FcPatternAddInteger(pat, FC_WEIGHT, weight); FcPatternAddInteger(pat, FC_WEIGHT, FcWeightFromOpenType(weight));
FcDefaultSubstitute(pat); FcDefaultSubstitute(pat);
if (!FcConfigSubstitute(config, pat, FcMatchPattern)) return ret; if (!FcConfigSubstitute(config, pat, FcMatchPattern)) return ret;