[MPlayer-dev-eng] [PATCH][RFC] Font layer fixes/improvements

Krzysztof Rusocki kszysiu at iceberg.elsat.net.pl
Sat May 29 18:27:22 CEST 2004


> > If you need more info, feel free to mail,
> > also, any feedback is welcome (including napalm).
> Could you post an up to date patch?

Gosh, pardon me Alex, lost mail :-(

Here it goes...

Cheers,
Krzysztof

P.S.
I am willing to do appropriate docs changes if core changes are considered o.k.
-------------- next part --------------
diff -ru main.orig/cfg-common.h main/cfg-common.h
--- main.orig/cfg-common.h	2004-05-03 15:19:03.000000000 +0200
+++ main/cfg-common.h	2004-05-29 18:18:15.661975896 +0200
@@ -261,13 +261,6 @@
  	{"subfont-outline", &subtitle_font_thickness, CONF_TYPE_FLOAT, CONF_RANGE, 0, 8, NULL},
  	{"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 #endif
-#ifdef HAVE_FONTCONFIG
-	{"fontconfig", &font_fontconfig, CONF_TYPE_FLAG, 0, 0, 1, NULL},
-	{"nofontconfig", &font_fontconfig, CONF_TYPE_FLAG, 0, 1, 0, NULL},
-#else
-	{"fontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
-	{"nofontconfig", "MPlayer was compiled without fontconfig support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
-#endif
 #endif
 
 #else
Only in main: cfg-common.h~
Only in main: cfg-common.h.orig
Only in main: cfg-common.h.rej
diff -ru main.orig/Gui/cfg.c main/Gui/cfg.c
--- main.orig/Gui/cfg.c	2003-11-08 01:26:44.000000000 +0100
+++ main/Gui/cfg.c	2004-05-29 18:16:10.638982280 +0200
@@ -8,6 +8,7 @@
 #include "../mplayer.h"
 #include "../m_config.h"
 #include "../m_option.h"
+#include "../libvo/font_if.h"
 
 #ifdef USE_SETLOCALE
 #include <locale.h>
diff -ru main.orig/Gui/interface.c main/Gui/interface.c
--- main.orig/Gui/interface.c	2004-03-25 22:49:47.000000000 +0100
+++ main/Gui/interface.c	2004-05-29 18:16:10.642981672 +0200
@@ -22,7 +22,7 @@
 #include "../subreader.h"
 #include "../libvo/x11_common.h"
 #include "../libvo/video_out.h"
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../libvo/sub.h"
 #include "../input/input.h"
 #include "../libao2/audio_out.h"
@@ -373,44 +373,8 @@
 #if defined( USE_OSD ) || defined( USE_SUB )
 void guiLoadFont( void )
 {
-#ifdef HAVE_FREETYPE
-  load_font_ft(vo_image_width, vo_image_height);
-#else
- if ( vo_font )
-  {
-   int i;
-   if ( vo_font->name ) free( vo_font->name );
-   if ( vo_font->fpath ) free( vo_font->fpath );
-   for ( i=0;i<16;i++ )
-    if ( vo_font->pic_a[i] )
-     {
-      if ( vo_font->pic_a[i]->bmp ) free( vo_font->pic_a[i]->bmp );
-      if ( vo_font->pic_a[i]->pal ) free( vo_font->pic_a[i]->pal );
-     }
-   for ( i=0;i<16;i++ )
-    if ( vo_font->pic_b[i] )
-     {
-      if ( vo_font->pic_b[i]->bmp ) free( vo_font->pic_b[i]->bmp );
-      if ( vo_font->pic_b[i]->pal ) free( vo_font->pic_b[i]->pal );
-     }
-   free( vo_font ); vo_font=NULL;
-  }
- if ( font_name )
-  {
-   vo_font=read_font_desc( font_name,font_factor,0 );
-   if ( !vo_font ) mp_msg( MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name );
-  } 
-  else
-   {
-    font_name=gstrdup( get_path( "font/font.desc" ) );
-    vo_font=read_font_desc( font_name,font_factor,0 );
-    if ( !vo_font )
-     {
-      gfree( (void **)&font_name ); font_name=gstrdup(MPLAYER_DATADIR "/font/font.desc" );
-      vo_font=read_font_desc( font_name,font_factor,0 );
-     }
-   }
-#endif
+  force_load_font = 1;
+  load_font(font_name, vo_image_width, vo_image_height);
 }
 #endif
 
@@ -999,33 +963,26 @@
 #ifndef HAVE_FREETYPE
    case gtkSetFontFactor:
         font_factor=fparam;
-	guiLoadFont();
 	return NULL;
 #else
    case gtkSetFontOutLine:
         subtitle_font_thickness=( 8.0f / 100.0f ) * fparam;
-	guiLoadFont();
 	return NULL;
    case gtkSetFontBlur:
 	subtitle_font_radius=( 8.0f / 100.0f ) * fparam;
-	guiLoadFont();
 	return NULL;
    case gtkSetFontTextScale:
 	text_font_scale_factor=fparam;
-	guiLoadFont();
 	return NULL;
    case gtkSetFontOSDScale:
 	osd_font_scale_factor=fparam;
-	guiLoadFont();
 	return NULL;
    case gtkSetFontEncoding:
 	gfree( (void **)&subtitle_font_encoding );
 	subtitle_font_encoding=gstrdup( (char *)vparam );
-	guiLoadFont();
 	return NULL;
    case gtkSetFontAutoScale:
 	subtitle_autoscale=(int)fparam;
-	guiLoadFont();
 	return NULL;
 #endif
 #ifdef USE_ICONV
diff -ru main.orig/Gui/interface.h main/Gui/interface.h
--- main.orig/Gui/interface.h	2003-08-15 13:55:21.000000000 +0200
+++ main/Gui/interface.h	2004-05-29 18:16:10.645981216 +0200
@@ -5,7 +5,6 @@
 #include "../config.h"
 #include "mplayer/play.h"
 #include "../mplayer.h"
-#include "../libvo/font_load.h"
 #include "cfg.h"
 
 #ifdef USE_DVDREAD
diff -ru main.orig/Gui/mplayer/gtk/opts.c main/Gui/mplayer/gtk/opts.c
--- main.orig/Gui/mplayer/gtk/opts.c	2004-02-03 20:02:45.000000000 +0100
+++ main/Gui/mplayer/gtk/opts.c	2004-05-29 18:16:10.651980304 +0200
@@ -12,6 +12,7 @@
 #include "../../../mixer.h"
 #include "../../../libao2/audio_out.h"
 #include "../../../libvo/video_out.h"
+#include "../libvo/font_if.h"
 
 #include "../../app.h"
 #include "../../cfg.h"
@@ -570,6 +571,7 @@
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleWidth ) ) ) gtkSet( gtkSetFontAutoScale,2,NULL );
 	if ( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( RBFontAutoScaleDiagonal ) ) ) gtkSet( gtkSetFontAutoScale,3,NULL );
 #endif
