[MPlayer-dev-eng] [PATCH] Dont show font.desc related error when not needed

Robert Ramiega jedi at plukwa.net
Tue Oct 18 16:03:25 CEST 2005


  Hi!
 If mplayer is compiled with libfreetype support and -font option is used to
show ttf font, mplayer puts unnecesary error message. 
 Attached patch shoud cure it. I hope that using svn diff to make patch is
acceptable here =o)
 
-- 
Just a friendly Jedi Knight     | I find your lack of faith
Robert Ramiega jedi at plukwa.net  | disturbing
-------------- next part --------------
Index: libvo/font_load.c
===================================================================
--- libvo/font_load.c	(revision 2)
+++ libvo/font_load.c	(working copy)
@@ -43,7 +43,7 @@
 
 extern int sub_unicode;
 
-font_desc_t* read_font_desc(char* fname,float factor,int verbose){
+font_desc_t* read_font_desc(char* fname,float factor,int verbose, int *sec_err){
 unsigned char sor[1024];
 unsigned char sor2[1024];
 font_desc_t *desc;
@@ -98,7 +98,11 @@
   
   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)) {
+#ifndef HAVE_FREETYPE
+      /* This might be some libfreetype supported font so don't 
+       * trouble enduser */
       mp_msg(MSGT_OSD, MSGL_ERR, "%s doesn't look like a font description, ignoring.\n", fname);
+#endif
       goto fail_out;
     }
     first = 0;
@@ -169,6 +173,7 @@
 		snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
 			 default_dir,p[1]);
 		if (!((desc->pic_a[fontdb]=load_raw(cp,verbose)))){
+		   *sec_err = 1;
 		   mp_msg(MSGT_OSD, MSGL_ERR, "Can't load font bitmap: %s\n",p[1]);
 		   free(cp);
 		   goto fail_out;
@@ -190,6 +195,7 @@
 		snprintf(cp,strlen(default_dir)+strlen(p[1])+2,"%s/%s",
 			 default_dir,p[1]);
 		if (!((desc->pic_b[fontdb]=load_raw(cp,verbose)))){
+		   *sec_err = 1;
 		   mp_msg(MSGT_OSD, MSGL_ERR, "Can't load font bitmap: %s\n",p[1]);
 		   free(cp);
 		   goto fail_out;
@@ -231,6 +237,7 @@
           if(sub_unicode && (chr>=0x80)) chr=(chr<<8)+p[0][1];
           else if(strlen(p[0])!=1) chr=strtol(p[0],NULL,0);
           if(end<start) {
+	      *sec_err = 1;
               mp_msg(MSGT_OSD, MSGL_WARN, "error in font desc: end<start for char '%c'\n",chr);
           } else {
               desc->start[chr]=start;
@@ -243,6 +250,7 @@
       }
   }
   mp_msg(MSGT_OSD, MSGL_ERR, "Syntax error in font desc: %s",sor);
+  *sec_err = 1;
   goto fail_out;
 
 }
@@ -259,6 +267,7 @@
 for(i=0;i<=fontdb;i++){
     if(!desc->pic_a[i] || !desc->pic_b[i]){
         mp_msg(MSGT_OSD, MSGL_ERR, "font: Missing bitmap(s) for sub-font #%d\n",i);
+	*sec_err = 1;
         goto fail_out;
     }
     //if(factor!=1.0f)
Index: libvo/font_load.h
===================================================================
--- libvo/font_load.h	(revision 2)
+++ libvo/font_load.h	(working copy)
@@ -96,6 +96,6 @@
 #endif
 
 raw_file* load_raw(char *name,int verbose);
-font_desc_t* read_font_desc(char* fname,float factor,int verbose);
+font_desc_t* read_font_desc(char* fname,float factor,int verbose, int *sec_err);
 
 #endif /* ! __MPLAYER_FONT_LOAD_H */
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 3)
+++ mplayer.c	(working copy)
@@ -1045,6 +1045,8 @@
 
 int delay_corrected=1;
 
+int sec_err=0;
+
 // movie info:
 
 int osd_function=OSD_PLAY;
@@ -1360,17 +1362,24 @@
   {
 #endif
   if(font_name){
-       vo_font=read_font_desc(font_name,font_factor,verbose>1);
+       vo_font=read_font_desc(font_name,font_factor,verbose>1, &sec_err);
        if(!vo_font) 
-#ifndef HAVE_FREETYPE
-	    mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+#ifdef HAVE_FREETYPE
+	    if(sec_err == 0) {  /* This might be libfreetype supported font */
+		 vo_font=read_font_desc_ft(font_name, 1, 1);
+		 if(!vo_font)
 #endif
+	              mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+#ifdef HAVE_FREETYPE
+	    } else
+		 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+#endif
   } else {
       // try default:
-       vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1);
+       vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1, &sec_err);
        free(mem_ptr); // release the buffer created by get_path()
        if(!vo_font)
-       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1);
+       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1, &sec_err);
   }
 #ifdef HAVE_FONTCONFIG
   }
Index: mencoder.c
===================================================================
--- mencoder.c	(revision 2)
+++ mencoder.c	(working copy)
@@ -395,6 +395,8 @@
 int curfile=0;
 int new_srate;
 
+int sec_err = 0;
+
 unsigned int timer_start;
 ao_data_t ao_data = {0,0,0,0,OUTBURST,-1,0};
 
@@ -493,13 +495,23 @@
   {
 #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);
+       vo_font=read_font_desc(font_name,font_factor,verbose>1,&sec_err);
+       if(!vo_font)
+#ifdef HAVE_FREETYPE
+            if(sec_err == 0) {  /* This might be libfreetype supported font */
+                 vo_font=read_font_desc_ft(font_name, 1, 1);
+                 if(!vo_font)
+#endif
+                      mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+#ifdef HAVE_FREETYPE
+            } else
+                 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
+#endif
   } else {
       // try default:
-       vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
+       vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1,&sec_err);
        if(!vo_font)
-       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1);
+       vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1,&sec_err);
   }
 #ifdef HAVE_FONTCONFIG
   }


More information about the MPlayer-dev-eng mailing list