[MPlayer-cvslog] r32873 - in trunk/gui/skin: font.c font.h

ib subversion at mplayerhq.hu
Thu Feb 10 12:35:33 CET 2011


Author: ib
Date: Thu Feb 10 12:35:32 2011
New Revision: 32873

Log:
Define constants in a single place.

Modified:
   trunk/gui/skin/font.c
   trunk/gui/skin/font.h

Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c	Thu Feb 10 12:17:12 2011	(r32872)
+++ trunk/gui/skin/font.c	Thu Feb 10 12:35:32 2011	(r32873)
@@ -26,21 +26,21 @@
 #include "mp_msg.h"
 #include "libavutil/avstring.h"
 
-bmpFont * Fonts[26] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
+bmpFont * Fonts[MAX_FONTS + 1] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
 
 int fntAddNewFont( char * name )
 {
  int id;
  int i;
 
- for( id=0;id<26;id++ )
+ for( id=0;id<MAX_FONTS + 1;id++ )
    if ( !Fonts[id] ) break;
 
- if ( id == 25 ) return -2;
+ if ( id == MAX_FONTS ) return -2;
 
  if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
 
- av_strlcpy( Fonts[id]->name,name,128 ); // FIXME: as defined in font.h
+ av_strlcpy( Fonts[id]->name,name,MAX_FONT_NAME );
  for ( i=0;i<ASCII_CHRS+EXTRA_CHRS;i++ )
    Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
 
@@ -50,7 +50,7 @@ int fntAddNewFont( char * name )
 void fntFreeFont( void )
 {
  int i;
- for( i=0;i < 25;i++ )
+ for( i=0;i < MAX_FONTS;i++ )
   {
    if ( Fonts[i] )
     {
@@ -137,7 +137,7 @@ int fntRead( char * path,char * fname )
 int fntFindID( char * name )
 {
  int i;
- for ( i=0;i < 25;i++ )
+ for ( i=0;i < MAX_FONTS;i++ )
    if ( Fonts[i] )
      if ( !strcmp( name,Fonts[i]->name ) ) return i;
  return -1;

Modified: trunk/gui/skin/font.h
==============================================================================
--- trunk/gui/skin/font.h	Thu Feb 10 12:17:12 2011	(r32872)
+++ trunk/gui/skin/font.h	Thu Feb 10 12:35:32 2011	(r32873)
@@ -26,6 +26,9 @@
 #define ASCII_CHRS 128   // number of ASCII characters
 #define EXTRA_CHRS 128   // (arbitrary) number of non-ASCII characters
 
+#define MAX_FONT_NAME 128
+#define MAX_FONTS 25
+
 #define fntAlignLeft   0
 #define fntAlignCenter 1
 #define fntAlignRight  2
@@ -41,10 +44,10 @@ typedef struct
  fntChar         Fnt[ASCII_CHRS + EXTRA_CHRS];
  unsigned char   nonASCIIidx[EXTRA_CHRS][4];
  txSample        Bitmap;
- char            name[128];
+ char            name[MAX_FONT_NAME];
 } bmpFont;
 
-extern bmpFont  * Fonts[26];
+extern bmpFont  * Fonts[MAX_FONTS + 1];
 
 int  fntAddNewFont( char * name );
 void fntFreeFont( void );


More information about the MPlayer-cvslog mailing list