diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-01 15:47:40 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-02 20:24:01 +0200 |
commit | 6c8348a598cd79874007e233b6f0f409185093b1 (patch) | |
tree | 6d20c708c4f48af09b722e17a53d8affe826418d /libass/ass_coretext.c | |
parent | fda28f6106caf7d450847444a363adc042b325b9 (diff) | |
download | libass-6c8348a598cd79874007e233b6f0f409185093b1.tar.bz2 libass-6c8348a598cd79874007e233b6f0f409185093b1.tar.xz |
directwrite, coretext: implement substitutions
This adds simple and sensible substitutions for generic font family
names. A helper function is introduced to reduce code duplication.
Diffstat (limited to 'libass/ass_coretext.c')
-rw-r--r-- | libass/ass_coretext.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c index 3553324..877018d 100644 --- a/libass/ass_coretext.c +++ b/libass/ass_coretext.c @@ -25,6 +25,12 @@ #define SAFE_CFRelease(x) do { if (x) CFRelease(x); } while(0) +static const ASS_FontMapping font_substitutions[] = { + {"sans-serif", "Helvetica"}, + {"serif", "Times"}, + {"monospace", "Courier"} +}; + static char *cfstr2buf(CFStringRef string) { const int encoding = kCFStringEncodingUTF8; @@ -266,10 +272,18 @@ static char *get_fallback(void *priv, const char *family, uint32_t codepoint) return res_family; } +static void get_substitutions(void *priv, const char *name, + ASS_FontProviderMetaData *meta) +{ + const int n = sizeof(font_substitutions) / sizeof(font_substitutions[0]); + ass_map_font(font_substitutions, n, name, meta); +} + static ASS_FontProviderFuncs coretext_callbacks = { .check_glyph = check_glyph, .destroy_font = destroy_font, .match_fonts = match_fonts, + .get_substitutions = get_substitutions, .get_fallback = get_fallback, }; |