changeset 32759:63844ef43932

Remove useless format argument. Because scrolling of dynamic labels depends on the length of the label text, any other format than %s to render would be pointless.
author ib
date Thu, 03 Feb 2011 14:19:19 +0000
parents ee56fbdc58ab
children 6b394b24f81c
files gui/mplayer/gui_common.c gui/skin/font.c gui/skin/font.h
diffstat 3 files changed, 15 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/gui/mplayer/gui_common.c	Thu Feb 03 14:04:43 2011 +0000
+++ b/gui/mplayer/gui_common.c	Thu Feb 03 14:19:19 2011 +0000
@@ -294,14 +294,14 @@
 	    3,item->pressed );
           break;
      case itSLabel:
-          image=fntRender( item,0,"%s",item->label );
+          image=fntRender( item,0,item->label );
           if ( image ) PutImage( image,item->x,item->y,1,0 );
      case itDLabel:
           {
            char * t = Translate( item->label );
            int    l = fntTextWidth( item->fontid,t );
            l=(l?l:item->width);
-           image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
+           image=fntRender( item,l-(GetTimerMS() / 20)%l,t );
 	  }
           if ( image ) PutImage( image,item->x,item->y,1,0 );
           break;
--- a/gui/skin/font.c	Thu Feb 03 14:04:43 2011 +0000
+++ b/gui/skin/font.c	Thu Feb 03 14:19:19 2011 +0000
@@ -232,34 +232,29 @@
  return max;
 }
 
-txSample * fntRender( wItem * item,int px,const char * fmt,... )
+txSample * fntRender( wItem * item,int px,char * txt )
 {
- va_list         ap;
- unsigned char * u, p[512];
+ unsigned char * u;
  int 	         c, i, dx = 0, tw, fbw, iw, id, ofs;
  int 		 x,y,fh,fw,fyc,yc;
  uint32_t      * ibuf;
  uint32_t      * obuf;
  gboolean        utf8;
 
- va_start( ap,fmt );
- vsnprintf( p,512,fmt,ap );
- va_end( ap );
-
  iw=item->width;
  id=item->fontid;
 
  if ( ( !item )||
       ( !Fonts[id] )||
-      ( !p[0] )||
-      ( !fntTextWidth( id,p ) ) ) return NULL;
+      ( !txt[0] )||
+      ( !fntTextWidth( id,txt ) ) ) return NULL;
 
- tw=fntTextWidth( id,p );
+ tw=fntTextWidth( id,txt );
  fbw=Fonts[id]->Bitmap.Width;
 
  if ( item->Bitmap.Image == NULL )
   {
-   item->Bitmap.Height=item->height=fntTextHeight( id,p );
+   item->Bitmap.Height=item->height=fntTextHeight( id,txt );
    item->Bitmap.Width=item->width=iw;
    item->Bitmap.ImageSize=item->height * iw * 4;
    if ( !item->Bitmap.ImageSize ) return NULL;
@@ -278,16 +273,16 @@
     {
      default:
      case fntAlignLeft:   dx=0; break;
-     case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break;
-     case fntAlignRight:  dx=iw - fntTextWidth( id,p ); break;
+     case fntAlignCenter: dx=( iw - fntTextWidth( id,txt ) ) / 2; break;
+     case fntAlignRight:  dx=iw - fntTextWidth( id,txt ); break;
     }
 
   } else dx+=px;
 
  ofs=dx;
 
- utf8 = g_utf8_validate( p, -1, NULL);
- u = p;
+ utf8 = g_utf8_validate( txt, -1, NULL);
+ u = txt;
 
  while ( *u )
   {
@@ -315,9 +310,9 @@
  if ( ofs > 0 && tw > item->width )
   {
    dx=ofs;
-   u = p + strlen( p );
+   u = txt + strlen( txt );
 
-   while ( u > p )
+   while ( u > (unsigned char *) txt )
     {
      c = fntGetCharIndex( id, &u, utf8, -1 );
 
--- a/gui/skin/font.h	Thu Feb 03 14:04:43 2011 +0000
+++ b/gui/skin/font.h	Thu Feb 03 14:19:19 2011 +0000
@@ -55,6 +55,6 @@
 int  fntTextWidth( int id, char * str );
 
 int        fntRead( char * path, char * fname );
-txSample * fntRender( wItem * item, int px, const char * fmt, ... );
+txSample * fntRender( wItem * item, int px, char * txt );
 
 #endif /* MPLAYER_GUI_FONT_H */