+	guiLoadFont();
 
 	// -- 5. page
 	force_ni=gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( CBNonInterlaved ) );
diff -ru main.orig/libmenu/menu.c main/libmenu/menu.c
--- main.orig/libmenu/menu.c	2003-08-16 11:50:45.000000000 +0200
+++ main/libmenu/menu.c	2004-05-29 18:16:10.654979848 +0200
@@ -8,7 +8,7 @@
 #include <unistd.h>
 
 #include "../libvo/osd.h"
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../osdep/keycodes.h"
 #include "../asxparser.h"
 #include "../libmpdemux/stream.h"
diff -ru main.orig/libmenu/menu_cmdlist.c main/libmenu/menu_cmdlist.c
--- main.orig/libmenu/menu_cmdlist.c	2002-12-28 19:51:09.000000000 +0100
+++ main/libmenu/menu_cmdlist.c	2004-05-29 18:16:10.657979392 +0200
@@ -15,7 +15,7 @@
 #include "menu.h"
 #include "menu_list.h"
 
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 
 #include "../input/input.h"
 #include "../version.h"
diff -ru main.orig/libmenu/menu_console.c main/libmenu/menu_console.c
--- main.orig/libmenu/menu_console.c	2003-09-13 20:02:20.000000000 +0200
+++ main/libmenu/menu_console.c	2004-05-29 18:16:10.659979088 +0200
@@ -20,7 +20,7 @@
 #include "../m_option.h"
 #include "menu.h"
 
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../osdep/keycodes.h"
 #include "../input/input.h"
 #include "../osdep/timer.h"
diff -ru main.orig/libmenu/menu_list.c main/libmenu/menu_list.c
--- main.orig/libmenu/menu_list.c	2003-09-24 09:35:59.000000000 +0200
+++ main/libmenu/menu_list.c	2004-05-29 18:16:10.662978632 +0200
@@ -12,7 +12,7 @@
 #include "m_struct.h"
 #include "menu.h"
 
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../osdep/keycodes.h"
 
 #define IMPL 1
