]> granicus.if.org Git - libass/commitdiff
fontselect: use designated initializers
authorwm4 <wm4@nowhere>
Tue, 1 Sep 2015 12:08:47 +0000 (14:08 +0200)
committerwm4 <wm4@nowhere>
Tue, 1 Sep 2015 12:08:47 +0000 (14:08 +0200)
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.

libass/ass_coretext.c
libass/ass_directwrite.c
libass/ass_fontconfig.c
libass/ass_fontselect.c
libass/ass_fontselect.h

index 35f10ffd5fe9145242f90d1d9795ca514525744c..00d4c45073c6a9e05e550705a668b966e3835965 100644 (file)
@@ -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 *
index fb21d5ceac56724bd6ec280778c7ceaf17e5de66..1ef061674adc8a7f479d8fc1bb928556c3218c8a 100644 (file)
@@ -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)(
index 0c89d36ec1ce3f9a8098fa1c5ae79b411c9fd3db..e65e413dddce05861995384443dd2d0a3453189d 100644 (file)
@@ -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 *
index 02d0bc42d27c3b2a0d8f3a74861f5ea70a7201f9..ab40bd54a62575f7ca82c7e2ab3f7d516d258246 100644 (file)
@@ -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) {
index 2c03a1668f84ef964cf58a97bfad2b7f23aa0975..f420935b28475066f5b7a5d142bb28b6a0469ef6 100644 (file)
@@ -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;
 
 /*