[MPlayer-dev-eng] Fontconfig support for mplayer

Arwed von Merkatz v.merkatz at gmx.net
Fri Apr 18 16:31:44 CEST 2003


Hi,

i added fontconfig support to mplayer, with the attached patch (one of
them applies to MPlayer 0.90, the other to the cvs), you can specify the
subtitle/osd font with -font <fontconfig font name>, e.g. mplayer -font
'Bitstream Vera Sans', or mplayer -font arial.

The patch adds a configure check for fontconfig, and it contains
fallbacks to sans-serif if no font is given, or if the given font name
doesn't map to a scalable (truetype or type1) font.

I also added the info about how to use it to the english and german
versions of the man page and the documentation.html.

The gui should probably have a drop down font chooser instead of the
Browse for font option if compiled with fontconfig support, but i'm not
experienced in gtk1 programming, so i left that one out.

-- 
Arwed v. Merkatz
Grimoire Guru for video
Sourcemage GNU/Linux
http://www.sourcemage.org
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.262
diff -u -r1.262 Makefile
--- Makefile	29 Mar 2003 14:37:23 -0000	1.262
+++ Makefile	18 Apr 2003 14:41:30 -0000
@@ -36,9 +36,9 @@
 VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) 
 AO_LIBS = $(ARTS_LIB) $(ESD_LIB) $(NAS_LIB) $(SGIAUDIO_LIB)
 CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(DECORE_LIB) $(XVID_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB)
-COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
+COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(FONTCONFIG_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
 
-CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(FRIBIDI_INC) # -Wall
+CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(FONTCONFIG_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(FRIBIDI_INC) # -Wall
 
 ifeq ($(TARGET_ALTIVEC),yes)
 ifeq ($(TARGET_OS),Darwin)
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.694
diff -u -r1.694 configure
--- configure	11 Apr 2003 16:33:29 -0000	1.694
+++ configure	18 Apr 2003 14:41:45 -0000
@@ -162,6 +162,7 @@
   --disable-css          Disable old-style libcss DVD support [autodetect]
   --disable-cdparanoia   Disable cdparanoia support [autodetect]
   --disable-freetype     Disable freetype2 font rendering support [autodetect]
+  --disable-fontconfig   Disable fontconfig font lookup support [autodetect]
   --disable-unrarlib     Disable Unique RAR File Library [enabled]
   --disable-new-conf     Disable new experimental config parser code [enabled]
   --enable-menu          Enable osd menu support (needs new config) [disabled]
@@ -1073,6 +1074,7 @@
 _cdparanoia=auto
 _big_endian=auto
 _freetype=auto
+_fontconfig=auto
 _shared_pp=no
 _new_conf=yes
 _menu=no
@@ -1267,6 +1269,8 @@
   --disable-big-endian) _big_endian=no  ;;
   --enable-freetype)    _freetype=yes   ;;
   --disable-freetype)   _freetype=no    ;;
+  --enable-fontconfig)  _fontconfig=yes ;;
+  --disable-fontconfig) _fontconfig=no  ;;
   --enable-unrarlib)	_unrarlib=yes	;;
   --disable-unrarlib)	_unrarlib=no	;;
 
@@ -3870,6 +3874,37 @@
 fi
 echores "$_freetype"
 
+echocheck "fontconfig"
+if test "$_fontconfig" = auto ; then
+    if ( pkg-config fontconfig --modversion) > /dev/null 2>&1 ; then
+        cat > $TMPC << EOF
+#include <stdio.h>
+#include <fontconfig/fontconfig.h>
+int main()
+{
+    int err = FcInit();
+    if(err == FcFalse){
+        printf("Couldn't initialize fontconfig lib\n");
+        exit(err);
+    }
+    return 0;
+    
+}
+EOF
+        _fontconfig=no
+        cc_check `pkg-config fontconfig --cflags --libs` && ( $TMPO >> "$TMPLOG" ) && _fontconfig=yes
+    else
+        _fontconfig=no
+    fi
+fi
+if test "$_fontconfig" = yes ; then
+    _def_fontconfig='#define HAVE_FONTCONFIG'
+    _inc_fontconfig=`pkg-config fontconfig --cflags`
+    _ld_fontconfig=`pkg-config fontconfig --libs`
+else
+    _def_fontconfig='#undef HAVE_FONTCONFIG'
+fi
+echores "$_fontconfig"
 
 echocheck "fribidi with charsets"
 if test "$_fribidi" = yes ; then
