summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-01 00:34:26 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-01 00:34:26 +0000
commit54d3bcce0b2f964494db7e4d25509a499af849dc (patch)
treed5b75dc8b332703a3c220008ab97bad7f5d32b2c /libass
parentcbc297c09d289e585990fa57962b13a97eeb15b8 (diff)
downloadmpv-54d3bcce0b2f964494db7e4d25509a499af849dc.tar.bz2
mpv-54d3bcce0b2f964494db7e4d25509a499af849dc.tar.xz
Allow inexact font family matching.
In SSA/ASS fonts are sometimes referenced by their "full name", which is usually a concatenation of family name and font style (ex. Ottawa Bold). Full name is available from FontConfig pattern element FC_FULLNAME, but it is never used for font matching. Therefore, I'm removing words from the end of the name one by one, and adding shortened names to the pattern. It seems that the first value (full name in this case) has precedence in matching. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26623 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_fontconfig.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c
index b9a8f42c45..48b24ad979 100644
--- a/libass/ass_fontconfig.c
+++ b/libass/ass_fontconfig.c
@@ -81,6 +81,26 @@ static char* _select_font(fc_instance_t* priv, const char* family, unsigned bold
goto error;
FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)family);
+
+ // In SSA/ASS fonts are sometimes referenced by their "full name",
+ // which is usually a concatenation of family name and font
+ // style (ex. Ottawa Bold). Full name is available from
+ // FontConfig pattern element FC_FULLNAME, but it is never
+ // used for font matching.
+ // Therefore, I'm removing words from the end of the name one
+ // by one, and adding shortened names to the pattern. It seems
+ // that the first value (full name in this case) has
+ // precedence in matching.
+ // An alternative approach could be to reimplement FcFontSort
+ // using FC_FULLNAME instead of FC_FAMILY.
+ if (strchr(family, ' ')) {
+ char *p, *s = strdup(family);
+ while (p = strrchr(s, ' ')) {
+ *p = '\0';
+ FcPatternAddString(pat, FC_FAMILY, (const FcChar8*)s);
+ }
+ free(s);
+ }
FcPatternAddBool(pat, FC_OUTLINE, FcTrue);
FcPatternAddInteger(pat, FC_SLANT, italic);
FcPatternAddInteger(pat, FC_WEIGHT, bold);