diff -ru main.orig/libmenu/menu_txt.c main/libmenu/menu_txt.c
--- main.orig/libmenu/menu_txt.c	2003-02-09 21:18:20.000000000 +0100
+++ main/libmenu/menu_txt.c	2004-05-29 18:16:10.664978328 +0200
@@ -12,7 +12,7 @@
 #include "../m_option.h"
 #include "menu.h"
 
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../osdep/keycodes.h"
 
 struct menu_priv_s {
diff -ru main.orig/libmenu/vf_menu.c main/libmenu/vf_menu.c
--- main.orig/libmenu/vf_menu.c	2003-07-09 03:30:23.000000000 +0200
+++ main/libmenu/vf_menu.c	2004-05-29 18:16:10.667977872 +0200
@@ -17,9 +17,10 @@
 
 #include "../libvo/fastmemcpy.h"
 #include "../libvo/video_out.h"
-#include "../libvo/font_load.h"
+#include "../libvo/font_if.h"
 #include "../input/input.h"
 #include "../m_struct.h"
+#include "../mplayer.h" // font_name
 #include "menu.h"
 
 extern vo_functions_t* video_out;
@@ -242,13 +243,8 @@
 
 static int config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height,
 		  unsigned int flags, unsigned int outfmt) { 
-#ifdef HAVE_FREETYPE    
   // here is the right place to get screen dimensions
-  if (force_load_font) {
-    force_load_font = 0;
-    load_font_ft(width,height);
-  }
-#endif
+  load_font(font_name, width, height);
   return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
 }
 static int open(vf_instance_t *vf, char* args){
Only in main/libvo: font_if.c
Only in main/libvo: font_if.h
diff -ru main.orig/libvo/font_load_ft.c main/libvo/font_load_ft.c
--- main.orig/libvo/font_load_ft.c	2003-12-08 14:30:30.000000000 +0100
+++ main/libvo/font_load_ft.c	2004-05-29 18:16:10.677976352 +0200
@@ -38,25 +38,7 @@
 #define HAVE_FREETYPE21
 #endif
 
-char *get_path(char *filename);
-
-char *subtitle_font_encoding = NULL;
-float text_font_scale_factor = 5.0;
-float osd_font_scale_factor = 6.0;
-float subtitle_font_radius = 2.0;
-float subtitle_font_thickness = 2.0;
-// 0 = no autoscale
-// 1 = video height
-// 2 = video width
-// 3 = diagonal
-int subtitle_autoscale = 3;
-
-int vo_image_width = 0;
-int vo_image_height = 0;
-int force_load_font;
-
 int using_freetype = 0;
-int font_fontconfig = 0;
 
 //// constants
 static unsigned int const colors = 256;
@@ -488,7 +470,7 @@
 }
 
 #define ALLOC_INCR 32
-void render_one_glyph(font_desc_t *desc, int c)
+void render_one_glyph_ft(font_desc_t *desc, int c)
 {
     FT_GlyphSlot	slot;
     FT_UInt		glyph_index;
@@ -867,57 +849,16 @@
     return desc;
 }
 
-void free_font_desc(font_desc_t *desc)
-{
-    int i;
-    
-    if (!desc) return;
-
-//    if (!desc->dynamic) return; // some vo_aa crap, better leaking than crashing
-
-    if (desc->name) free(desc->name);
-    if (desc->fpath) free(desc->fpath);
-    
-    for(i = 0; i < 16; i++) {
-	if (desc->pic_a[i]) {
-	    if (desc->pic_a[i]->bmp) free(desc->pic_a[i]->bmp);
-	    if (desc->pic_a[i]->pal) free(desc->pic_a[i]->pal);
-	}
-	if (desc->pic_b[i]) {
-	    if (desc->pic_b[i]->bmp) free(desc->pic_b[i]->bmp);
-	    if (desc->pic_b[i]->pal) free(desc->pic_b[i]->pal);
-	}
-    }
-
-    if (desc->tables.g) free(desc->tables.g);
-    if (desc->tables.gt2) free(desc->tables.gt2);
-    if (desc->tables.om) free(desc->tables.om);
-    if (desc->tables.omt) free(desc->tables.omt);
-    if (desc->tables.tmp) free(desc->tables.tmp);
-
-    for(i = 0; i < desc->face_cnt; i++) {
-	FT_Done_Face(desc->faces[i]);
-    }
-    
-    free(desc);
-}
-
 static int load_sub_face(char *name, FT_Face *face)
 {
     int err = -1;
     
-    if (name) err = FT_New_Face(library, name, 0, face);
+    if (name)
+    	err = FT_New_Face(library, name, 0, face);
+    
+    if (err)
+	    mp_msg(MSGT_OSD, MSGL_WARN, "Freetype: New_Face couldn't load \"%s\".\n", name);
 
-    if (err) {
-	err = FT_New_Face(library, get_path("subfont.ttf"), 0, face);
-	if (err) {
-	    err = FT_New_Face(library, MPLAYER_DATADIR "/subfont.ttf", 0, face);
-	    if (err) {
-	        mp_msg(MSGT_OSD, MSGL_ERR, "New_Face failed. Maybe the font path is wrong.\nPlease supply the text font file (~/.mplayer/subfont.ttf).\n" );
-		return -1;
-	    }
-	}
-    }
     return err;
 }
 
