diff -ru MPlayer-1.0pre3.orig/cfg-common.h MPlayer-1.0pre3/cfg-common.h --- MPlayer-1.0pre3.orig/cfg-common.h 2003-12-08 22:33:31.000000000 +0100 +++ MPlayer-1.0pre3/cfg-common.h 2004-02-06 15:43:02.000000000 +0100 @@ -252,13 +252,7 @@ {"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 wasn't compiled with Fontconfig support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, - {"nofontconfig", "MPlayer wasn't compiled with Fontconfig support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, -#endif + #endif #else diff -ru MPlayer-1.0pre3.orig/get_path.c MPlayer-1.0pre3/get_path.c --- MPlayer-1.0pre3.orig/get_path.c 2003-04-30 20:16:21.000000000 +0200 +++ MPlayer-1.0pre3/get_path.c 2004-02-06 16:52:04.000000000 +0100 @@ -1,5 +1,9 @@ -char *get_path(char *filename){ +#ifndef __MPLAYER_GET_PATH +#define __MPLAYER_GET_PATH +#include "mp_msg.h" + +static char *get_path(char *filename){ char *homedir; char *buff; #if defined(__MINGW32__) @@ -37,3 +41,4 @@ mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); return buff; } +#endif diff -ru MPlayer-1.0pre3.orig/Gui/cfg.c MPlayer-1.0pre3/Gui/cfg.c --- MPlayer-1.0pre3.orig/Gui/cfg.c 2003-11-08 01:26:44.000000000 +0100 +++ MPlayer-1.0pre3/Gui/cfg.c 2004-02-06 22:15:02.000000000 +0100 @@ -8,6 +8,7 @@ #include "../mplayer.h" #include "../m_config.h" #include "../m_option.h" +#include "../get_path.c" #ifdef USE_SETLOCALE #include diff -ru MPlayer-1.0pre3.orig/Gui/interface.c MPlayer-1.0pre3/Gui/interface.c --- MPlayer-1.0pre3.orig/Gui/interface.c 2003-11-08 01:26:44.000000000 +0100 +++ MPlayer-1.0pre3/Gui/interface.c 2004-02-13 15:57:52.224522880 +0100 @@ -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" @@ -30,6 +30,8 @@ #include "../libao2/audio_plugin.h" #include "../libao2/eq.h" +#include "../get_path.c" + #ifdef USE_ICONV #include #endif @@ -330,6 +332,7 @@ if ( plCurrent && !filename ) mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE ); if ( subdata ) guiSetFilename( guiIntfStruct.Subtitlename, subdata->filename ); #if defined( USE_OSD ) || defined( USE_SUB ) + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): guiInit\n"); guiLoadFont(); #endif } @@ -372,44 +375,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 @@ -815,6 +782,7 @@ gtkSubDumpMPSub=gtkSubDumpSrt=0; #endif #if defined( USE_OSD ) || defined( USE_SUB ) + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): guiGetEvent\n"); guiLoadFont(); #endif @@ -869,7 +837,7 @@ #define list(); #endif -void * gtkSet( int cmd,float fparam, void * vparam ) +void * _gtkSet( int cmd,float fparam, void * vparam, char * fn, int ln) { equalizer_t * eq = (equalizer_t *)vparam; plItem * item = (plItem *)vparam; @@ -877,6 +845,8 @@ URLItem * url_item = (URLItem *)vparam; int is_added = True; + mp_msg( MSGT_GPLAYER,MSGL_INFO,"gtkSet called from %s:%d\n", fn, ln); + switch ( cmd ) { // --- handle playlist @@ -998,33 +968,33 @@ #ifndef HAVE_FREETYPE case gtkSetFontFactor: font_factor=fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontFactor\n"); return NULL; #else case gtkSetFontOutLine: subtitle_font_thickness=( 8.0f / 100.0f ) * fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontOutline\n"); return NULL; case gtkSetFontBlur: subtitle_font_radius=( 8.0f / 100.0f ) * fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontBlur\n"); return NULL; case gtkSetFontTextScale: text_font_scale_factor=fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontTextScale\n"); return NULL; case gtkSetFontOSDScale: osd_font_scale_factor=fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontOSDScale\n"); return NULL; case gtkSetFontEncoding: gfree( (void **)&subtitle_font_encoding ); subtitle_font_encoding=gstrdup( (char *)vparam ); - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontEncoding\n"); return NULL; case gtkSetFontAutoScale: subtitle_autoscale=(int)fparam; - guiLoadFont(); + mp_msg( MSGT_GPLAYER,MSGL_INFO,"guiLoadFont(): gtkSet/gtkSetFontAutoScale\n"); return NULL; #endif #ifdef USE_ICONV diff -ru MPlayer-1.0pre3.orig/Gui/interface.h MPlayer-1.0pre3/Gui/interface.h --- MPlayer-1.0pre3.orig/Gui/interface.h 2003-08-15 13:55:21.000000000 +0200 +++ MPlayer-1.0pre3/Gui/interface.h 2004-02-10 04:26:39.000000000 +0100 @@ -6,6 +6,7 @@ #include "mplayer/play.h" #include "../mplayer.h" #include "../libvo/font_load.h" +#include "../get_path.c" #include "cfg.h" #ifdef USE_DVDREAD @@ -140,8 +141,6 @@ #define guiFilenames 4 #define guiALL 0xffffffff -extern char *get_path(char *filename); - extern void guiInit( void ); extern void guiDone( void ); extern int guiGetEvent( int type,char * arg ); @@ -202,7 +201,8 @@ extern float gtkEquChannels[6][10]; -extern void * gtkSet( int cmd,float param, void * vparam ); +#define gtkSet(c, p, v) _gtkSet(c, p, v, __FILE__, __LINE__) +extern void * _gtkSet( int cmd,float fparam, void * vparam, char * fn, int ln); extern char * gconvert_uri_to_filename( char * str ); extern char * gstrdup( char * str ); diff -ru MPlayer-1.0pre3.orig/Gui/mplayer/gtk/fs.c MPlayer-1.0pre3/Gui/mplayer/gtk/fs.c --- MPlayer-1.0pre3.orig/Gui/mplayer/gtk/fs.c 2003-12-07 16:42:03.000000000 +0100 +++ MPlayer-1.0pre3/Gui/mplayer/gtk/fs.c 2004-02-05 18:17:47.000000000 +0100 @@ -102,9 +102,8 @@ { "True Type fonts (*.ttf)", "*.ttf" }, { "Type1 fonts (*.pfb)", "*.pfb" }, { "All fonts", "*.ttf,*.pfb" }, -#else - { "font files (*.desc)", "*.desc" }, #endif + { "font files (*.desc)", "*.desc" }, { "All files", "*" }, { NULL,NULL } }; diff -ru MPlayer-1.0pre3.orig/Gui/mplayer/gtk/opts.c MPlayer-1.0pre3/Gui/mplayer/gtk/opts.c --- MPlayer-1.0pre3.orig/Gui/mplayer/gtk/opts.c 2003-05-25 19:25:59.000000000 +0200 +++ MPlayer-1.0pre3/Gui/mplayer/gtk/opts.c 2004-02-10 04:37:36.000000000 +0100 @@ -570,6 +570,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 MPlayer-1.0pre3.orig/input/input.c MPlayer-1.0pre3/input/input.c --- MPlayer-1.0pre3.orig/input/input.c 2003-11-30 17:36:07.000000000 +0100 +++ MPlayer-1.0pre3/input/input.c 2004-02-06 16:50:06.000000000 +0100 @@ -1470,7 +1470,7 @@ return 0; } -extern char *get_path(char *filename); +#include "../get_path.c" void mp_input_init(void) { diff -ru MPlayer-1.0pre3.orig/libaf/af_export.c MPlayer-1.0pre3/libaf/af_export.c --- MPlayer-1.0pre3.orig/libaf/af_export.c 2003-11-28 21:43:00.000000000 +0100 +++ MPlayer-1.0pre3/libaf/af_export.c 2004-02-06 17:11:00.000000000 +0100 @@ -23,8 +23,7 @@ #include "af.h" -extern char * get_path( char * filename ); - +#include "../get_path.c" #define DEF_SZ 512 // default buffer size (in samples) #define SHARED_FILE "mplayer-af_export" /* default file name diff -ru MPlayer-1.0pre3.orig/libmpdvdkit2/libdvdcss.c MPlayer-1.0pre3/libmpdvdkit2/libdvdcss.c --- MPlayer-1.0pre3.orig/libmpdvdkit2/libdvdcss.c 2003-08-30 15:38:15.000000000 +0200 +++ MPlayer-1.0pre3/libmpdvdkit2/libdvdcss.c 2004-02-06 18:05:02.000000000 +0100 @@ -116,7 +116,7 @@ #ifndef HAVE_MPLAYER #include "get_path.c" #else - extern char * get_path( char * filename ); + #include "../get_path.c" #endif /** diff -ru MPlayer-1.0pre3.orig/libvo/font_load.c MPlayer-1.0pre3/libvo/font_load.c --- MPlayer-1.0pre3.orig/libvo/font_load.c 2003-06-09 14:15:47.000000000 +0200 +++ MPlayer-1.0pre3/libvo/font_load.c 2004-02-06 23:03:31.000000000 +0100 @@ -8,8 +8,7 @@ #include #include "font_load.h" - -extern char *get_path ( char * ); +#include "../get_path.c" raw_file* load_raw(char *name,int verbose){ int bpp; diff -ru MPlayer-1.0pre3.orig/libvo/font_load_ft.c MPlayer-1.0pre3/libvo/font_load_ft.c --- MPlayer-1.0pre3.orig/libvo/font_load_ft.c 2003-12-08 14:30:30.000000000 +0100 +++ MPlayer-1.0pre3/libvo/font_load_ft.c 2004-02-13 16:11:19.616780600 +0100 @@ -38,25 +38,9 @@ #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; +#include "../get_path.c" int using_freetype = 0; -int font_fontconfig = 0; //// constants static unsigned int const colors = 256; @@ -234,7 +218,7 @@ } // general outline -void outline( +static void outline( unsigned char *s, unsigned char *t, int width, @@ -277,7 +261,7 @@ // 1 pixel outline -void outline1( +static void outline1( unsigned char *s, unsigned char *t, int width, @@ -315,7 +299,7 @@ } // "0 pixel outline" -void outline0( +static void outline0( unsigned char *s, unsigned char *t, int width, @@ -330,7 +314,7 @@ } // gaussian blur -void blur( +static void blur( unsigned char *buffer, unsigned short *tmp2, int width, @@ -654,7 +638,7 @@ } -int generate_tables(font_desc_t *desc, double thickness, double radius) +static int generate_tables(font_desc_t *desc, double thickness, double radius) { int width = desc->max_height; int height = desc->max_width; @@ -867,57 +851,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; } @@ -947,7 +890,7 @@ return f266ToInt(kern.x); } -font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height) +static font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height) { font_desc_t *desc; @@ -1006,8 +949,10 @@ /* generate the subtitle font */ 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; + /*goto gen_osd;*/ } desc->face_cnt++; @@ -1116,47 +1061,58 @@ return 0; } -void load_font_ft(int width, int height) +static char * fontconfig_get_name(char * name) { #ifdef HAVE_FONTCONFIG FcPattern *fc_pattern; FcChar8 *s; FcBool scalable; #endif - vo_image_width = width; - vo_image_height = height; - - // protection against vo_aa font hacks - if (vo_font && !vo_font->dynamic) return; - - if (vo_font) free_font_desc(vo_font); + char * ret=NULL; -#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); - } + 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 + */ + + 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); +#endif + return ret; +} + +void load_font_ft(char * name, int width, int height) +{ +#ifdef USE_OSD + vo_font=read_font_desc_ft(name, width, height); + if (vo_font) + mp_msg(MSGT_CPLAYER,MSGL_INFO,"Freetype: loaded \"%s\"\n", name); #endif - vo_font=read_font_desc_ft(font_name, width, height); +} + +void load_font_fc_ft(char * name, int width, int height) +{ +#ifdef USE_OSD + char * tmp; + + tmp=fontconfig_get_name(name); + if (tmp) { + mp_msg(MSGT_CPLAYER,MSGL_INFO,"Fontconfig: found \"%s\" for \"%s\"\n", tmp, name); + load_font_ft(tmp, width, height); + } #endif } diff -ru MPlayer-1.0pre3.orig/libvo/font_load.h MPlayer-1.0pre3/libvo/font_load.h --- MPlayer-1.0pre3.orig/libvo/font_load.h 2003-11-20 17:25:40.000000000 +0100 +++ MPlayer-1.0pre3/libvo/font_load.h 2004-02-13 15:10:12.727232544 +0100 @@ -1,99 +1,7 @@ #ifndef __MPLAYER_FONT_LOAD_H #define __MPLAYER_FONT_LOAD_H -#ifdef HAVE_FREETYPE -#include -#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 MPlayer-1.0pre3.orig/libvo/Makefile MPlayer-1.0pre3/libvo/Makefile --- MPlayer-1.0pre3.orig/libvo/Makefile 2003-12-08 10:38:25.000000000 +0100 +++ MPlayer-1.0pre3/libvo/Makefile 2004-02-06 15:04:57.000000000 +0100 @@ -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 MPlayer-1.0pre3.orig/libvo/sub.c MPlayer-1.0pre3/libvo/sub.c --- MPlayer-1.0pre3.orig/libvo/sub.c 2003-10-27 22:36:29.000000000 +0100 +++ MPlayer-1.0pre3/libvo/sub.c 2004-02-13 16:34:14.941699432 +0100 @@ -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 MPlayer-1.0pre3.orig/libvo/vo_dxr2.c MPlayer-1.0pre3/libvo/vo_dxr2.c --- MPlayer-1.0pre3.orig/libvo/vo_dxr2.c 2003-11-30 17:36:10.000000000 +0100 +++ MPlayer-1.0pre3/libvo/vo_dxr2.c 2004-02-06 16:36:34.000000000 +0100 @@ -26,7 +26,7 @@ #include -extern char *get_path(char *filename); +#include "../get_path.c" extern float monitor_aspect; extern float movie_aspect; diff -ru MPlayer-1.0pre3.orig/loader/registry.c MPlayer-1.0pre3/loader/registry.c --- MPlayer-1.0pre3.orig/loader/registry.c 2003-04-21 22:13:21.000000000 +0200 +++ MPlayer-1.0pre3/loader/registry.c 2004-02-06 16:51:28.000000000 +0100 @@ -18,7 +18,7 @@ //#undef TRACE //#define TRACE printf -extern char *get_path ( char * ); +#include "../get_path.c" // ...can be set before init_registry() call char* regpathname = NULL; diff -ru MPlayer-1.0pre3.orig/Makefile MPlayer-1.0pre3/Makefile --- MPlayer-1.0pre3.orig/Makefile 2003-12-08 22:33:31.000000000 +0100 +++ MPlayer-1.0pre3/Makefile 2004-02-06 18:11:42.000000000 +0100 @@ -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 MPlayer-1.0pre3.orig/mencoder.c MPlayer-1.0pre3/mencoder.c --- MPlayer-1.0pre3.orig/mencoder.c 2003-12-08 22:33:31.000000000 +0100 +++ MPlayer-1.0pre3/mencoder.c 2004-02-13 16:23:38.978380552 +0100 @@ -172,6 +172,7 @@ // sub: char *font_name=NULL; +char *fontdesc_name=NULL; #ifdef HAVE_FONTCONFIG extern int font_fontconfig; #endif @@ -439,27 +440,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(); diff -ru MPlayer-1.0pre3.orig/mplayer.c MPlayer-1.0pre3/mplayer.c --- MPlayer-1.0pre3.orig/mplayer.c 2003-12-08 22:33:31.000000000 +0100 +++ MPlayer-1.0pre3/mplayer.c 2004-02-13 16:25:31.613257448 +0100 @@ -284,9 +284,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; @@ -1057,28 +1054,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 @@ -3756,11 +3735,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); --- /dev/null 2003-09-15 15:40:47.000000000 +0200 +++ MPlayer-1.0pre3/libvo/font_if.c 2004-02-13 16:36:32.791743040 +0100 @@ -0,0 +1,136 @@ + +#include "config.h" +#include "font_load.h" +#include "font_load_ft.h" +#include "../mplayer.h" +#include "../mp_msg.h" +#include "../get_path.c" +#include "font_if.h" + + +int vo_image_width = 0; +int vo_image_height = 0; + +int force_load_font; /* some component requests font reload */ +int font_loaded; /* type of loaded font (not used yet) */ + +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 init_font() +{ + int ret = 0; +#ifdef HAVE_FREETYPE + ret = init_freetype(); +#endif + return ret; +} + +int uninit_font() +{ + int ret = 0; + if (vo_font) + free_font_desc(vo_font); + vo_font = NULL; +#ifdef HAVE_FREETYPE + ret = done_freetype(); +#endif + return ret; +} + +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); +} + +void _load_font(char * name, int width, int height, char * fn, int ln) +{ + //mp_msg(MSGT_CPLAYER,MSGL_INFO, "%s:%d: load_font: w: %d, h: %d\n", fn, ln, width, height); + + if (vo_image_width != width || vo_image_height != height) { + force_load_font=1; + } + + vo_image_width = width; + vo_image_height = height; + + // protection against vo_aa font hacks + if (vo_font) { + if (!vo_font->dynamic || force_load_font == 0) { + force_load_font=0; + return; + } + free_font_desc(vo_font); + vo_font=NULL; + } + force_load_font=0; + if (name) { +#ifdef HAVE_FREETYPE + load_font_ft(name, width, height); + if (vo_font) + return; +#endif + vo_font=read_font_desc(name, font_factor, verbose>1); + if (vo_font) + return; +#ifdef HAVE_FREETYPE + load_font_fc_ft(name, width, height); + if (vo_font) + return; +#endif + } + mp_msg(MSGT_CPLAYER,MSGL_INFO,"Trying default fonts...\n"); +#ifdef HAVE_FREETYPE + load_font_ft(get_path("subfont.ttf"), width, height); + if (vo_font) + return; + load_font_ft(MPLAYER_DATADIR "/subfont.ttf", width, height); + if (vo_font) + return; + load_font_fc_ft("sans-serif", width, height); + if (vo_font) + return; +#endif + vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1); + if (vo_font) + return; + vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1); +} --- /dev/null 2003-09-15 15:40:47.000000000 +0200 +++ MPlayer-1.0pre3/libvo/font_if.h 2004-02-13 16:36:09.100344680 +0100 @@ -0,0 +1,89 @@ + +#ifndef __MPLAYER_FONT_IF_H +#define __MPLAYER_FONT_IF_H + +#include "config.h" +#ifdef HAVE_FREETYPE +#include +#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; +extern int force_load_font; + +extern int vo_image_width; +extern int vo_image_height; + +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; + +int init_font(); +int uninit_font(); + +void render_one_glyph(font_desc_t *desc, int c); +int kerning(font_desc_t *desc, int prevc, int c); +void free_font_desc(font_desc_t *desc); + +#define load_font(n, w, h) _load_font(n, w, h, __FILE__, __LINE__) +void _load_font(char * name, int width, int height, char * fn, int ln); + +#endif /* ! __MPLAYER_FONT_IF_H */ --- /dev/null 2003-09-15 15:40:47.000000000 +0200 +++ MPlayer-1.0pre3/libvo/font_load_ft.h 2004-02-13 16:35:54.904502776 +0100 @@ -0,0 +1,14 @@ + +#ifndef __MPLAYER_FONT_LOAD_FT_H +#define __MPLAYER_FONT_LOAD_FT_H + +#ifdef HAVE_FREETYPE + +int init_freetype(); +int done_freetype(); +void load_font_ft(char * name, int width, int height) ; +void load_font_fc_ft(char * name, int width, int height); + +#endif /* HAVE_FREETYPE */ + +#endif /* ! __MPLAYER_FONT_LOAD_FT_H */