@@ -5200,6 +5235,8 @@
 CDPARANOIA_LIB = $_ld_cdparanoia
 FREETYPE_INC = $_inc_freetype
 FREETYPE_LIB = $_ld_freetype
+FONTCONFIG_INC = $_inc_fontconfig
+FONTCONFIG_LIB = $_ld_fontconfig
 FRIBIDI_INC = $_inc_fribidi
 FRIBIDI_LIB = $_ld_fribidi
 LIBLZO_LIB= $_ld_liblzo
@@ -5603,6 +5640,9 @@
 
 /* enable FreeType support */
 $_def_freetype
+
+/* enable Fontconfig support */
+$_def_fontconfig
 
 /* enable FriBiDi usage */
 $_def_fribidi
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.213
diff -u -r1.213 mencoder.c
--- mencoder.c	7 Apr 2003 16:03:37 -0000	1.213
+++ mencoder.c	18 Apr 2003 14:41:50 -0000
@@ -435,6 +435,10 @@
 #ifdef USE_OSD
 #ifdef HAVE_FREETYPE
   init_freetype();
+#ifdef HAVE_FONTCONFIG
+  if(!font_name)
+    font_name = "sans-serif";
+#endif
 #else
   if(font_name){
        vo_font=read_font_desc(font_name,font_factor,verbose>1);
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.691
diff -u -r1.691 mplayer.c
--- mplayer.c	7 Apr 2003 20:55:32 -0000	1.691
+++ mplayer.c	18 Apr 2003 14:42:08 -0000
@@ -1018,8 +1018,15 @@
 
 //------ load global data first ------
 
-#ifdef USE_OSD
 // check font
+#ifdef USE_OSD
+#ifdef HAVE_FREETYPE
+  init_freetype();
+#ifdef HAVE_FONTCONFIG
+  if(!font_name)
+    font_name = "sans-serif";
+#endif
+#else
   if(font_name){
        vo_font=read_font_desc(font_name,font_factor,verbose>1);
        if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
@@ -1029,9 +1036,6 @@
        if(!vo_font)
        vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1);
   }
-#ifdef HAVE_FREETYPE
-  if (!vo_font)
-	init_freetype();
 #endif
 #endif
   vo_init_osd();
Index: DOCS/de/documentation.html
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/de/documentation.html,v
retrieving revision 1.71
diff -u -r1.71 documentation.html
--- DOCS/de/documentation.html	22 Mar 2003 12:01:46 -0000	1.71
+++ DOCS/de/documentation.html	18 Apr 2003 14:42:27 -0000
@@ -1108,6 +1108,11 @@
         ~/.mplayer/subfont.ttf</CODE></LI>
     </UL>
   </LI>
+  <LI>Mit Fontconfig in Kombination mit freetype erwartet der -font parameter
+    den fontconfig Namen der Schriftart:
+    <BR>
+    <CODE>-font 'Bitstream Vera Sans'</CODE>
+  </LI>
 </UL>
 
 <P>Wenn du eine Nicht-TrueType-Schrift benutzt, dann entpacke die Dateien  nach
Index: DOCS/de/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/de/mplayer.1,v
retrieving revision 1.27
diff -u -r1.27 mplayer.1
--- DOCS/de/mplayer.1	22 Mar 2003 12:01:47 -0000	1.27
+++ DOCS/de/mplayer.1	18 Apr 2003 14:42:45 -0000
@@ -909,6 +909,8 @@
 Die \-subfont-*-Optionen sind nur verf?gbar, wenn FreeType eincompieliert
 wurde. Wenn die FreeType-Unterst?tzung aktiviert wurde, dann kann die
 alte Schriftunterst?tzung nicht mehr benutzt werden.
+.br
+Bei Fontconfig gibt diese Option den fontconfig Namen der Schriftart an.
 
 .I BEISPIELE:
 .PD 0
