[MPlayer-dev-eng] [PATCH] autodetecting font= type

Wojtek Kaniewski wojtekka at bydg.pdi.net
Wed Dec 18 18:16:46 CET 2002


last time it went to the list without [PATCH] in the subject.

On Mon, 16 Dec 2002, Wojtek Kaniewski wrote:

> On Mon, 16 Dec 2002, Arpi wrote:
> > freetype.diff - (enables both old and new font support at the same time)
> >                  needs to be changed to check for new-type fonts (ttf) first
> 
> i've attached simple patch, that checks two first bytes of font
> description and if they match ttf/pfm/pfb/fon/pcf/pcf.gz, mplayer
> ignores it instead of showing garbage on stdout. simple, but seems
> to work fine.
> 
> regards,
> wojtek
> 
-------------- next part --------------
--- libvo/font_load.c	Mon Dec 16 21:04:09 2002
+++ libvo/font_load.c	Mon Dec 16 21:34:42 2002
@@ -54,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));
@@ -90,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++;


More information about the MPlayer-dev-eng mailing list