diff libvo/font_load.c @ 8635:81dbd28ef7c0

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@bydg.pdi.net>
author arpi
date Sun, 29 Dec 2002 14:59:23 +0000
parents 0dc9cb756b68
children 7b0bc557987b
line wrap: on
line diff
--- a/libvo/font_load.c	Sun Dec 29 14:36:56 2002 +0000
+++ b/libvo/font_load.c	Sun Dec 29 14:59:23 2002 +0000
@@ -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 */