@@ -916,6 +918,8 @@
 \-font ~/\:.mplayer/\:arial\-14/\:font.desc
 .br
 \-font ~/\:.mplayer/\:arialuni.ttf
+.br
+\-font 'Bitstream Vera Sans'
 .RE
 .PD 1
 .
Index: DOCS/en/documentation.html
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/en/documentation.html,v
retrieving revision 1.400
diff -u -r1.400 documentation.html
--- DOCS/en/documentation.html	1 Apr 2003 00:33:16 -0000	1.400
+++ DOCS/en/documentation.html	18 Apr 2003 14:43:02 -0000
@@ -1014,6 +1014,11 @@
       <LI>create a symlink: <CODE>ln -s /path/to/arial.ttf ~/.mplayer/subfont.ttf</CODE></LI>
     </UL>
   </LI>
+  <LI>using Fontconfig in combination with freetype, you use the -font
+    parameter with a fontconfig font name:
+    <BR>
+    <CODE>-font 'Bitstream Vera Sans'</CODE>
+  </LI>
 </UL>
 
 <P>If you chose non-TTF fonts, UNZIP the file you downloaded to <CODE>~/.mplayer</CODE> or
Index: DOCS/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/en/mplayer.1,v
retrieving revision 1.371
diff -u -r1.371 mplayer.1
--- DOCS/en/mplayer.1	11 Apr 2003 10:27:31 -0000	1.371
+++ DOCS/en/mplayer.1	18 Apr 2003 14:43:20 -0000
@@ -900,6 +900,8 @@
 With FreeType, this option determines path to the text font file.
 .br
 The \-subfont-* options are available only with FreeType support compiled in.
+.br
+With Fontconfig, this option determines the fontconfig font name.
 
 .I EXAMPLE:
 .PD 0
@@ -907,6 +909,8 @@
 \-font ~/\:.mplayer/\:arial\-14/\:font.desc
 .br
 \-font ~/\:.mplayer/\:arialuni.ttf
+.br
+\-font 'Bitstream Vera Sans'
 .RE
 .PD 1
 .
Index: libvo/font_load_ft.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load_ft.c,v
retrieving revision 1.9
diff -u -r1.9 font_load_ft.c
--- libvo/font_load_ft.c	30 Jan 2003 19:58:43 -0000	1.9
+++ libvo/font_load_ft.c	18 Apr 2003 14:43:35 -0000
@@ -23,6 +23,10 @@
 #include <freetype/freetype.h>
 #include <freetype/ftglyph.h>
 
+#ifdef HAVE_FONTCONFIG
+#include <fontconfig/fontconfig.h>
+#endif
+
 #include "../bswap.h"
 #include "font_load.h"
 #include "mp_msg.h"
@@ -1112,6 +1116,13 @@
 
 void load_font_ft(int width, int height) 
 {
+#ifdef HAVE_FONTCONFIG
+  FcConfig *fc_config;
+  FcPattern *fc_pattern;
+  FcResult *fc_result;
+  FcChar8 *s;
+  FcBool scalable;
+#endif
     vo_image_width = width;
     vo_image_height = height;
 
@@ -1120,8 +1131,28 @@
 
     if (vo_font) free_font_desc(vo_font);
 
+    
 #ifdef USE_OSD
+#ifdef HAVE_FONTCONFIG
+    // do those need to be freed after the read_font_desc_ft call?
+    fc_config = FcInitLoadConfigAndFonts();
+    fc_pattern = FcNameParse(font_name);
+    FcConfigSubstitute(fc_config, fc_pattern, FcMatchPattern);
+    FcDefaultSubstitute(fc_pattern);
+    fc_pattern = FcFontMatch(fc_config, fc_pattern, fc_result);
+    FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable);
+    if (scalable != FcTrue) {
+      fc_pattern = FcNameParse("sans-serif");
+      FcConfigSubstitute(fc_config, fc_pattern, FcMatchPattern);
+      FcDefaultSubstitute(fc_pattern);
+      fc_pattern = FcFontMatch(fc_config, fc_pattern, fc_result);
+    }
+    // s definitely 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);
+#else
     vo_font=read_font_desc_ft(font_name, width, height);
+#endif
 #endif
 }
 