@@ -930,7 +871,7 @@
     return 0;
 }
 
-int kerning(font_desc_t *desc, int prevc, int c)
+int kerning_ft(font_desc_t *desc, int prevc, int c)
 {
     FT_Vector kern;
     
@@ -1004,10 +945,13 @@
 //    t=GetTimer();
 
     /* generate the subtitle font */
+    if (!fname)
+	goto gen_osd;
     err = load_sub_face(fname, &face);
     if (err) {
-	mp_msg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n");
-	goto gen_osd;
+	//mp_msg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n");
+	free_font_desc(desc);
+	return NULL;
     }
     desc->face_cnt++;
 
@@ -1116,48 +1060,55 @@
     return 0;
 }
 
-void load_font_ft(int width, int height) 
-{
 #ifdef HAVE_FONTCONFIG
+static char * fontconfig_get_name(char * name)
+{
     FcPattern *fc_pattern;
     FcChar8 *s;
     FcBool scalable;
-#endif
-    vo_image_width = width;
-    vo_image_height = height;
+    char * ret = NULL;
 
-    // protection against vo_aa font hacks
-    if (vo_font && !vo_font->dynamic) return;
+    FcInit();
+    fc_pattern = FcNameParse(name);
+    FcConfigSubstitute(0, fc_pattern, FcMatchPattern);
+    FcDefaultSubstitute(fc_pattern);
+
+    fc_pattern = FcFontMatch(0, fc_pattern, 0);
+	/* NOTE: it seems that second allocation of fc_pattern takes place
+	 * here, what is more, last (FcResult*) argument is totally ignored
+	 * by fontconfig as of 2.2.92
+	 */
 
-    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);
-	}
+    FcPatternGetBool(fc_pattern, FC_SCALABLE, 0, &scalable);
+    if (scalable == FcTrue) {
 	// 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);
+	//mp_msg(MSGT_CPLAYER, MSGL_ERR, "fontconfig: fc_ret: %d, font: %s\n", fc_ret, s);
+	ret = s;
     }
-    else
+    free(fc_pattern);
+    return ret;
+}
 #endif
-    vo_font=read_font_desc_ft(font_name, width, height);
+
+void load_font_ft(char * name, int width, int height) 
+{
+    vo_font = read_font_desc_ft(name, width, height);
+    if (vo_font)
+	mp_msg(MSGT_CPLAYER, MSGL_INFO, "Freetype: loaded \"%s\"\n", name);
+}
+
+void load_font_fc_ft(char * name, int width, int height)
+{
+    char * tmp = NULL;
+
+#ifdef HAVE_FONTCONFIG    
+    tmp = fontconfig_get_name(name);
 #endif
+    if (tmp) {
+    	mp_msg(MSGT_CPLAYER, MSGL_INFO, "Fontconfig: found \"%s\" for \"%s\"\n", tmp, name);
+    	load_font_ft(tmp, width, height);
+    }
 }
 
 #endif /* HAVE_FREETYPE */
Only in main/libvo: font_load_ft.h
diff -ru main.orig/libvo/font_load.h main/libvo/font_load.h
--- main.orig/libvo/font_load.h	2003-11-20 17:25:40.000000000 +0100
+++ main/libvo/font_load.h	2004-05-29 18:16:10.682975592 +0200
@@ -1,99 +1,7 @@
 #ifndef __MPLAYER_FONT_LOAD_H
 #define __MPLAYER_FONT_LOAD_H
 
