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_directwrite.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_directwrite.c')
-rw-r--r-- | libass/ass_directwrite.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c index 86b0b4b..f11deb6 100644 --- a/libass/ass_directwrite.c +++ b/libass/ass_directwrite.c @@ -31,6 +31,12 @@ #define NAME_MAX_LENGTH 256 #define FALLBACK_DEFAULT_FONT L"Arial" +static const ASS_FontMapping font_substitutions[] = { + {"sans-serif", "Arial"}, + {"serif", "Times New Roman"}, + {"monospace", "Courier New"} +}; + /* * The private data stored for every font, detected by this backend. */ @@ -624,6 +630,13 @@ static void scan_fonts(IDWriteFactory *factory, } } +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); +} + /* * Called by libass when the provider should perform the * specified task @@ -633,6 +646,7 @@ static ASS_FontProviderFuncs directwrite_callbacks = { .check_glyph = check_glyph, .destroy_font = destroy_font, .destroy_provider = destroy_provider, + .get_substitutions = get_substitutions, .get_fallback = get_fallback, }; |