diff options
author | wm4 <wm4@nowhere> | 2015-09-01 14:08:47 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-09-01 14:08:47 +0200 |
commit | 888c644420b138875bf5e9f956d926b0be784eae (patch) | |
tree | 6dd0a1184f3239e4dab7188995061d96da9fd8b0 /libass | |
parent | 72f751e3a5693ed2b7e935cb6c31ce18eed8d7b0 (diff) | |
download | libass-888c644420b138875bf5e9f956d926b0be784eae.tar.bz2 libass-888c644420b138875bf5e9f956d926b0be784eae.tar.xz |
fontselect: use designated initializers
Tired of matching the names and order of the callbacks in my head.
While we're at it, also give some of the callbacks better names.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_coretext.c | 15 | ||||
-rw-r--r-- | libass/ass_directwrite.c | 12 | ||||
-rw-r--r-- | libass/ass_fontconfig.c | 11 | ||||
-rw-r--r-- | libass/ass_fontselect.c | 9 | ||||
-rw-r--r-- | libass/ass_fontselect.h | 18 |
5 files changed, 28 insertions, 37 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c index 35f10ff..00d4c45 100644 --- a/libass/ass_coretext.c +++ b/libass/ass_coretext.c @@ -287,17 +287,12 @@ static char *get_fallback(void *priv, ASS_FontProviderMetaData *meta, } static ASS_FontProviderFuncs coretext_callbacks = { - NULL, - check_glyph, - destroy_font, - NULL, -#if CT_FONTS_EAGER_LOAD - NULL, -#else - match_fonts, + .check_glyph = check_glyph, + .destroy_font = destroy_font, +#if !CT_FONTS_EAGER_LOAD + .match_fonts = match_fonts, #endif - NULL, - get_fallback + .get_fallback = get_fallback, }; ASS_FontProvider * diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c index fb21d5c..1ef0616 100644 --- a/libass/ass_directwrite.c +++ b/libass/ass_directwrite.c @@ -628,13 +628,11 @@ static void scan_fonts(IDWriteFactory *factory, * specified task */ static ASS_FontProviderFuncs directwrite_callbacks = { - get_data, - check_glyph, - destroy_font, - destroy_provider, - NULL, - NULL, - get_fallback + .get_data = get_data, + .check_glyph = check_glyph, + .destroy_font = destroy_font, + .destroy_provider = destroy_provider, + .get_fallback = get_fallback, }; typedef HRESULT WINAPI (*DWriteCreateFactoryFn)( diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index 0c89d36..e65e413 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -242,13 +242,10 @@ cleanup: } static ASS_FontProviderFuncs fontconfig_callbacks = { - NULL, - check_glyph, - NULL, - destroy, - NULL, - get_substitutions, - get_fallback + .check_glyph = check_glyph, + .destroy_provider = destroy, + .get_substitutions = get_substitutions, + .get_fallback = get_fallback, }; ASS_FontProvider * diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c index 02d0bc4..ab40bd5 100644 --- a/libass/ass_fontselect.c +++ b/libass/ass_fontselect.c @@ -514,8 +514,9 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library, }; // get a list of substitutes if applicable, and use it for matching - if (default_provider && default_provider->funcs.subst_font) { - default_provider->funcs.subst_font(default_provider->priv, family_trim, &meta); + if (default_provider && default_provider->funcs.get_substitutions) { + default_provider->funcs.get_substitutions(default_provider->priv, + family_trim, &meta); } if (!meta.n_fullname) { meta = default_meta; @@ -634,13 +635,13 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library, family, bold, italic, res, *index, *postscript_name); } - if (!res && default_provider && default_provider->funcs.fallback_font) { + if (!res && default_provider && default_provider->funcs.get_fallback) { ASS_FontProviderMetaData meta; meta.families = &family; meta.weight = bold; meta.slant = italic; meta.width = 100; - char *fallback_family = default_provider->funcs.fallback_font( + char *fallback_family = default_provider->funcs.get_fallback( default_provider->priv, &meta, code); if (fallback_family) { diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h index 2c03a16..f420935 100644 --- a/libass/ass_fontselect.h +++ b/libass/ass_fontselect.h @@ -122,23 +122,23 @@ typedef void (*SubstituteFontFunc)(void *priv, const char *name, * Note that fontselect uses the font provider set as default to determine * fallbacks. * - * \param font_priv font private data + * \param priv font provider private data * \param codepoint Unicode codepoint (UTF-32) * \return output font family, allocated with malloc(), must be freed * by caller. */ -typedef char *(*GetFallbackFunc)(void *font_priv, +typedef char *(*GetFallbackFunc)(void *priv, ASS_FontProviderMetaData *meta, uint32_t codepoint); typedef struct font_provider_funcs { - GetDataFunc get_data; /* optional/mandatory */ - CheckGlyphFunc check_glyph; /* mandatory */ - DestroyFontFunc destroy_font; /* optional */ - DestroyProviderFunc destroy_provider; /* optional */ - MatchFontsFunc match_fonts; /* optional */ - SubstituteFontFunc subst_font; /* optional */ - GetFallbackFunc fallback_font; /* optional */ + GetDataFunc get_data; /* optional/mandatory */ + CheckGlyphFunc check_glyph; /* mandatory */ + DestroyFontFunc destroy_font; /* optional */ + DestroyProviderFunc destroy_provider; /* optional */ + MatchFontsFunc match_fonts; /* optional */ + SubstituteFontFunc get_substitutions; /* optional */ + GetFallbackFunc get_fallback; /* optional */ } ASS_FontProviderFuncs; /* |