-#ifdef HAVE_FREETYPE
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#endif
-
-typedef struct {
-    unsigned char *bmp;
-    unsigned char *pal;
-    int w,h,c;
-#ifdef HAVE_FREETYPE
-    int charwidth,charheight,pen,baseline,padding;
-    int current_count, current_alloc;
-#endif
-} raw_file;
-
-typedef struct {
-#ifdef HAVE_FREETYPE
-    int dynamic;
-#endif
-    char *name;
-    char *fpath;
-    int spacewidth;
-    int charspace;
-    int height;
-//    char *fname_a;
-//    char *fname_b;
-    raw_file* pic_a[16];
-    raw_file* pic_b[16];
-    short font[65536];
-    int start[65536];   // short is not enough for unicode fonts
-    short width[65536];
-    int freetype;
-
-#ifdef HAVE_FREETYPE
-    int face_cnt;
-    
-    FT_Face faces[16];
-    FT_UInt glyph_index[65536];
-
-    int max_width, max_height;
-
-    struct 
-    {
-	int g_r;
-	int o_r;
-	int g_w;
-	int o_w;
-	int o_size;
-	unsigned volume;
-
-	unsigned *g;
-	unsigned *gt2;
-	unsigned *om;
-	unsigned char *omt;
-	unsigned short *tmp;
-    } tables;
-#endif
-
-} font_desc_t;
-
-extern font_desc_t* vo_font;
-
-#ifdef HAVE_FREETYPE
-
-extern char *subtitle_font_encoding;
-extern float text_font_scale_factor;
-extern float osd_font_scale_factor;
-extern float subtitle_font_radius;
-extern float subtitle_font_thickness;
-extern int subtitle_autoscale;
-
-extern int vo_image_width;
-extern int vo_image_height;
-
-extern int force_load_font;
-
-int init_freetype();
-int done_freetype();
-
-font_desc_t* read_font_desc_ft(char* fname,int movie_width, int movie_height);
-void free_font_desc(font_desc_t *desc);
-
-void render_one_glyph(font_desc_t *desc, int c);
-int kerning(font_desc_t *desc, int prevc, int c);
-
-void load_font_ft(int width, int height);
-
-#else
-
-static void render_one_glyph(font_desc_t *desc, int c) {}
-static int kerning(font_desc_t *desc, int prevc, int c) { return 0; }
-
-#endif
+#include "font_if.h"
 
 raw_file* load_raw(char *name,int verbose);
 font_desc_t* read_font_desc(char* fname,float factor,int verbose);
diff -ru main.orig/libvo/Makefile main/libvo/Makefile
--- main.orig/libvo/Makefile	2004-01-10 10:48:14.000000000 +0100
+++ main/libvo/Makefile	2004-05-29 18:16:10.684975288 +0200
@@ -3,7 +3,7 @@
 
 LIBNAME = libvo.a
 
-SRCS=geometry.c aspect.c aclib.c osd.c font_load.c gtf.c spuenc.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_mpegpes.c vo_yuv4mpeg.c $(OPTIONAL_SRCS) sub.c font_load_ft.c
+SRCS=geometry.c aspect.c aclib.c osd.c font_load.c gtf.c spuenc.c video_out.c vo_null.c vo_pgm.c vo_md5.c vo_mpegpes.c vo_yuv4mpeg.c $(OPTIONAL_SRCS) sub.c font_load_ft.c font_if.c
 OBJS=$(SRCS:.c=.o)
 
 ifeq ($(VIDIX),yes)
diff -ru main.orig/libvo/sub.c main/libvo/sub.c
--- main.orig/libvo/sub.c	2003-10-27 22:36:29.000000000 +0100
+++ main/libvo/sub.c	2004-05-29 18:16:10.688974680 +0200
@@ -10,9 +10,10 @@
 
 #include "mp_msg.h"
 #include "video_out.h"
-#include "font_load.h"
+#include "font_if.h"
 #include "sub.h"
 #include "../spudec.h"
+#include "../mplayer.h" /* font_name, don't like it */
 
 #define NEW_SPLITTING
 
@@ -755,13 +756,8 @@
     mp_osd_obj_t* obj=vo_osd_list;
     int chg=0;
 
-#ifdef HAVE_FREETYPE    
     // here is the right place to get screen dimensions
