summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2015-10-23 01:55:06 +0300
committerOleg Oshmyan <chortos@inbox.lv>2015-10-23 02:47:00 +0300
commitf16cf28b7a8275594ec8397aaa9d5ab8d178c629 (patch)
treee454419a679a9043c002d21609d958e008d7da19
parenta200f7732ab64a97c8717655bdc6df47f27a1308 (diff)
downloadlibass-f16cf28b7a8275594ec8397aaa9d5ab8d178c629.tar.bz2
libass-f16cf28b7a8275594ec8397aaa9d5ab8d178c629.tar.xz
fontselect: don't find fonts with PostScript outlines by full name
Related to commit e00691e8096cc69e5651480155ebc61d9e079290: it turns out that GDI (and hence VSFilter) does not check full names of fonts that have PostScript outlines when searching for a font by name. To summarize the resulting behavior: * Fonts with PostScript outlines can be found by family name and by PostScript name. * Fonts without PostScript outlines can be found by family name and by full name.
-rw-r--r--libass/ass_fontselect.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index e179ed9..ce24f7e 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -419,25 +419,21 @@ static bool matches_family_name(ASS_FontInfo *f, const char *family)
}
/**
- * \brief Return whether the given font has the given fullname.
+ * \brief Return whether the given font has the given fullname or
+ * PostScript name depending on whether it has PostScript outlines.
*/
-static bool matches_fullname(ASS_FontInfo *f, const char *fullname)
+static bool matches_full_or_postscript_name(ASS_FontInfo *f,
+ const char *fullname)
{
- for (int i = 0; i < f->n_fullname; i++) {
- if (ass_strcasecmp(f->fullnames[i], fullname) == 0)
- return true;
- }
- return false;
-}
-
-/**
- * \brief Return whether the given font has the given PostScript name.
- */
-static bool matches_postscript_name(ASS_FontInfo *f, const char *name)
-{
- if (f->is_postscript && f->postscript_name) {
- if (ass_strcasecmp(f->postscript_name, name) == 0)
+ if (f->is_postscript) {
+ if (f->postscript_name != NULL &&
+ ass_strcasecmp(f->postscript_name, fullname) == 0)
return true;
+ } else {
+ for (int i = 0; i < f->n_fullname; i++) {
+ if (ass_strcasecmp(f->fullnames[i], fullname) == 0)
+ return true;
+ }
}
return false;
}
@@ -527,8 +523,7 @@ find_font(ASS_FontSelector *priv, ASS_Library *library,
// to determine best match in that particular family
score = font_attributes_similarity(font, &req);
*name_match = true;
- } else if (matches_fullname(font, fullname) ||
- matches_postscript_name(font, fullname)) {
+ } else if (matches_full_or_postscript_name(font, fullname)) {
// If we don't have any match, compare fullnames against request
// if there is a match now, assign lowest score possible. This means
// the font should be chosen instantly, without further search.