changeset 32786:31f88a1387ad

Define constants in a single place.
author ib
date Thu, 10 Feb 2011 11:35:32 +0000
parents 91625bcadbe8
children d55d0bb7d00f
files gui/skin/font.c gui/skin/font.h
diffstat 2 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/gui/skin/font.c	Thu Feb 10 11:17:12 2011 +0000
+++ b/gui/skin/font.c	Thu Feb 10 11:35:32 2011 +0000
@@ -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 @@
 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 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;
--- a/gui/skin/font.h	Thu Feb 10 11:17:12 2011 +0000
+++ b/gui/skin/font.h	Thu Feb 10 11:35:32 2011 +0000
@@ -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 @@
  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 );