diff --git a/libass/ass.h b/libass/ass.h index 851be6681d..9710ae7276 100644 --- a/libass/ass.h +++ b/libass/ass.h @@ -93,6 +93,11 @@ void ass_set_line_spacing(ass_renderer_t* priv, double line_spacing); */ int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family); +/** + * \brief set font lookup defaults, don't use fontconfig even if it is available + */ +int ass_set_fonts_nofc(ass_renderer_t* priv, const char* default_font, const char* default_family); + /** * \brief render a frame, producing a list of ass_image_t * \param priv library diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index addcc82646..b9a8f42c45 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -40,8 +40,6 @@ #include #endif -extern int font_fontconfig; - struct fc_instance_s { #ifdef HAVE_FONTCONFIG FcConfig* config; @@ -155,7 +153,7 @@ char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, uint32_t code) { char* res = 0; - if (font_fontconfig < 0) { + if (!priv->config) { *index = priv->index_default; return priv->path_default; } @@ -319,16 +317,17 @@ static void process_fontdata(fc_instance_t* priv, ass_library_t* library, FT_Lib * \param path default font path * \return pointer to fontconfig private data */ -fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path) +fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path, int fc) { int rc; fc_instance_t* priv = calloc(1, sizeof(fc_instance_t)); const char* dir = library->fonts_dir; int i; - if (font_fontconfig < 0) { + if (!fc) { mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed); + priv->config = NULL; priv->path_default = strdup(path); priv->index_default = 0; return priv; diff --git a/libass/ass_fontconfig.h b/libass/ass_fontconfig.h index 3806f2468b..f5762f854b 100644 --- a/libass/ass_fontconfig.h +++ b/libass/ass_fontconfig.h @@ -32,7 +32,7 @@ typedef struct fc_instance_s fc_instance_t; -fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path); +fc_instance_t* fontconfig_init(ass_library_t* library, FT_Library ftlibrary, const char* family, const char* path, int fc); char* fontconfig_select(fc_instance_t* priv, const char* family, unsigned bold, unsigned italic, int* index, uint32_t code); void fontconfig_done(fc_instance_t* priv); diff --git a/libass/ass_mp.c b/libass/ass_mp.c index b3b3963eef..5fa2cd53c2 100644 --- a/libass/ass_mp.c +++ b/libass/ass_mp.c @@ -242,7 +242,10 @@ void ass_configure_fonts(ass_renderer_t* priv) { else if (font_fontconfig >= 0 && font_name) family = strdup(font_name); else family = 0; - ass_set_fonts(priv, path, family); + if (font_fontconfig >= 0) + ass_set_fonts(priv, path, family); + else + ass_set_fonts_nofc(priv, path, family); free(dir); free(path); diff --git a/libass/ass_render.c b/libass/ass_render.c index 05657294a7..8951af0ad0 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -2083,7 +2083,7 @@ void ass_set_line_spacing(ass_renderer_t* priv, double line_spacing) priv->settings.line_spacing = line_spacing; } -int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family) +static int ass_set_fonts_(ass_renderer_t* priv, const char* default_font, const char* default_family, int fc) { if (priv->settings.default_font) free(priv->settings.default_font); @@ -2095,11 +2095,21 @@ int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* de if (priv->fontconfig_priv) fontconfig_done(priv->fontconfig_priv); - priv->fontconfig_priv = fontconfig_init(priv->library, priv->ftlibrary, default_family, default_font); + priv->fontconfig_priv = fontconfig_init(priv->library, priv->ftlibrary, default_family, default_font, fc); return !!priv->fontconfig_priv; } +int ass_set_fonts(ass_renderer_t* priv, const char* default_font, const char* default_family) +{ + return ass_set_fonts_(priv, default_font, default_family, 1); +} + +int ass_set_fonts_nofc(ass_renderer_t* priv, const char* default_font, const char* default_family) +{ + return ass_set_fonts_(priv, default_font, default_family, 0); +} + /** * \brief Start a new frame */