diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2011-08-19 01:16:24 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2015-07-10 10:42:40 +0200 |
commit | 93c4e8ebf3dea5c9e1978f78a33cb961d6a1aaf7 (patch) | |
tree | 10adc9f34146192dafdf6ab158f4022ed2acff3f /libass/ass_fontconfig.c | |
parent | 986605e29d9d8c7a0d0aeac8f53fc556097334d6 (diff) | |
download | libass-93c4e8ebf3dea5c9e1978f78a33cb961d6a1aaf7.tar.bz2 libass-93c4e8ebf3dea5c9e1978f78a33cb961d6a1aaf7.tar.xz |
Use TrueType font weight scale
fontconfig uses an unusual scale from 0-215 for the font weight. It
looks like it is somewhat derived from the typographic scale some font
families use, but is still rather nonstandard. Nowadays the TrueType
scale from 100-900 seems to be standard. CSS uses it, for example.
However, most importantly, VSFilter also uses the TrueType scale. So
let's use it in libass, too.
Diffstat (limited to 'libass/ass_fontconfig.c')
-rw-r--r-- | libass/ass_fontconfig.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index c65cd20..a3a371a 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -71,7 +71,7 @@ static void scan_fonts(FcConfig *config, ASS_FontProvider *provider) for (i = 0; i < fonts->nfont; i++) { FcPattern *pat = fonts->fonts[i]; FcBool outline; - int index; + int index, weight; char *path; char *fullnames[MAX_FULLNAME]; @@ -82,11 +82,21 @@ static void scan_fonts(FcConfig *config, ASS_FontProvider *provider) // simple types result = FcPatternGetInteger(pat, FC_SLANT, 0, &meta.slant); - result |= FcPatternGetInteger(pat, FC_WEIGHT, 0, &meta.weight); + result |= FcPatternGetInteger(pat, FC_WEIGHT, 0, &weight); result |= FcPatternGetInteger(pat, FC_INDEX, 0, &index); if (result != FcResultMatch) continue; + // fontconfig uses its own weight scale, apparently derived + // from typographical weight. we're using truetype weights, so + // convert appropriately + if (weight <= FC_WEIGHT_LIGHT) + meta.weight = FONT_WEIGHT_LIGHT; + else if (weight <= FC_WEIGHT_MEDIUM) + meta.weight = FONT_WEIGHT_MEDIUM; + else + meta.weight = FONT_WEIGHT_BOLD; + // family name // HACK: get the last family name. that fixes fonts // like Arial Narrow in some versions |