[Mplayer-cvslog] CVS: main/libvo font_load_ft.c,1.11,1.12

Alex Beregszaszi alex at mplayerhq.hu
Mon Dec 8 13:11:56 CET 2003


Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv12542/libvo

Modified Files:
	font_load_ft.c 
Log Message:
Fontconfig support based on patch by Arwed von Merkatz <v.merkatz at gmx.net>, but slightly reworked

Index: font_load_ft.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load_ft.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- font_load_ft.c	20 Nov 2003 16:25:40 -0000	1.11
+++ font_load_ft.c	8 Dec 2003 12:11:52 -0000	1.12
@@ -24,6 +24,10 @@
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
+#ifdef HAVE_FONTCONFIG
+#include <fontconfig/fontconfig.h>
+#endif
+
 #include "../bswap.h"
 #include "font_load.h"
 #include "mp_msg.h"
@@ -1113,6 +1117,11 @@
 
 void load_font_ft(int width, int height) 
 {
+#ifdef HAVE_FONTCONFIG
+    FcPattern *fc_pattern;
+    FcChar8 *s;
+    FcBool scalable;
+#endif
     vo_image_width = width;
     vo_image_height = height;
 
@@ -1122,6 +1131,30 @@
     if (vo_font) free_font_desc(vo_font);
 
 #ifdef USE_OSD
+#ifdef HAVE_FONTCONFIG
+    if (font_fontconfig)
+    {
+	if (!font_name)
+	    font_name = "sans-serif";
+	FcInit();
+	fc_pattern = FcNameParse(font_name);
+	FcConfigSubstitute(0, fc_pattern, FcMatchPattern);
+	FcDefaultSubstitute(fc_pattern);
+	fc_pattern = FcFontMatch(0, fc_pattern, 0);
+	FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable);
+	if (scalable != FcTrue) {
+    	    fc_pattern = FcNameParse("sans-serif");
+    	    FcConfigSubstitute(0, fc_pattern, FcMatchPattern);
+    	    FcDefaultSubstitute(fc_pattern);
+    	    fc_pattern = FcFontMatch(0, fc_pattern, 0);
+	}
+	// s doesn't need to be freed according to fontconfig docs
+	FcPatternGetString(fc_pattern, FC_FILE, 0, &s);
+	vo_font=read_font_desc_ft(s, width, height);
+	free(fc_pattern);
+    }
+    else
+#endif
     vo_font=read_font_desc_ft(font_name, width, height);
 #endif
 }



More information about the MPlayer-cvslog mailing list