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

ib subversion at mplayerhq.hu
Thu Feb 17 14:35:58 CET 2011


Author: ib
Date: Thu Feb 17 14:35:58 2011
New Revision: 32922

Log:
Enlarge uchar buffer, because GLib implements 31-bit UTF-8,
and define length of an UTF-8 encoding sequence allowed in
the font definition file as a constant.

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

Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c	Thu Feb 17 12:15:19 2011	(r32921)
+++ trunk/gui/skin/font.c	Thu Feb 17 14:35:58 2011	(r32922)
@@ -103,7 +103,7 @@ int fntRead( char * path,char * fname )
         {
          if ( !Fonts[id]->nonASCIIidx[i][0] )
           {
-           strncpy( Fonts[id]->nonASCIIidx[i], command, 4 );
+           strncpy( Fonts[id]->nonASCIIidx[i], command, UTF8LENGTH );
            break;
           }
         }
@@ -151,7 +151,7 @@ int fntFindID( char * name )
 // then move pointer to next/previous character
 int fntGetCharIndex( int id, unsigned char **str, gboolean utf8, int direction )
 {
- unsigned char *p, uchar[4] = {'\0'};
+ unsigned char *p, uchar[6] = "";   // glib implements 31-bit UTF-8
  int i, c = -1;
 
  if ( **str & 0x80 )
@@ -172,7 +172,7 @@ int fntGetCharIndex( int id, unsigned ch
 
    for ( i = 0; ( i < EXTRA_CHRS ) && Fonts[id]->nonASCIIidx[i][0]; i++ )
     {
-     if ( strncmp( Fonts[id]->nonASCIIidx[i], uchar, 4 ) == 0 ) return i + ASCII_CHRS;
+     if ( strncmp( Fonts[id]->nonASCIIidx[i], uchar, UTF8LENGTH ) == 0 ) return i + ASCII_CHRS;
      if ( !utf8 && ( Fonts[id]->nonASCIIidx[i][0] == (*uchar >> 6 | 0xc0) && Fonts[id]->nonASCIIidx[i][1] == (*uchar & 0x3f | 0x80) && Fonts[id]->nonASCIIidx[i][2] == 0 ) ) c = i + ASCII_CHRS;
     }
   }

Modified: trunk/gui/skin/font.h
==============================================================================
--- trunk/gui/skin/font.h	Thu Feb 17 12:15:19 2011	(r32921)
+++ trunk/gui/skin/font.h	Thu Feb 17 14:35:58 2011	(r32922)
@@ -25,6 +25,7 @@
 
 #define ASCII_CHRS 128   // number of ASCII characters
 #define EXTRA_CHRS 128   // (arbitrary) number of non-ASCII characters
+#define UTF8LENGTH 4     // length of an UTF-8 encoding according to RFC 3629
 
 #define MAX_FONT_NAME 128
 #define MAX_FONTS 25
@@ -42,7 +43,7 @@ typedef struct
 typedef struct
 {
  fntChar         Fnt[ASCII_CHRS + EXTRA_CHRS];
- unsigned char   nonASCIIidx[EXTRA_CHRS][4];
+ unsigned char   nonASCIIidx[EXTRA_CHRS][UTF8LENGTH];
  txSample        Bitmap;
  char            name[MAX_FONT_NAME];
 } bmpFont;


More information about the MPlayer-cvslog mailing list