diff options
author | wm4 <wm4@nowhere> | 2015-08-28 13:56:51 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-08-28 14:06:56 +0200 |
commit | d164226a4c1c6c29951819862d505161065eed6f (patch) | |
tree | c25c52f758ba1b39a92aa66dab65cf25c72ef591 | |
parent | db1c6fd2a34c331825bfb6cbdef313fa9e64528e (diff) | |
download | libass-d164226a4c1c6c29951819862d505161065eed6f.tar.bz2 libass-d164226a4c1c6c29951819862d505161065eed6f.tar.xz |
fontselect: minor cleanup
Use a pointer to the selected font info, instead of an index. Makes the
code a bit more readable.
-rw-r--r-- | libass/ass_fontselect.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c index a603fbc..cafe05e 100644 --- a/libass/ass_fontselect.c +++ b/libass/ass_fontselect.c @@ -461,12 +461,11 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library, int *index, char **postscript_name, int *uid, ASS_FontStream *stream, uint32_t code) { - int idx = -1; ASS_FontInfo req = {0}; char *family_trim = strdup_trimmed(family); ASS_FontProvider *default_provider = priv->default_provider; - ASS_FontInfo *font_infos = priv->font_infos; ASS_FontProviderMetaData meta = {0}; + ASS_FontInfo *selected = NULL; if (family_trim == NULL) return NULL; @@ -527,7 +526,7 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library, continue; score_min = score; - idx = x; + selected = font; } // Lowest possible score instantly matches; this is typical @@ -541,25 +540,25 @@ static char *select_font(ASS_FontSelector *priv, ASS_Library *library, free(family_trim); // found anything? - if (idx < 0) { + if (!selected) { return NULL; } // successfully matched, set up return values - *postscript_name = font_infos[idx].postscript_name; - *index = font_infos[idx].index; - *uid = font_infos[idx].uid; + *postscript_name = selected->postscript_name; + *index = selected->index; + *uid = selected->uid; // set up memory stream if there is no path - if (font_infos[idx].path == NULL) { - ASS_FontProvider *provider = font_infos[idx].provider; + if (selected->path == NULL) { + ASS_FontProvider *provider = selected->provider; stream->func = provider->funcs.get_data; - stream->priv = font_infos[idx].priv; + stream->priv = selected->priv; // FIXME: we should define a default family name in some way, // possibly the first (or last) English name - return strdup(font_infos[idx].families[0]); + return strdup(selected->families[0]); } else - return strdup(font_infos[idx].path); + return strdup(selected->path); } |