-------------- next part --------------
diff -Nur MPlayer-0.90/configure MPlayer-0.90-fontconfig/configure
--- MPlayer-0.90/configure	2003-03-22 17:29:16.000000000 +0100
+++ MPlayer-0.90-fontconfig/configure	2003-04-18 15:33:16.000000000 +0200
@@ -162,6 +162,7 @@
   --disable-css          Disable old-style libcss DVD support [autodetect]
   --disable-cdparanoia   Disable cdparanoia support [autodetect]
   --disable-freetype     Disable freetype2 font rendering support [autodetect]
+  --disable-fontconfig   Disable fontconfig font lookup support [autodetect]
   --disable-unrarlib     Disable Unique RAR File Library [enabled]
   --disable-new-conf     Disable new experimental config parser code [enabled]
   --enable-menu          Enable osd menu support (needs new config) [disabled]
@@ -1060,6 +1061,7 @@
 _cdparanoia=auto
 _big_endian=auto
 _freetype=auto
+_fontconfig=auto
 _shared_pp=no
 _new_conf=yes
 _menu=no
@@ -1251,6 +1253,8 @@
   --disable-big-endian) _big_endian=no  ;;
   --enable-freetype)    _freetype=yes   ;;
   --disable-freetype)   _freetype=no    ;;
+  --enable-fontconfig)  _fontconfig=yes ;;
+  --disable-fontconfig) _fontconfig=no  ;;
   --enable-unrarlib)	_unrarlib=yes	;;
   --disable-unrarlib)	_unrarlib=no	;;
 
@@ -3764,6 +3768,37 @@
 fi
 echores "$_freetype"
 
+echocheck "fontconfig"
+if test "$_fontconfig" = auto ; then
+    if ( pkg-config fontconfig --modversion) > /dev/null 2>&1 ; then
+        cat > $TMPC << EOF
+#include <stdio.h>
+#include <fontconfig/fontconfig.h>
+int main()
+{
+    int err = FcInit();
+    if(err == FcFalse){
+        printf("Couldn't initialize fontconfig lib\n");
+        exit(err);
+    }
+    return 0;
+    
+}
+EOF
+        _fontconfig=no
+        cc_check `pkg-config fontconfig --cflags --libs` && ( $TMPO >> "$TMPLOG" ) && _fontconfig=yes
+    else
+        _fontconfig=no
+    fi
+fi
+if test "$_fontconfig" = yes ; then
+    _def_fontconfig='#define HAVE_FONTCONFIG'
+    _inc_fontconfig=`pkg-config fontconfig --cflags`
+    _ld_fontconfig=`pkg-config fontconfig --libs`
+else
+    _def_fontconfig='#undef HAVE_FONTCONFIG'
+fi
+echores "$_fontconfig"
 
 echocheck "fribidi with charsets"
 if test "$_fribidi" = yes ; then
@@ -5051,6 +5086,8 @@
 CDPARANOIA_LIB = $_ld_cdparanoia
 FREETYPE_INC = $_inc_freetype
 FREETYPE_LIB = $_ld_freetype
+FONTCONFIG_INC = $_inc_fontconfig
+FONTCONFIG_LIB = $_ld_fontconfig
 FRIBIDI_INC = $_inc_fribidi
 FRIBIDI_LIB = $_ld_fribidi
 LIBLZO_LIB= $_ld_liblzo
@@ -5446,6 +5483,9 @@
 /* enable FreeType support */
 $_def_freetype
 
+/* enable Fontconfig support */
+$_def_fontconfig
+
 /* enable FriBiDi usage */
 $_def_fribidi
 
diff -Nur MPlayer-0.90/DOCS/documentation.html MPlayer-0.90-fontconfig/DOCS/documentation.html
--- MPlayer-0.90/DOCS/documentation.html	2003-04-01 02:29:34.000000000 +0200
+++ MPlayer-0.90-fontconfig/DOCS/documentation.html	2003-04-18 15:41:29.000000000 +0200
@@ -1014,6 +1014,11 @@
       <LI>create a symlink: <CODE>ln -s /path/to/arial.ttf ~/.mplayer/subfont.ttf</CODE></LI>
     </UL>
   </LI>
