[Mplayer-cvslog] CVS: main/libvo font_load.c,1.24,1.25 font_load.h,1.11,1.12 font_load_ft.c,1.5,1.6 sub.c,1.65,1.66

Arpi of Ize arpi at mplayerhq.hu
Sun Dec 29 15:59:26 CET 2002


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

Modified Files:
	font_load.c font_load.h font_load_ft.c sub.c 
Log Message:
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.
(also you can use -font /path/to/font.desc and -font /path/to/foobar.ttf too)
patch-set by Wojtek Kaniewski <wojtekka at bydg.pdi.net>


Index: font_load.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- font_load.c	28 Aug 2002 20:52:02 -0000	1.24
+++ font_load.c	29 Dec 2002 14:59:23 -0000	1.25
@@ -1,7 +1,5 @@
 #include "config.h"
 
-#ifndef HAVE_FREETYPE
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -56,6 +54,7 @@
 int chardb=0;
 int fontdb=-1;
 int version=0;
+int first=1;
 
 desc=malloc(sizeof(font_desc_t));if(!desc) return NULL;
 memset(desc,0,sizeof(font_desc_t));
@@ -92,6 +91,21 @@
   int ec=' ';
   int id=0;
   sor[1020]=0;
+
+  /* skip files that look like: TTF (0x00, 0x01), PFM (0x00, 0x01), PFB
+   * (0x80, 0x01), PCF (0x01, 0x66), fon ("MZ"), gzipped (0x1f, 0x8b) */
+  
+  if (first) {
+    if (!sor[0] || sor[1] == 1 || (sor[0] == 'M' && sor[1] == 'Z') || (sor[0] == 0x1f && sor[1] == 0x8b) || (sor[0] == 1 && sor[1] == 0x66)) {
+      printf("%s doesn't look like a font description, ignoring\n", fname);
+      fclose(f);
+      free(desc);
+      free(dn);
+      return NULL;
+    }
+    first = 0;
+  }
+  
   p[0]=d;++pdb;
   while(1){
       int c=*s++;
@@ -303,4 +317,3 @@
 }
 #endif
 
-#endif /* HAVE_FREETYPE */

Index: font_load.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- font_load.h	30 Aug 2002 13:53:27 -0000	1.11
+++ font_load.h	29 Dec 2002 14:59:23 -0000	1.12
@@ -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 */

Index: font_load_ft.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load_ft.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- font_load_ft.c	6 Nov 2002 23:54:27 -0000	1.5
+++ font_load_ft.c	29 Dec 2002 14:59:23 -0000	1.6
@@ -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
 }
 

Index: sub.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/sub.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- sub.c	28 Dec 2002 15:03:23 -0000	1.65
+++ sub.c	29 Dec 2002 14:59:23 -0000	1.66
@@ -526,9 +526,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
 




More information about the MPlayer-cvslog mailing list