From fab9febdc3a863c157a56cc4de2418cbb9665844 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 9 Dec 2012 15:05:21 +0100 Subject: 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. --- sub/ass_mp.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'sub/ass_mp.c') 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; } -- cgit v1.2.3