+  <LI>using Fontconfig in combination with freetype, you use the -font
+    parameter with a fontconfig font name:
+    <BR>
+    <CODE>-font 'Bitstream Vera Sans'</CODE>
+  </LI>
 </UL>
 
 <P>If you chose non-TTF fonts, UNZIP the file you downloaded to <CODE>~/.mplayer</CODE> or
diff -Nur MPlayer-0.90/DOCS/German/documentation.html MPlayer-0.90-fontconfig/DOCS/German/documentation.html
--- MPlayer-0.90/DOCS/German/documentation.html	2003-03-24 15:57:01.000000000 +0100
+++ MPlayer-0.90-fontconfig/DOCS/German/documentation.html	2003-04-18 15:44:49.000000000 +0200
@@ -1108,6 +1108,11 @@
         ~/.mplayer/subfont.ttf</CODE></LI>
     </UL>
   </LI>
+  <LI>Mit Fontconfig in Kombination mit freetype erwartet der -font parameter
+    den fontconfig Namen der Schriftart:
+    <BR>
+    <CODE>-font 'Bitstream Vera Sans'</CODE>
+  </LI>
 </UL>
 
 <P>Wenn du eine Nicht-TrueType-Schrift benutzt, dann entpacke die Dateien  nach
diff -Nur MPlayer-0.90/DOCS/German/mplayer.1 MPlayer-0.90-fontconfig/DOCS/German/mplayer.1
--- MPlayer-0.90/DOCS/German/mplayer.1	2003-03-25 09:32:19.000000000 +0100
+++ MPlayer-0.90-fontconfig/DOCS/German/mplayer.1	2003-04-18 15:36:56.000000000 +0200
@@ -909,6 +909,8 @@
 Die \-subfont-*-Optionen sind nur verf?gbar, wenn FreeType eincompieliert
 wurde. Wenn die FreeType-Unterst?tzung aktiviert wurde, dann kann die
 alte Schriftunterst?tzung nicht mehr benutzt werden.
+.br
+Bei Fontconfig gibt diese Option den fontconfig Namen der Schriftart an.
 
 .I BEISPIELE:
 .PD 0
@@ -916,6 +918,8 @@
 \-font ~/\:.mplayer/\:arial\-14/\:font.desc
 .br
 \-font ~/\:.mplayer/\:arialuni.ttf
+.br
+\-font 'Bitstream Vera Sans'
 .RE
 .PD 1
 .
diff -Nur MPlayer-0.90/DOCS/mplayer.1 MPlayer-0.90-fontconfig/DOCS/mplayer.1
--- MPlayer-0.90/DOCS/mplayer.1	2003-04-01 03:03:27.000000000 +0200
+++ MPlayer-0.90-fontconfig/DOCS/mplayer.1	2003-04-18 15:33:06.000000000 +0200
@@ -869,6 +869,8 @@
 With FreeType, this option determines path to the text font file.
 .br
 The \-subfont-* options are available only with FreeType support compiled in.
+.br
+With Fontconfig, this option determines the fontconfig font name.
 
 .I EXAMPLE:
 .PD 0
@@ -876,6 +878,8 @@
 \-font ~/\:.mplayer/\:arial\-14/\:font.desc
 .br
 \-font ~/\:.mplayer/\:arialuni.ttf
+.br
+\-font 'Bitstream Vera Sans'
 .RE
 .PD 1
 .
diff -Nur MPlayer-0.90/libvo/font_load_ft.c MPlayer-0.90-fontconfig/libvo/font_load_ft.c
--- MPlayer-0.90/libvo/font_load_ft.c	2003-01-30 20:58:43.000000000 +0100
+++ MPlayer-0.90-fontconfig/libvo/font_load_ft.c	2003-04-18 15:46:19.000000000 +0200
@@ -23,6 +23,10 @@
 #include <freetype/freetype.h>
 #include <freetype/ftglyph.h>
 
+#ifdef HAVE_FONTCONFIG
+#include <fontconfig/fontconfig.h>
+#endif
+
 #include "../bswap.h"
 #include "font_load.h"
 #include "mp_msg.h"
