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

Robert Ramiega jedi at plukwa.net
Thu Oct 27 15:54:17 CEST 2005


On Tue, Oct 18, 2005 at 04:03:25PM +0200, Robert Ramiega wrote:
>   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've slightly revised my patch and here is updated version.

-- 
Just a friendly Jedi Knight     | I find your lack of faith
Robert Ramiega jedi at plukwa.net  | disturbing
-------------- next part --------------
Index: libvo/font_load_ft.c
===================================================================
--- libvo/font_load_ft.c	(revision 11)
+++ libvo/font_load_ft.c	(working copy)
@@ -917,8 +917,8 @@
 	if (err) {
 	    err = FT_New_Face(library, MPLAYER_DATADIR "/subfont.ttf", 0, face);
 	    if (err) {
-	        mp_msg(MSGT_OSD, MSGL_ERR, "New_Face failed. Maybe the font path is wrong.\nPlease supply the text font file (~/.mplayer/subfont.ttf).\n" );
-		return -1;
+	        mp_msg(MSGT_OSD, MSGL_ERR, "Please supply the text font file (~/.mplayer/subfont.ttf).\n" );
+		return -2;
 	    }
 	}
     }
@@ -928,7 +928,7 @@
 static int load_osd_face(FT_Face *face)
 {
     if ( FT_New_Memory_Face(library, osd_font_pfb, sizeof(osd_font_pfb), 0, face) ) {
-	mp_msg(MSGT_OSD, MSGL_ERR, "New_Memory_Face failed..\n");
+	mp_msg(MSGT_OSD, MSGL_ERR, "Creating OSD font face failed.\n");
 	return -1;
     }
     return 0;
@@ -971,19 +971,23 @@
     float subtitle_font_ppem;
     float osd_font_ppem;
 
-    switch (subtitle_autoscale) {
-    case 1:
-	movie_size = movie_height;
-	break;
-    case 2:
-	movie_size = movie_width;
-	break;
-    case 3:
-	movie_size = sqrt(movie_height*movie_height+movie_width*movie_width);
-	break;
-    default:
-	movie_size = 100;
-	break;
+    if (movie_width < 0 && movie_height < 0)
+        movie_size = 100;
+    else {
+	switch (subtitle_autoscale) {
+        case 1:
+	    movie_size = movie_height;
+	    break;
+        case 2:
+	    movie_size = movie_width;
+	    break;
+        case 3:
+	    movie_size = sqrt(movie_height*movie_height+movie_width*movie_width);
+	    break;
+        default:
+	    movie_size = 100;
+	    break;
+	}
     }
 
     subtitle_font_ppem = movie_size*text_font_scale_factor/100.0;
@@ -1010,7 +1014,7 @@
     /* generate the subtitle font */
     err = load_sub_face(fname, &face);
     if (err) {
-	mp_msg(MSGT_OSD, MSGL_WARN, "subtitle font: load_sub_face failed.\n");
+	
 	goto gen_osd;
     }
     desc->face_cnt++;
@@ -1127,8 +1131,10 @@
     FcChar8 *s;
     FcBool scalable;
 #endif
-    vo_image_width = width;
-    vo_image_height = height;
+    if (width > 0)
+        vo_image_width = width;
+    if (height > 0)
+        vo_image_height = height;
 
     // protection against vo_aa font hacks
     if (vo_font && !vo_font->dynamic) return;
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 11)
+++ mplayer.c	(working copy)
@@ -1338,7 +1338,7 @@
        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);
+		 vo_font=read_font_desc_ft(font_name, -1, -1);
 		 if(!vo_font)
 #endif
 	              mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
@@ -1351,10 +1351,10 @@
        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, &sec_err);
+          vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1, &sec_err);
   }
 #ifdef HAVE_FONTCONFIG
-  }
+  } else load_font_ft(-1, -1);
 #endif
 #endif /* USE_OSD */
   vo_init_osd();
Index: mencoder.c
===================================================================
--- mencoder.c	(revision 12)
+++ mencoder.c	(working copy)
@@ -503,7 +503,7 @@
        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);
+                 vo_font=read_font_desc_ft(font_name, -1, -1);
                  if(!vo_font)
 #endif
                       mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
@@ -515,10 +515,10 @@
       // try default:
        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,&sec_err);
+          vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1,&sec_err);
   }
 #ifdef HAVE_FONTCONFIG
-  }
+  } else load_font_ft(-1, -1);
 #endif
 #endif
 


More information about the MPlayer-dev-eng mailing list