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_fontselect.h | |
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_fontselect.h')
-rw-r--r-- | libass/ass_fontselect.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h index c989e1a..1e0959e 100644 --- a/libass/ass_fontselect.h +++ b/libass/ass_fontselect.h @@ -177,6 +177,37 @@ struct ass_font_stream { void *priv; }; + +typedef struct ass_font_mapping ASS_FontMapping; + +struct ass_font_mapping { + const char *from; + const char *to; +}; + +/** + * Simple font substitution helper. This can be used to implement basic + * mappings from one name to another. This is useful for supporting + * generic font families in font providers. + * + * \param map list of mappings + * \param len length of list of mappings + * \param name font name to map from + * \param meta metadata struct, mapped fonts will be stored into this + */ +inline void ass_map_font(const ASS_FontMapping *map, int len, const char *name, + ASS_FontProviderMetaData *meta) +{ + for (int i = 0; i < len; i++) { + if (strcasecmp(map[i].from, name) == 0) { + meta->n_fullname = 1; + meta->fullnames = calloc(1, sizeof(char *)); + meta->fullnames[0] = strdup(map[i].to); + return; + } + } +} + ASS_FontSelector * ass_fontselect_init(ASS_Library *library, FT_Library ftlibrary, const char *family, |