From 9201cfe2bda3904ad34b51234a2802a788ad4148 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 9 Dec 2012 12:45:05 +0100 Subject: [PATCH] ass_mp: allow to use a custom fontconfig configuration file This allows to use a fontconfig fonts.conf that is customized for mpv. The configuration file is assumed to be located at `~/.mpv/fonts.conf`. If not found the default fcontconfig config file is used. --- sub/ass_mp.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 079afbe17e..36e03fb2d6 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -255,18 +255,23 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts) { - char *dir, *path; - dir = get_path("fonts"); - path = get_path("subfont.ttf"); - if (!mp_path_exists(path)) { - free(path); - path = NULL; + char *default_font = get_path("subfont.ttf"); + char *config = get_path("fonts.conf"); + + if (!mp_path_exists(default_font)) { + free(default_font); + default_font = NULL; } - ass_set_fonts(priv, path, opts->font, 1, NULL, 1); + if (!mp_path_exists(config)) { + free(config); + config = NULL; + } - free(dir); - free(path); + ass_set_fonts(priv, default_font, opts->font, 1, config, 1); + + free(default_font); + free(config); } void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time,