summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-09 19:09:09 +0100
committerGrigori Goronzy <greg@chown.ath.cx>2015-07-10 10:42:40 +0200
commite95626628eab9a892047c60e4b9926ab50ce1bd4 (patch)
tree94c198b57158dc8a08cbfae465406228f7802a4e /libass
parent24254d714139f978be83b8e658f5bd58233990d8 (diff)
downloadlibass-e95626628eab9a892047c60e4b9926ab50ce1bd4.tar.bz2
libass-e95626628eab9a892047c60e4b9926ab50ce1bd4.tar.xz
fontselect: use fallback fonts when querying font providers
51f9e80b added a MatchFontsFunc callback which allows to lookup font names directly on the font provider. This approach broke support for font fallback which worked only with lookups from libass in-memory font database. This commit moves the font fallback code in the font lookup function, so that it is available for all font providers.
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_fontselect.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 52ef192..f804c94 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -371,7 +371,6 @@ static unsigned font_info_similarity(ASS_FontInfo *a, ASS_FontInfo *req)
{
int i, j;
unsigned similarity = 0;
- const char **fallback = fallback_fonts;
// compare fullnames
// a matching fullname is very nice and instantly drops the score to zero
@@ -392,15 +391,6 @@ static unsigned font_info_similarity(ASS_FontInfo *a, ASS_FontInfo *req)
}
}
- // nothing found? Try fallback fonts
- while (similarity > 0 && *fallback) {
- for (i = 0; i < a->n_family; i++) {
- if (strcmp(a->families[i], *fallback) == 0)
- similarity = 5000;
- }
- fallback++;
- }
-
// compare slant
similarity += ABS(a->slant - req->slant);
@@ -571,15 +561,18 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library,
res, *index, *postscript_name);
}
- // FIXME: not sure if that is needed, we cannot reach this path at the
- // moment, either select_font returns or a font or the default one is used
if (!res) {
- res = select_font(priv, library, "Arial", bold, italic,
- index, postscript_name, uid, data, code);
- if (res)
- ass_msg(library, MSGL_WARN, "fontselect: Using 'Arial' "
- "font family: (%s, %d, %d) -> %s, %d, %s", family, bold,
- italic, res, *index, *postscript_name);
+ // This code path is reached when the script uses glyphs not
+ // available in the previous fonts (or no font is matched), and
+ // the ASS_FontProvider used provides only the MatchFontsFunc callback
+ for (int i = 0; fallback_fonts[i] && !res; i++) {
+ res = select_font(priv, library, fallback_fonts[i], bold,
+ italic, index, postscript_name, uid, data, code);
+ if (res)
+ ass_msg(library, MSGL_WARN, "fontselect: Using fallback "
+ "font family: (%s, %d, %d) -> %s, %d, %s",
+ family, bold, italic, res, *index, *postscript_name);
+ }
}
if (res)