[MPlayer-dev-eng] [PATCH] dynamic font generation

Jindrich Makovicka makovick at KMLinux.fjfi.cvut.cz
Sat Aug 24 10:58:46 CEST 2002


On Sat, Aug 24, 2002 at 11:08:00AM +0200, Arpi wrote:
> Hi,
> 
> > currently the font is loaded in vf_vo, but there is no problem in changing
> > that because this is just about moving one line to another place.
> 
> it's not a good idea, as vf_vo is not used in mencoder but the font is needed
> 

I already moved it to sub.c and it seems to work good for both mplayer and
mencoder. Here are the changes.

-- 
Jindrich Makovicka
-------------- next part --------------
diff -urN prev/main/DOCS/mplayer.1 main/DOCS/mplayer.1
--- prev/main/DOCS/mplayer.1	Sat Aug 24 10:55:59 2002
+++ main/DOCS/mplayer.1	Sat Aug 24 10:55:44 2002
@@ -663,7 +663,7 @@
 .B \-subfont-outline
 Sets the font outline thickness.
 .TP
-.B \-subfont-autoscale <0-3> (MPLAYER only)
+.B \-subfont-autoscale <0-3>
 Sets the autoscale mode. Can be
     0    no autoscale,
     1    proportional to movie width,
@@ -671,7 +671,7 @@
     3    proportional to movie diagonal.
 
 Default is 3 (diagonal). Zero means that text-scale and osd-scale are
-font heights in points. For mencoder, this option is always zero.
+font heights in points.
 .TP
 .B \-noautosub
 Turns off automatic subtitles.
