[MPlayer-dev-eng] [PATCH] autodetecting freetype
Wojtek Kaniewski
wojtekka at bydg.pdi.net
Tue Dec 10 17:31:55 CET 2002
these patches let ,,oldstyle'' and freetype subtitle renderers live
together happily. if an oldstyle subtitle (font.desc) is found, it will
be used. otherwise mplayer will choose subfont.ttf, if freetype was
detected during ./configure.
regards,
wojtek
-------------- next part --------------
--- mplayer.c 5 Dec 2002 00:18:56 -0000 1.624
+++ mplayer.c 10 Dec 2002 16:46:03 -0000
@@ -743,7 +743,6 @@
//------ load global data first ------
#ifdef USE_OSD
-#ifndef HAVE_FREETYPE
// check font
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
@@ -754,8 +753,9 @@
if(!vo_font)
vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1);
}
-#else
- init_freetype();
+#ifdef HAVE_FREETYPE
+ if (!vo_font)
+ init_freetype();
#endif
#endif
vo_init_osd();
--- Gui/interface.c 29 Nov 2002 00:58:22 -0000 1.63
+++ Gui/interface.c 10 Dec 2002 16:46:05 -0000
@@ -301,7 +301,7 @@
void guiLoadFont( void )
{
#ifdef HAVE_FREETYPE
- load_font(vo_image_width, vo_image_height);
+ load_font_ft(vo_image_width, vo_image_height);
#else
if ( vo_font )
{
--- libmenu/vf_menu.c 22 Nov 2002 12:01:59 -0000 1.4
+++ libmenu/vf_menu.c 10 Dec 2002 16:46:08 -0000
@@ -241,7 +241,7 @@
// here is the right place to get screen dimensions
if (force_load_font) {
force_load_font = 0;
- load_font(width,height);
+ load_font_ft(width,height);
}
#endif
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
--- libvo/font_load.c 28 Aug 2002 20:52:02 -0000 1.24
+++ libvo/font_load.c 10 Dec 2002 16:46:09 -0000
@@ -1,7 +1,5 @@
#include "config.h"
-#ifndef HAVE_FREETYPE
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -303,4 +301,3 @@
}
#endif
-#endif /* HAVE_FREETYPE */
--- libvo/font_load.h 30 Aug 2002 13:53:27 -0000 1.11
+++ libvo/font_load.h 10 Dec 2002 16:46:09 -0000
@@ -31,6 +31,7 @@
short font[65536];
int start[65536]; // short is not enough for unicode fonts
short width[65536];
+ int freetype;
#ifdef HAVE_FREETYPE
int face_cnt;
@@ -78,23 +79,22 @@
int init_freetype();
int done_freetype();
-font_desc_t* read_font_desc(char* fname,int movie_width, int movie_height);
+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(int width, int height);
+void load_font_ft(int width, int height);
#else
-raw_file* load_raw(char *name,int verbose);
-font_desc_t* read_font_desc(char* fname,float factor,int verbose);
-
-static void inline render_one_glyph(font_desc_t *desc, int c) {}
-static int inline kerning(font_desc_t *desc, int prevc, int c) { return 0; }
-static void inline load_font(int width, int height){}
+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
+
+raw_file* load_raw(char *name,int verbose);
+font_desc_t* read_font_desc(char* fname,float factor,int verbose);
#endif /* ! __MPLAYER_FONT_LOAD_H */
--- libvo/font_load_ft.c 6 Nov 2002 23:54:27 -0000 1.5
+++ libvo/font_load_ft.c 10 Dec 2002 16:46:12 -0000
@@ -50,6 +50,8 @@
int vo_image_height = 0;
int force_load_font;
+int using_freetype = 0;
+
//// constants
static unsigned int const colors = 256;
static unsigned int const maxcolor = 255;
@@ -937,7 +939,7 @@
return f266ToInt(kern.x);
}
-font_desc_t* read_font_desc(char *fname, int movie_width, int movie_height)
+font_desc_t* read_font_desc_ft(char *fname, int movie_width, int movie_height)
{
font_desc_t *desc;
@@ -1086,12 +1088,16 @@
return -1;
}
fprintf(stderr, "init_freetype\n");
+ using_freetype = 1;
return 0;
}
int done_freetype()
{
int err;
+
+ if (!using_freetype)
+ return 0;
err = FT_Done_FreeType(library);
if (err) {
@@ -1102,7 +1108,7 @@
return 0;
}
-void load_font(int width, int height)
+void load_font_ft(int width, int height)
{
vo_image_width = width;
vo_image_height = height;
@@ -1113,7 +1119,7 @@
if (vo_font) free_font_desc(vo_font);
#ifdef USE_OSD
- vo_font=read_font_desc(font_name, width, height);
+ vo_font=read_font_desc_ft(font_name, width, height);
#endif
}
--- libvo/sub.c 5 Dec 2002 00:03:35 -0000 1.58
+++ libvo/sub.c 10 Dec 2002 16:46:14 -0000
@@ -510,9 +510,9 @@
#ifdef HAVE_FREETYPE
// here is the right place to get screen dimensions
- if (force_load_font) {
+ if (!vo_font && force_load_font) {
force_load_font = 0;
- load_font(dxs, dys);
+ load_font_ft(dxs, dys);
}
#endif
-------------- next part --------------
--- documentation.html Tue Dec 10 14:44:09 2002
+++ documentation.html Tue Dec 10 17:24:55 2002
@@ -942,8 +942,7 @@
<LI>use the font generator GIMP plugin at TOOLS/subfont-GIMP
(note: you must have HSI RAW plugin too, see URL below)</LI>
<LI>using a TrueType (TTF) font, by the means of the <B>freetype</B>
- library. Version 2.0.9 or greater is mandatory! You have to pass the
- <CODE>--enable-freetype</CODE> option to ./configure. Then you
+ library. Version 2.0.9 or greater is mandatory! Then you
have two methods:
<UL>
<LI>use the <CODE>-font /path/to/arial.ttf</CODE> option to specify
--- configure Tue Dec 10 14:43:57 2002
+++ configure Tue Dec 10 17:23:22 2002
@@ -149,7 +149,7 @@
--disable-mpdvdkit Disable mpdvdkit/mpdvdkit2 support [autodetect]
--disable-css Disable old-style libcss DVD support [autodetect]
--disable-cdparanoia Disable cdparanoia support [autodetect]
- --enable-freetype Enable freetype2 font rendering support [disabled]
+ --disable-freetype Disable freetype2 font rendering 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 (need new config) [disabled]
@@ -1025,7 +1025,7 @@
_libdv=auto
_cdparanoia=auto
_big_endian=auto
-_freetype=no
+_freetype=auto
_shared_pp=no
_new_conf=yes
_menu=no
@@ -3473,7 +3473,7 @@
echores "$_cdparanoia"
echocheck "freetype >= 2.0.9"
-if test "$_freetype" = yes ; then
+if test "$_freetype" = auto ; then
test -z "$_freetypeconfig" && _freetypeconfig='freetype-config'
if ( $_freetypeconfig --version ) >/dev/null 2>&1 ; then
cat > $TMPC << EOF
More information about the MPlayer-dev-eng
mailing list