diff libass/ass_fontconfig.c @ 25351:f46e91c64b39

Fix libass to support -nofontconfig. For history reason, fontconfig is auto-enabled when ass is enabled, we keep this behavior and document it clearly.
author ulion
date Wed, 12 Dec 2007 10:00:34 +0000
parents 3b830c7e0eb2
children 62ac4f8062ee
line wrap: on
line diff
--- a/libass/ass_fontconfig.c	Wed Dec 12 08:50:54 2007 +0000
+++ b/libass/ass_fontconfig.c	Wed Dec 12 10:00:34 2007 +0000
@@ -40,6 +40,8 @@
 #include <fontconfig/fcfreetype.h>
 #endif
 
+extern int font_fontconfig;
+
 struct fc_instance_s {
 #ifdef HAVE_FONTCONFIG
 	FcConfig* config;
@@ -153,6 +155,10 @@
 			uint32_t code)
 {
 	char* res = 0;
+	if (font_fontconfig < 0) {
+		*index = priv->index_default;
+		return priv->path_default;
+	}
 	if (family && *family)
 		res = _select_font(priv, family, bold, italic, index, code);
 	if (!res && priv->family_default) {
@@ -320,6 +326,14 @@
 	const char* dir = library->fonts_dir;
 	int i;
 	
+	if (font_fontconfig < 0) {
+		mp_msg(MSGT_ASS, MSGL_WARN,
+		       MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
+		priv->path_default = strdup(path);
+		priv->index_default = 0;
+		return priv;
+	}
+
 	rc = FcInit();
 	assert(rc);