[MPlayer-cvslog] r26614 - in trunk/libass: ass.h ass_fontconfig.c ass_fontconfig.h ass_mp.c ass_render.c

eugeni subversion at mplayerhq.hu
Wed Apr 30 16:16:22 CEST 2008


Author: eugeni
Date: Wed Apr 30 16:16:22 2008
New Revision: 26614

Log:
Remove libass dependency on global font_fontconfig variable.

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


Modified:
   trunk/libass/ass.h
   trunk/libass/ass_fontconfig.c
   trunk/libass/ass_fontconfig.h
   trunk/libass/ass_mp.c
   trunk/libass/ass_render.c

Modified: trunk/libass/ass.h
==============================================================================
--- trunk/libass/ass.h	(original)
+++ trunk/libass/ass.h	Wed Apr 30 16:16:22 2008
@@ -94,6 +94,11 @@ void ass_set_line_spacing(ass_renderer_t
 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
  * \param track subtitle track

Modified: trunk/libass/ass_fontconfig.c
==============================================================================
--- trunk/libass/ass_fontconfig.c	(original)
+++ trunk/libass/ass_fontconfig.c	Wed Apr 30 16:16:22 2008
@@ -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* p
 			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
  * \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;

Modified: trunk/libass/ass_fontconfig.h
==============================================================================
--- trunk/libass/ass_fontconfig.h	(original)
+++ trunk/libass/ass_fontconfig.h	Wed Apr 30 16:16:22 2008
@@ -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);
 

Modified: trunk/libass/ass_mp.c
==============================================================================
--- trunk/libass/ass_mp.c	(original)
+++ trunk/libass/ass_mp.c	Wed Apr 30 16:16:22 2008
@@ -242,7 +242,10 @@ void ass_configure_fonts(ass_renderer_t*
 	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);

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Wed Apr 30 16:16:22 2008
@@ -2083,7 +2083,7 @@ void ass_set_line_spacing(ass_renderer_t
 	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, 
 
 	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
  */



More information about the MPlayer-cvslog mailing list