1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 15:52:25 +00:00

Remove libass dependency on global font_fontconfig variable.

A new function (ass_set_fonts_nofc) is introduced instead of an extra argument
to existing ass_set_fonts to keep binary compatibility with older versions of
the library.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26614 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
eugeni 2008-04-30 14:16:22 +00:00
parent 6671a91eaf
commit f1e8cbf643
5 changed files with 26 additions and 9 deletions

View File

@ -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

View File

@ -40,8 +40,6 @@
#include <fontconfig/fcfreetype.h>
#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;

View File

@ -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);

View File

@ -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);

View File

@ -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
*/