-    if (!vo_font || force_load_font) {
-	force_load_font = 0;
-	load_font_ft(dxs, dys);
-    }
-#endif
+    load_font(font_name, dxs, dys);
 
     while(obj){
       if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){
@@ -835,9 +831,7 @@
     new_osd_obj(OSDTYPE_SUBTITLE);
     new_osd_obj(OSDTYPE_PROGBAR);
     new_osd_obj(OSDTYPE_SPU);
-#ifdef HAVE_FREETYPE
     force_load_font = 1;
-#endif
 }
 
 int vo_osd_changed_flag=0;
diff -ru main.orig/libvo/vo_aa.c main/libvo/vo_aa.c
--- main.orig/libvo/vo_aa.c	2003-08-13 18:45:02.000000000 +0200
+++ main/libvo/vo_aa.c	2004-05-29 18:16:10.691974224 +0200
@@ -29,7 +29,7 @@
 #include "aspect.h"
 #include "../postproc/swscale.h"
 #include "../libmpcodecs/vf_scale.h"
-#include "font_load.h"
+#include "font_if.h"
 #include "sub.h"
 
 #include "osdep/keycodes.h"
diff -ru main.orig/Makefile main/Makefile
--- main.orig/Makefile	2004-05-08 19:52:24.000000000 +0200
+++ main/Makefile	2004-05-29 18:16:10.694973768 +0200
@@ -22,7 +22,7 @@
 endif
 
 SRCS_COMMON = cpudetect.c codec-cfg.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c sub_cc.c find_sub.c m_config.c m_option.c parser-cfg.c m_struct.c
-SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c
+SRCS_MENCODER = mencoder.c mp_msg-mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c libvo/font_load_ft.c xvid_vbr.c parser-mecmd.c libvo/font_if.c
 SRCS_MPLAYER = mplayer.c mp_msg.c $(SRCS_COMMON) mixer.c parser-mpcmd.c
 
 ifeq ($(UNRARLIB),yes)
diff -ru main.orig/mencoder.c main/mencoder.c
--- main.orig/mencoder.c	2004-05-19 06:38:05.000000000 +0200
+++ main/mencoder.c	2004-05-29 18:16:10.701972704 +0200
@@ -453,27 +453,8 @@
 
   mp_msg_set_level(verbose+MSGL_STATUS);
 
-// check font
 #ifdef USE_OSD
-#ifdef HAVE_FREETYPE
-  init_freetype();
-#endif
-#ifdef HAVE_FONTCONFIG
-  if(!font_fontconfig)
-  {
-#endif
-  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);
-  } else {
-      // try default:
-       vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
-       if(!vo_font)
-       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1);
-  }
-#ifdef HAVE_FONTCONFIG
-  }
-#endif
+    init_font();
 #endif
 
   vo_init_osd();
Only in main: mencoder.c.orig
diff -ru main.orig/mplayer.c main/mplayer.c
--- main.orig/mplayer.c	2004-04-30 22:05:54.000000000 +0200
+++ main/mplayer.c	2004-05-29 18:16:10.714970728 +0200
@@ -290,9 +290,6 @@
 
 // sub:
 char *font_name=NULL;
-#ifdef HAVE_FONTCONFIG
-extern int font_fontconfig;
-#endif
 float font_factor=0.75;
 char **sub_name=NULL;
 float sub_delay=0;
@@ -1063,28 +1060,10 @@
 
 //------ load global data first ------
 
-// check font
 #ifdef USE_OSD
-#ifdef HAVE_FREETYPE
-  init_freetype();
-#endif
-#ifdef HAVE_FONTCONFIG
-  if(!font_fontconfig)
-  {
-#endif
-  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);
-  } else {
-      // try default:
-       vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
-       if(!vo_font)
-       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1);
-  }
-#ifdef HAVE_FONTCONFIG
-  }
-#endif
+    init_font();
 #endif
+
   vo_init_osd();
 
 #ifdef HAVE_RTC
@@ -1782,9 +1761,7 @@
    if(vo_flags & 0x08 && vo_spudec)
       spudec_set_hw_spu(vo_spudec,video_out);
 
-#ifdef HAVE_FREETYPE
    force_load_font = 1;
-#endif
 
 //================== MAIN: ==========================
 main:
@@ -3779,11 +3756,9 @@
   goto play_next_file;
 }
 
-#ifdef HAVE_FREETYPE
+#ifdef USE_OSD
 current_module="uninit_font";
-if (vo_font) free_font_desc(vo_font);
-vo_font = NULL;
-done_freetype();
+uninit_font();
 #endif
 
 exit_player_with_rc(MSGTR_Exit_eof, 0);
Only in main: mplayer.c.orig


More information about the MPlayer-dev-eng mailing list