@@ -1112,6 +1116,13 @@
 
 void load_font_ft(int width, int height) 
 {
+#ifdef HAVE_FONTCONFIG
+  FcConfig *fc_config;
+  FcPattern *fc_pattern;
+  FcResult *fc_result;
+  FcChar8 *s;
+  FcBool scalable;
+#endif
     vo_image_width = width;
     vo_image_height = height;
 
@@ -1120,9 +1131,29 @@
 
     if (vo_font) free_font_desc(vo_font);
 
+    
 #ifdef USE_OSD
+#ifdef HAVE_FONTCONFIG
+    // do those need to be freed after the read_font_desc_ft call?
+    fc_config = FcInitLoadConfigAndFonts();
+    fc_pattern = FcNameParse(font_name);
+    FcConfigSubstitute(fc_config, fc_pattern, FcMatchPattern);
+    FcDefaultSubstitute(fc_pattern);
+    fc_pattern = FcFontMatch(fc_config, fc_pattern, fc_result);
+    FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable);
+    if (scalable != FcTrue) {
+      fc_pattern = FcNameParse("sans-serif");
+      FcConfigSubstitute(fc_config, fc_pattern, FcMatchPattern);
+      FcDefaultSubstitute(fc_pattern);
+      fc_pattern = FcFontMatch(fc_config, fc_pattern, fc_result);
+    }
+    // s definitely 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);
+#else
     vo_font=read_font_desc_ft(font_name, width, height);
 #endif
+#endif
 }
 
 #endif /* HAVE_FREETYPE */
diff -Nur MPlayer-0.90/Makefile MPlayer-0.90-fontconfig/Makefile
--- MPlayer-0.90/Makefile	2003-03-22 17:29:16.000000000 +0100
+++ MPlayer-0.90-fontconfig/Makefile	2003-04-18 15:33:16.000000000 +0200
@@ -33,10 +33,10 @@
 OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
 OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
 
-VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) 
+VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB)
 AO_LIBS = $(ARTS_LIB) $(ESD_LIB) $(NAS_LIB) $(SGIAUDIO_LIB)
 CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(DECORE_LIB) $(XVID_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB)
-COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a $(PP_LIB) postproc/libswscale.a linux/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
+COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a $(PP_LIB) postproc/libswscale.a linux/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(FONTCONFIG_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
 
 CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(FRIBIDI_INC) # -Wall
 
diff -Nur MPlayer-0.90/mencoder.c MPlayer-0.90-fontconfig/mencoder.c
--- MPlayer-0.90/mencoder.c	2003-03-10 17:12:11.000000000 +0100
+++ MPlayer-0.90-fontconfig/mencoder.c	2003-04-18 15:33:16.000000000 +0200
@@ -433,6 +433,10 @@
 #ifdef USE_OSD
 #ifdef HAVE_FREETYPE
   init_freetype();
+#ifdef HAVE_FONTCONFIG
+  if(!font_name)
+    font_name = "sans-serif";
+#endif
 #else
   if(font_name){
        vo_font=read_font_desc(font_name,font_factor,verbose>1);
diff -Nur MPlayer-0.90/mplayer.c MPlayer-0.90-fontconfig/mplayer.c
--- MPlayer-0.90/mplayer.c	2003-03-10 15:02:18.000000000 +0100
+++ MPlayer-0.90-fontconfig/mplayer.c	2003-04-18 15:33:16.000000000 +0200
@@ -960,8 +960,15 @@
 
 //------ load global data first ------
 
-#ifdef USE_OSD
 // check font
+#ifdef USE_OSD
+#ifdef HAVE_FREETYPE
+  init_freetype();
+#ifdef HAVE_FONTCONFIG
+  if(!font_name)
+    font_name = "sans-serif";
+#endif
+#else
   if(font_name){
        vo_font=read_font_desc(font_name,font_factor,verbose>1);
        if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
@@ -971,9 +978,6 @@
        if(!vo_font)
        vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1);
   }
-#ifdef HAVE_FREETYPE
-  if (!vo_font)
-	init_freetype();
 #endif
 #endif
   vo_init_osd();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20030418/2f48bf95/attachment.pgp>


More information about the MPlayer-dev-eng mailing list