summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.c
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-02 22:01:37 +0100
committerGrigori Goronzy <greg@chown.ath.cx>2015-07-10 10:42:40 +0200
commitb0776d353f8c3396165effd21e113c4f225daa0d (patch)
treedf9fb1911caa7736b4cf3a6675f3b1357ab75821 /libass/ass_fontselect.c
parent9014b275e9e90d796bee95249a6059e4a55f3cf9 (diff)
downloadlibass-b0776d353f8c3396165effd21e113c4f225daa0d.tar.bz2
libass-b0776d353f8c3396165effd21e113c4f225daa0d.tar.xz
fontselect: coretext: allow to match fontname using the provider
Not all APIs cache everything the same way that fontconfig does. This allows to first perform a match based on the font name and then score the matched fonts using the common code using and in memory database approach. The benefit is the application doesn't have to load all of the fonts and query for weight, slant, width, path and fullnames. I left both code paths inside ass_coretext.c. This allows to test matching problems and have a term of comparison with the slower implementation. To activate it one just has to flip the CT_FONTS_EAGER_LOAD define to 1. Here are some benchmarks with a pretty typical OS X font library of ~600 fonts and using Libass's test program to load a script with 'Helvetica Neue': CT_FONTS_EAGER_LOAD=0 0.04s user 0.02s system 79% cpu 0.081 total CT_FONTS_EAGER_LOAD=1 0.12s user 0.06s system 44% cpu 0.420 total
Diffstat (limited to 'libass/ass_fontselect.c')
-rw-r--r--libass/ass_fontselect.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 799ad02..52ef192 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -465,9 +465,15 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library,
{
int num_fonts = priv->n_font;
int idx = 0;
- ASS_FontInfo *font_infos = priv->font_infos;
ASS_FontInfo req;
char *req_fullname;
+ char *tfamily = trim_space(strdup(family));
+
+ ASS_FontProvider *default_provider = priv->default_provider;
+ if (default_provider && default_provider->funcs.match_fonts)
+ default_provider->funcs.match_fonts(library, default_provider, tfamily);
+
+ ASS_FontInfo *font_infos = priv->font_infos;
// do we actually have any fonts?
if (!priv->n_font)
@@ -480,7 +486,7 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library,
req.width = 100;
req.n_fullname = 1;
req.fullnames = &req_fullname;
- req.fullnames[0] = trim_space(strdup(family));
+ req.fullnames[0] = tfamily;
// calculate similarities
font_info_req_similarity(font_infos, num_fonts, &req);