diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-12-09 15:05:21 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-12-15 17:38:00 +0100 |
commit | fab9febdc3a863c157a56cc4de2418cbb9665844 (patch) | |
tree | 8c442f1f04d67587d91f7f5427d5c90d7a99ff0e /sub/ass_mp.c | |
parent | c7bf5111c7db05dc5b1750ff285e343849293dd3 (diff) | |
download | mpv-fab9febdc3a863c157a56cc4de2418cbb9665844.tar.bz2 mpv-fab9febdc3a863c157a56cc4de2418cbb9665844.tar.xz |
path: add mp_find_config_file and reorganize some of the code
Add `mp_find_config_file` to search different known paths and use that in
ass_mp to look for the fontconfig configuration file.
Some incidental changes spawned by this feature where:
* Buffer allocation for the strings containing the paths is now performed
with talloc. All of the allocations are done on a NULL context, but it still
improves readability of the code.
* Move the OSX function for lookup inside of a bundle: this code path was
currently not used by the bundle generated with `make osxbundle`. The plan
is to use it again in a future commit to get a fontconfig config file.
Diffstat (limited to 'sub/ass_mp.c')
-rw-r--r-- | sub/ass_mp.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 36e03fb2d6..c992f017f7 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -255,23 +255,18 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts) { - char *default_font = get_path("subfont.ttf"); - char *config = get_path("fonts.conf"); + char *default_font = mp_find_user_config_file("subfont.ttf"); + char *config = mp_find_config_file("fonts.conf"); if (!mp_path_exists(default_font)) { - free(default_font); + talloc_free(default_font); default_font = NULL; } - if (!mp_path_exists(config)) { - free(config); - config = NULL; - } - ass_set_fonts(priv, default_font, opts->font, 1, config, 1); - free(default_font); - free(config); + talloc_free(default_font); + talloc_free(config); } void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time, @@ -332,11 +327,11 @@ static void message_callback(int level, const char *format, va_list va, void *ct ASS_Library *mp_ass_init(struct MPOpts *opts) { ASS_Library *priv; - char *path = get_path("fonts"); + char *path = mp_find_user_config_file("fonts"); priv = ass_library_init(); ass_set_message_cb(priv, message_callback, NULL); ass_set_fonts_dir(priv, path); ass_set_extract_fonts(priv, opts->use_embedded_fonts); - free(path); + talloc_free(path); return priv; } |