diff -urN prev/main/cfg-common.h main/cfg-common.h
--- prev/main/cfg-common.h	Sat Aug 24 10:55:59 2002
+++ main/cfg-common.h	Sat Aug 24 10:55:44 2002
@@ -169,6 +169,7 @@
  	{"subfont-osd-scale", &osd_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
  	{"subfont-blur", &subtitle_font_radius, CONF_TYPE_FLOAT, CONF_RANGE, 0, 8, NULL},
  	{"subfont-outline", &subtitle_font_thickness, CONF_TYPE_FLOAT, CONF_RANGE, 0, 8, NULL},
+ 	{"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
 #endif
 #endif
 
diff -urN prev/main/cfg-mplayer.h main/cfg-mplayer.h
--- prev/main/cfg-mplayer.h	Sat Aug 24 10:55:59 2002
+++ main/cfg-mplayer.h	Fri Aug 23 18:38:03 2002
@@ -294,9 +294,6 @@
 
 	{"osdlevel", &osd_level, CONF_TYPE_INT, CONF_RANGE, 0, 2 , NULL},
 
-#ifdef HAVE_FREETYPE
- 	{"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
-#endif
 	// these should be moved to -common, and suppot in mencoder too
 	{"vobsub", &vobsub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
 	{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
diff -urN prev/main/libmpcodecs/vf_vo.c main/libmpcodecs/vf_vo.c
--- prev/main/libmpcodecs/vf_vo.c	Sat Aug 24 10:55:59 2002
+++ main/libmpcodecs/vf_vo.c	Mon Jul 29 18:13:41 2002
@@ -10,14 +10,6 @@
 
 #include "../libvo/video_out.h"
 
-#ifdef HAVE_FREETYPE
-void load_font(int width, int height);
-#else
-extern void inline load_font(int width, int height)
-{
-}
-#endif
-
 //===========================================================================//
 
 #define video_out ((vo_functions_t*)(vf->priv))
@@ -47,8 +39,6 @@
     if(info->comment && strlen(info->comment) > 0)
         mp_msg(MSGT_CPLAYER,MSGL_V,"VO: Comment: %s\n", info->comment);
   }
-
-  load_font(width, height);
 
     if(video_out->config(width,height,d_width,d_height,flags,"MPlayer",outfmt,NULL))
 	return 0;
diff -urN prev/main/libvo/font_load.h main/libvo/font_load.h
--- prev/main/libvo/font_load.h	Sat Aug 24 10:55:59 2002
+++ main/libvo/font_load.h	Sat Aug 24 10:55:44 2002
@@ -71,6 +71,8 @@
 extern int vo_image_width;
 extern int vo_image_height;
 
+extern int force_load_font;
+
 int init_freetype();
 int done_freetype();
 
diff -urN prev/main/libvo/font_load_ft.c main/libvo/font_load_ft.c
--- prev/main/libvo/font_load_ft.c	Sat Aug 24 10:55:59 2002
+++ main/libvo/font_load_ft.c	Sat Aug 24 10:55:44 2002
@@ -43,6 +43,7 @@
 
 int vo_image_width = 0;
 int vo_image_height = 0;
+int force_load_font;
 
 //// constants
 static int const colors = 256;
@@ -1067,7 +1068,6 @@
 #ifdef USE_OSD
     vo_font=read_font_desc(font_name, font_factor, width, height);
 #endif
-    vo_init_osd();
 }
 
 #endif /* HAVE_FREETYPE */
diff -urN prev/main/libvo/sub.c main/libvo/sub.c
--- prev/main/libvo/sub.c	Sat Aug 24 10:55:59 2002
+++ main/libvo/sub.c	Sat Aug 24 10:55:44 2002
@@ -54,7 +54,9 @@
     unsigned char *as = srca;
 
     if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
-	fprintf(stderr, "osd text out of range!\n");
+	fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
+		obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
+		x0, x0+w, y0, y0+h);
 	return;
     }
     
@@ -249,6 +251,7 @@
     render_one_glyph(vo_font, OSD_PB_END);
     render_one_glyph(vo_font, OSD_PB_0);
     render_one_glyph(vo_font, OSD_PB_1);
+    render_one_glyph(vo_font, vo_osd_progbar_type);
     
     {	int h=0;
         int y=(dys-vo_font->height)/2;
@@ -505,6 +508,15 @@
 int vo_update_osd(int dxs,int dys){
     mp_osd_obj_t* obj=vo_osd_list;
     int chg=0;
+
+#ifdef HAVE_FREETYPE    
+    // here is the right place to get screen dimensions
+    if (force_load_font) {
+	force_load_font = 0;
+	load_font(dxs, dys);
+    }
+#endif
+
     while(obj){
       if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){
         int vis=obj->flags&OSDFLAG_VISIBLE;
@@ -577,6 +589,9 @@
     new_osd_obj(OSDTYPE_SUBTITLE);
     new_osd_obj(OSDTYPE_PROGBAR);
     new_osd_obj(OSDTYPE_SPU);
+#ifdef HAVE_FREETYPE
+    force_load_font = 1;
+#endif
 }
 
 int vo_osd_changed_flag=0;
diff -urN prev/main/mencoder.c main/mencoder.c
--- prev/main/mencoder.c	Sat Aug 24 10:55:59 2002
+++ main/mencoder.c	Sat Aug 24 10:55:44 2002
@@ -392,8 +392,6 @@
 #ifdef USE_OSD
 #ifdef HAVE_FREETYPE
   init_freetype();
-  subtitle_autoscale = 0; // disable autoscale
-  vo_font=read_font_desc(font_name, font_factor, 0, 0);
 #else
   if(font_name){
        vo_font=read_font_desc(font_name,font_factor,verbose>1);
diff -urN prev/main/mplayer.c main/mplayer.c
--- prev/main/mplayer.c	Sat Aug 24 10:55:59 2002
+++ main/mplayer.c	Sat Aug 24 10:55:44 2002
@@ -705,6 +705,7 @@
   vo_init_osd();
 #else
   init_freetype();
+  vo_init_osd();
 #endif
 
 #if defined(HAVE_LIRC) && ! defined(HAVE_NEW_INPUT)
@@ -1357,6 +1358,10 @@
 
    if(vo_flags & 0x08 && vo_spudec)
       spudec_set_hw_spu(vo_spudec,video_out);
+
+#ifdef HAVE_FREETYPE
+   force_load_font = 1;
+#endif
 
 //================== MAIN: ==========================
    main:


More information about the MPlayer-dev-eng mailing list