[Tux4kids-commits] r183 - in tuxtype/trunk: . tuxtype tuxtype/data/fonts

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Thu May 24 21:29:35 UTC 2007


Author: dbruce-guest
Date: 2007-05-24 21:29:34 +0000 (Thu, 24 May 2007)
New Revision: 183

Added:
   tuxtype/trunk/tuxtype/data/fonts/AndikaDesRevG.ttf
Modified:
   tuxtype/trunk/ChangeLog
   tuxtype/trunk/tuxtype/alphabet.c
   tuxtype/trunk/tuxtype/data/fonts/Makefile.am
   tuxtype/trunk/tuxtype/data/fonts/Makefile.in
   tuxtype/trunk/tuxtype/funcs.h
   tuxtype/trunk/tuxtype/globals.h
   tuxtype/trunk/tuxtype/laser.c
   tuxtype/trunk/tuxtype/loaders.c
   tuxtype/trunk/tuxtype/playgame.c
   tuxtype/trunk/tuxtype/playgame.h
   tuxtype/trunk/tuxtype/titlescreen.c
Log:
UTF-8/Unicode work


Modified: tuxtype/trunk/ChangeLog
===================================================================
--- tuxtype/trunk/ChangeLog	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/ChangeLog	2007-05-24 21:29:34 UTC (rev 183)
@@ -1,3 +1,18 @@
+24 May 2007
+[ David Bruce]
+       - Additional work on UTF-8/Unicode issues - program now scans
+         word list to see what Unicode characters are needed instead
+         of automatically rendering everything from 0-255. It now
+         displays chars beyond this range (e.g. Russian/Cyrillic) as
+         long as the font contains the needed glyphs (which Andika 
+         does not, as of yet). Display "should" now work correctly
+         except for a cosmetic problem with vertical alignment, which
+         should be fixed soon. Files - alphabet.c, playgame.c, laser.c.
+       - Lowercase keystrokes for non-US characters converted to upper-
+         case, just like A-Z.  Not sure this addresses keyboard input
+         problems just yet.
+       - Changed font to Andika design review "G".
+
 v.1.5.9  07 May 2007
 
 [ David Bruce]

Modified: tuxtype/trunk/tuxtype/alphabet.c
===================================================================
--- tuxtype/trunk/tuxtype/alphabet.c	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/alphabet.c	2007-05-24 21:29:34 UTC (rev 183)
@@ -31,9 +31,15 @@
 /* Used for word list functions (see below): */
 static int WORD_qty;
 wchar_t WORDS[MAX_NUM_WORDS][MAX_WORD_SIZE + 1];
+wchar_t unicode_chars_used[MAX_UNICODES];  // List of distinct letters in list
+static int num_chars_used = 0;       // Number of different letters in word list
 
+/* These are the arrays for the red and white letters: */
+uni_glyph char_glyphs[MAX_UNICODES];
+
 /* Local function prototypes: */
 void WORDS_scan_chars(void);
+int add_unicode(wchar_t uc);
 
 /* --- setup the alphabet --- */
 void set_letters(unsigned char *t) {
@@ -176,6 +182,7 @@
   return out;
 }
 
+
 /* This version takes a single wide character and renders it with the */
 /* Unicode glyph versions of the SDL_ttf functions:                         */
 SDL_Surface* black_outline_wchar(wchar_t t, TTF_Font *font, SDL_Color *c) {
@@ -236,6 +243,8 @@
   return out;
 }
 
+
+
 void show_letters( void ) {
 	int i, l=0;
 	SDL_Surface *abit;
@@ -331,6 +340,9 @@
 	/* Make sure list is terminated with null character */
 	WORDS[WORD_qty][0] = '\0';
 
+	/* Make list of all unicode characters used in word list: */
+	WORDS_scan_chars();
+
 	DOUT(WORD_qty);
 	LOG("Leaving WORDS_use_alphabet()\n");
 }
@@ -392,7 +404,6 @@
  * it ignores any words too long or that has bad
  * character (such as #)
  */
-/* FIXME changing to wchar_t to accommodate i18n */
 
 void WORDS_use(char *wordFn)
 {
@@ -463,52 +474,202 @@
     WORD_qty++;
   }
         
-	/* Make sure list is terminated with null character */
-	WORDS[WORD_qty][0] = '\0';
+  /* Make sure list is terminated with null character */
+  WORDS[WORD_qty][0] = '\0';
 
-	DOUT(WORD_qty);
+  DOUT(WORD_qty);
 
-	if (WORD_qty == 0)
-		WORDS_use_alphabet( );
+  if (WORD_qty == 0)
+    WORDS_use_alphabet( );
 
-	fclose(wordFile);
+  fclose(wordFile);
 
-	LOG("Leaving WORDS_use()\n");
+  /* Make list of all unicode characters used in word list: */
+  WORDS_scan_chars();
+
+  LOG("Leaving WORDS_use()\n");
 }
 
 
-/* Returns number of UTF-8 characters rather than just size in */
-/* bytes like strlen(). mbstowcs(NULL, s, 0) should do this    */
-/* but for some reason I haven't gotten it to work.            */
-/* Returns -1 if any invalid characters encountered.           */
-size_t UTF8_strlen(const char* s)
+
+
+
+
+
+/* Now that the words are stored internally as wchars, we use the */
+/* Unicode glyph version of black_outline():                      */
+int RenderLetters(TTF_Font* letter_font)
 {
-  size_t byte_length = 0;
-  size_t UTF8_length = 0;
-  int i = 0;
-  int char_width = 0;
+  wchar_t t;
+  int i;
+  int maxy;
 
-  byte_length = strlen(s);
+  if (!letter_font)
+  {
+    fprintf(stderr, "RenderLetters() - invalid TTF_Font* argument!\n");
+    return 0;
+  }
 
-  DEBUGCODE{ fprintf(stderr, "String is: %s\nstrlen() = %d\n",
-                              s, byte_length); }
-  while (i < byte_length)
+  /* The following will supercede the old code: */
+  i = num_chars_used = 0;
+  while (unicode_chars_used[i] != '\0')
   {
-    /* look at the length of each UTF-8 char and jump ahead accordingly: */
-    char_width = mblen(&s[i], byte_length - i);
-    if (char_width == -1)
-      return -1;
-    i += mblen(&s[i], byte_length - i);
-    UTF8_length++;
+    t = unicode_chars_used[i];
+
+    if(TTF_GlyphMetrics(font, t, NULL , NULL, NULL,
+                        &maxy, NULL) == -1)
+    {
+      fprintf(stderr, "Could not get glyph metrics for %lc", t);
+      i++;
+      continue;
+    }
+
+    DEBUGCODE
+    {
+      fprintf(stderr, "Creating SDL_Surface for list element %d, char = %lc\n", i, t);
+    }
+
+    char_glyphs[i].unicode_value = t;
+    char_glyphs[i].white_glyph = black_outline_wchar(t, font, &white);
+    char_glyphs[i].red_glyph = black_outline_wchar(t, font, &red);
+    char_glyphs[i].max_y = maxy;
+
+    i++;
+    num_chars_used++;
   }
+  /* Remember how many letters we added: */
+  return num_chars_used;
+}
 
-  DEBUGCODE{ fprintf(stderr, "UTF8_strlen() = %d\n", UTF8_length); }
 
-  return UTF8_length;
+void FreeLetters(void)
+{
+  int i;
+
+  for (i = 0; i < num_chars_used; i++)
+  {
+    SDL_FreeSurface(char_glyphs[i].white_glyph);
+    SDL_FreeSurface(char_glyphs[i].red_glyph);
+  } 
 }
 
 
+SDL_Surface* GetWhiteGlyph(wchar_t t)
+{
+  int i;
 
+  for (i = 0;
+       (char_glyphs[i].unicode_value != t) && (i <= num_chars_used);
+       i++)
+  {}
+
+  /* Now return appropriate pointer: */
+  if (i > num_chars_used)
+  {
+    /* Didn't find character: */
+    fprintf(stderr, "Could not find glyph for unicode character %lc\n", t);
+    return NULL;
+  }
+  
+  /* Return corresponding surface for blitting: */
+  return char_glyphs[i].white_glyph;
+}
+
+
+
+SDL_Surface* GetRedGlyph(wchar_t t)
+{
+  int i;
+
+  for (i = 0;
+       char_glyphs[i].unicode_value != t && i <= num_chars_used;
+       i++)
+  {}
+
+  /* Now return appropriate pointer: */
+  if (i > num_chars_used)
+  {
+    /* Didn't find character: */
+    fprintf(stderr, "Could not find glyph for unicode character %lc\n", t);
+    return NULL;
+  }
+  
+  /* Return corresponding surface for blitting: */
+  return char_glyphs[i].red_glyph;
+}
+
+
+
+/****************************************************/
+/*                                                  */
+/*       Local ("private") functions:               */
+/*                                                  */
+/****************************************************/
+
+
+/* Creates a list of distinct Unicode characters in */
+/* the WORDS[][] list (so the program knows what    */
+/* needs to be rendered for the games)              */
 void WORDS_scan_chars(void)
 {
+  int i, j;
+  i = j = 0;
+  unicode_chars_used[0] = '\0';
+
+  while (WORDS[i][0] != '\0' && i < MAX_NUM_WORDS) 
+  {
+    j = 0;
+
+    while (WORDS[i][j]!= '\0' && j < MAX_WORD_SIZE)
+    {
+      add_unicode(WORDS[i][j]);
+      j++;
+    }
+
+    i++;
+  }
+
+  DEBUGCODE
+  {
+    fprintf(stderr, "unicode_chars_used = %S\n", unicode_chars_used);
+  }
 }
+
+
+/* Checks to see if the argument is already in the list and adds    */
+/* it if necessary.  Returns 1 if char added, 0 if already in list, */
+/* -1 if list already up to maximum size:                           */
+
+int add_unicode(wchar_t uc)
+{
+  int i = 0;
+  while ((unicode_chars_used[i] != uc)
+      && (unicode_chars_used[i] != '\0')
+      && (i < MAX_UNICODES - 1))          //Because 1 need for null terminator
+  {
+    i++;
+  }
+
+  /* unicode already in list: */
+  if (unicode_chars_used[i] == uc)
+  {
+    DEBUGCODE{ fprintf(stderr,
+                       "Unicode value: %d\tcharacter %lc already in list\n",
+                        uc, uc);}
+    return 0;
+  }
+
+  if (unicode_chars_used[i] == '\0')
+  {
+    DEBUGCODE{ fprintf(stderr, "Adding unicode value: %d\tcharacter %lc\n", uc, uc);}
+    unicode_chars_used[i] = uc;
+    unicode_chars_used[i + 1] = '\0';
+    return 1;
+  }
+
+  if (i == MAX_UNICODES - 1)            //Because 1 need for null terminator
+  {
+    LOG ("Unable to add unicode - list at max capacity");
+    return -1;
+  }
+}

Added: tuxtype/trunk/tuxtype/data/fonts/AndikaDesRevG.ttf
===================================================================
(Binary files differ)


Property changes on: tuxtype/trunk/tuxtype/data/fonts/AndikaDesRevG.ttf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: tuxtype/trunk/tuxtype/data/fonts/Makefile.am
===================================================================
--- tuxtype/trunk/tuxtype/data/fonts/Makefile.am	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/data/fonts/Makefile.am	2007-05-24 21:29:34 UTC (rev 183)
@@ -1,8 +1,8 @@
-EXTRA_DIST = AndikaDesRevA.ttf
+EXTRA_DIST = AndikaDesRevG.ttf
 
 install-data-local:
 	$(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
-	$(INSTALL_DATA) $(srcdir)/AndikaDesRevA.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
+	$(INSTALL_DATA) $(srcdir)/AndikaDesRevG.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
 
 uninstall-local:
-	rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/AndikaDesRevA.ttf
+	rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/AndikaDesRevG.ttf

Modified: tuxtype/trunk/tuxtype/data/fonts/Makefile.in
===================================================================
--- tuxtype/trunk/tuxtype/data/fonts/Makefile.in	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/data/fonts/Makefile.in	2007-05-24 21:29:34 UTC (rev 183)
@@ -149,7 +149,7 @@
 target_vendor = @target_vendor@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = AndikaDesRevA.ttf
+EXTRA_DIST = AndikaDesRevG.ttf
 all: all-am
 
 .SUFFIXES:
@@ -313,10 +313,10 @@
 
 install-data-local:
 	$(mkinstalldirs) $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
-	$(INSTALL_DATA) $(srcdir)/AndikaDesRevA.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
+	$(INSTALL_DATA) $(srcdir)/AndikaDesRevG.ttf $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts
 
 uninstall-local:
-	rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/AndikaDesRevA.ttf
+	rm -f $(DESTDIR)$(prefix)/share/$(PACKAGE)/data/fonts/AndikaDesRevG.ttf
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:

Modified: tuxtype/trunk/tuxtype/funcs.h
===================================================================
--- tuxtype/trunk/tuxtype/funcs.h	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/funcs.h	2007-05-24 21:29:34 UTC (rev 183)
@@ -84,8 +84,10 @@
 extern void show_letters( void );
 extern SDL_Surface* black_outline( unsigned char *t, TTF_Font* font, SDL_Color* c );
 extern SDL_Surface* black_outline_wchar(wchar_t t, TTF_Font* font, SDL_Color* c);
-extern size_t UTF8_strlen(const char* s);
-
+extern SDL_Surface* GetWhiteGlyph(wchar_t t);
+extern SDL_Surface* GetRedGlyph(wchar_t t);
+extern int RenderLetters(TTF_Font* letter_font);
+extern void FreeLetters(void);
 /* WORD FUNCTIONS (also in alphabet.c) */
 extern void WORDS_init( void );
 extern void WORDS_use_alphabet( void );

Modified: tuxtype/trunk/tuxtype/globals.h
===================================================================
--- tuxtype/trunk/tuxtype/globals.h	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/globals.h	2007-05-24 21:29:34 UTC (rev 183)
@@ -110,14 +110,17 @@
 #define amask 0xff000000
 #endif
 
-#define menu_font	"AndikaDesRevA.ttf" /* GenAI102.ttf or "DejaVuSans-Bold.ttf"  or "FreeSansBold.ttf" */ 	/* was menu.ttf */
+#define menu_font	"AndikaDesRevG.ttf"    /*"AndikaDesRevA.ttf"  GenAI102.ttf or "DejaVuSans-Bold.ttf"  or "FreeSansBold.ttf" */ 	/* was menu.ttf */
 #define menu_font_size	20
 
-#define ttf_font	"AndikaDesRevA.ttf" /* GenAI102.ttf or "DejaVuSans-Bold.ttf" or "FreeSansBold.ttf" */  	/* was letters.ttf */
+#define ttf_font	"AndikaDesRevG.ttf" /*AndikaDesRevA.ttf"  GenAI102.ttf or "DejaVuSans-Bold.ttf" or "FreeSansBold.ttf" */  	/* was letters.ttf */
 #define ttf_font_size	20
 
+/* Limits on word list size, word length, and on the number of distinct characters */
+/* that can be present within a word list: */
 #define MAX_NUM_WORDS   500
 #define MAX_WORD_SIZE   8
+#define MAX_UNICODES 1024
 
 #define WAIT_MS				2500
 #define	FRAMES_PER_SEC	                50
@@ -168,6 +171,7 @@
 extern unsigned char KEYMAP[256];
 extern unsigned char FINGER[256][10];
 extern int ALPHABET_SIZE;
+extern wchar_t unicode_chars_used[MAX_UNICODES];
 
 //global vars
 extern int speed_up;
@@ -208,3 +212,14 @@
 
     NUM_WIPES
 };
+
+
+/* An individual item in the list of cached unicode characters that are rendered at   */
+/* the start of each game. The 'max_y' is stored so that the characters can be lined  */
+/* up properly even if their heights are different.                                   */
+typedef struct uni_glyph {
+  wchar_t unicode_value;
+  SDL_Surface* white_glyph;
+  SDL_Surface* red_glyph;
+  int max_y;
+} uni_glyph;

Modified: tuxtype/trunk/tuxtype/laser.c
===================================================================
--- tuxtype/trunk/tuxtype/laser.c	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/laser.c	2007-05-24 21:29:34 UTC (rev 183)
@@ -31,6 +31,8 @@
 void laser_unload_data(void) {
 	int i;
 
+	FreeLetters();
+
 	for (i = 0; i < NUM_IMAGES; i++)
 		SDL_FreeSurface(images[i]);
 
@@ -45,16 +47,19 @@
 
 	pause_unload_media();
 
-	for ( i=1; i<255; i++ )
-		SDL_FreeSurface( letters[i] );
 
 	TTF_CloseFont(font);
 }
 
 /* --- Load all media --- */
-void laser_load_data(void) {
+void laser_load_data(void)
+{
 	int i;
+
+	/* Create the SDL_Surfaces for all of the characters */
+        /* used in the word list: */
 	font = LoadFont( ttf_font, 32);
+	RenderLetters(font);
 
 	/* Load images: */
 	for (i = 0; i < NUM_IMAGES; i++) 
@@ -70,25 +75,6 @@
 	}
 
 	pause_load_media();
-
-        /* Now that the words are stored internally as wchars, we use the */
-        /* Unicode glyph version of black_outline():                      */
-        {
-          wchar_t t;
-          int i;
-
-          for (i = 1; i < 255; i++)
-          {
-            t = (wchar_t)i;
-
-            DEBUGCODE
-            {
-              fprintf(stderr, "Creating SDL_Surface for int = %d, char = %lc\n", i, t);
-            }
-
-            letters[i] = black_outline_wchar(t, font, &white);
-          }
-        }
 }
 
 
@@ -104,7 +90,7 @@
 /* Local (to game.c) 'globals': */
 
 int wave, speed, score, pre_wave_score, num_attackers, distanceMoved;
-unsigned char ans[NUM_ANS];
+wchar_t ans[NUM_ANS];
 int ans_num;
 
 comet_type comets[MAX_COMETS];
@@ -119,7 +105,7 @@
 void laser_draw_line(int x1, int y1, int x2, int y2, int r, int g, int b);
 void laser_putpixel(SDL_Surface * surface, int x, int y, Uint32 pixel);
 void laser_draw_console_image(int i);
-void laser_draw_let(unsigned char c, int x, int y);
+void laser_draw_let(wchar_t c, int x, int y);
 void laser_add_score(int inc);
 
 /* --- MAIN GAME FUNCTION!!! --- */
@@ -138,7 +124,8 @@
 	Uint32    last_time, now_time;
 	SDLKey    key;
 	SDL_Rect  src, dest;
-	unsigned char      str[64];
+	/* str[] is a buffer to draw the scores, waves, etc. (don't need wchar_t) */
+	unsigned char str[64]; 
 
 	LOG( "starting Comet Zap game\n" );
 	DOUT( DIF_LEVEL );
@@ -855,12 +842,12 @@
 
 /* Draw numbers/symbols over the attacker: */
 
-void laser_draw_let(unsigned char c, int x, int y)
+void laser_draw_let(wchar_t c, int x, int y)
 {
 	SDL_Rect dst;
 	dst.y = y-35;
-	dst.x = x - (letters[(int)c]->w/2);
-	SDL_BlitSurface(letters[(int)c], NULL, screen, &dst); 
+	dst.x = x - (GetWhiteGlyph(c)->w/2);
+	SDL_BlitSurface(GetWhiteGlyph(c), NULL, screen, &dst); 
 }
 
 

Modified: tuxtype/trunk/tuxtype/loaders.c
===================================================================
--- tuxtype/trunk/tuxtype/loaders.c	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/loaders.c	2007-05-24 21:29:34 UTC (rev 183)
@@ -239,10 +239,13 @@
 SDL_Surface *LoadImage( char *datafile, int mode )
 {
 	int i;
+	int oldDebug;  //so we can turn off debug output for this func only
 	SDL_Surface  *tmp_pic = NULL, *final_pic = NULL;
 	char         fn[FNLEN];
 
+	oldDebug = debugOn;  // suppress output for now
 	debugOn = 0;
+
 	DEBUGCODE { fprintf(stderr, "LoadImage: loading %s\n", datafile ); }
 
 	/* truth table for start of loop, since we only use theme on those conditions!
@@ -305,7 +308,9 @@
 	}
 
 	LOG( "LOADIMAGE: Done\n" );
-	debugOn = 1;
+
+	debugOn = oldDebug;
+
 	return (final_pic);
 }
 

Modified: tuxtype/trunk/tuxtype/playgame.c
===================================================================
--- tuxtype/trunk/tuxtype/playgame.c	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/playgame.c	2007-05-24 21:29:34 UTC (rev 183)
@@ -39,8 +39,6 @@
 SDL_Surface *congrats[CONGRATS_FRAMES];
 SDL_Surface *ohno[OH_NO_FRAMES];
 
-SDL_Surface *letter[256];
-SDL_Surface *red_letter[256];
 sprite *fishy;
 sprite *splat;
 
@@ -58,6 +56,9 @@
 
 
 
+
+
+
 /* Local function prototypes: */
 void UpdateTux(wchar_t letter_pressed, int fishies, int frame);
 
@@ -86,36 +87,14 @@
 }
 
 
-/* Now that the words are stored internally as wchars, we use the */
-/* Unicode glyph version of black_outline():                      */
-void create_letters( void )
-{
-  wchar_t t;
-  int i;
 
-  for (i = 1; i < 255; i++)
-  {
-    t = (wchar_t)i;
 
-    DEBUGCODE
-    {
-      fprintf(stderr, "Creating SDL_Surface for int = %d, char = %lc\n", i, t);
-    }
 
-    letter[i] = black_outline_wchar(t, font, &white);
-    red_letter[i] = black_outline_wchar(t, font, &red);;
-  }
-}
 
 
-void remove_letters( void ) {
-	int i;
-	for (i = 1; i < 255; i++) {
-			SDL_FreeSurface(letter[i]);
-			SDL_FreeSurface(red_letter[i]);
-		} 
-}
 
+
+
 /***************************************
 	WaitFrame: wait for the next frame
 ***************************************/
@@ -505,6 +484,8 @@
 void FreeGame( void ) {
 	int i;
 
+	FreeLetters();
+
 	TTF_CloseFont(font);
 
 	LOG( "FreeGame():\n-Freeing Tux Animations\n" );
@@ -532,11 +513,6 @@
 	for (i = 0; i < NUM_NUMS; i++)
 		SDL_FreeSurface(number[i]);
 
-	for (i = 0; i < 256; i++) {
-		if (letter[i]) SDL_FreeSurface(letter[i]);
-		if (red_letter[i]) SDL_FreeSurface(red_letter[i]);
-	}
-
 	for (i = 0; i < CONGRATS_FRAMES; i++)
 		SDL_FreeSurface(congrats[i]);
 
@@ -552,6 +528,7 @@
 
 	pause_unload_media();
 
+
 	LOG( "FreeGame(): END\n" );
 }
 
@@ -762,6 +739,7 @@
         int letter_x = 0;
         int letter_y = 0;
 	int current_letter;
+        SDL_Surface* letter_surface;
 
 	/* Make sure needed pointers are valid - if not, return: */
         if (!fishy || !fishy->frame[0])
@@ -813,14 +791,6 @@
 		{
 		  current_letter = (int)fish_object[which].word[j];
 
-		  /* For now, we don't support wchars outside of 0-255: */
-		  if (current_letter < 0 || current_letter > 255)
-		  {
-		    fprintf(stderr, "Character encountered with value '%d' - not supported\n",
-                                     current_letter);
-		    continue;
-		  }
- 
 		  letter_x = fish_object[which].x + (j * fishy->frame[0]->w) + x_offset;
 		  letter_y = fish_object[which].y + y_offset;
  
@@ -832,11 +802,12 @@
 // 		  }
 		  //if (fish_object[which].word[j] != 32) /* Don't understand this */
 		  if (j < red_letters)
-		    DrawObject(red_letter[current_letter],
-                               letter_x, letter_y);
-		  else
-		    DrawObject(letter[current_letter],
-                               letter_x, letter_y);
+                    letter_surface = GetRedGlyph(current_letter);
+                  else
+                    letter_surface = GetWhiteGlyph(current_letter);
+
+		  DrawObject(letter_surface, letter_x, letter_y);
+
 		}
 	}
 /*        LOG ("Leaving DrawFish()\n");*/
@@ -1120,9 +1091,9 @@
 	LoadTuxAnims(); 
 	LoadFishies();
 	LoadOthers();
-        LOG( " before create_letters()\n" );
-	create_letters();
-        LOG( " after create_letters()\n" );
+        LOG( " before RenderLetters()\n" );
+	RenderLetters(font);
+        LOG( " after RenderLetters()\n" );
 
 	LOG( " starting game \n ");
 	while (still_playing) {
@@ -1243,11 +1214,8 @@
 					DEBUGCODE
 					{
 					  fprintf(stderr,
-					    "\nkey_unicode = %d\tKEYMAP[key_unicode] = %c\t",
-					     key_unicode, KEYMAP[key_unicode]);
-					  if (0 <= key_unicode && key_unicode <= 255)
-                                            fprintf(stderr, "(char)key_unicode = %c\n",
-                                                    key_unicode);
+					    "\nkey_unicode = %d\twchar_t = %lc\tKEYMAP[key_unicode] = %c\n",
+					     key_unicode, key_unicode, KEYMAP[key_unicode]);
 					}
 
                                         if (key_unicode >= 97 && key_unicode <= 122)
@@ -1259,11 +1227,8 @@
 					DEBUGCODE
 					{
 					  fprintf(stderr,
-					    "key_unicode = %d\tKEYMAP[key_unicode] = %c\t",
-					     key_unicode, KEYMAP[key_unicode]);
-					  if (0 <= key_unicode && key_unicode <= 255)
-                                            fprintf(stderr, "(char)key_unicode = %c\n",
-                                                    key_unicode);
+					    "key_unicode = %d\twchar_t = %lc\tKEYMAP[key_unicode] = %c\n\n",
+					     key_unicode, key_unicode, KEYMAP[key_unicode]);
 					}
 
 					/* Now update with case-folded value: */

Modified: tuxtype/trunk/tuxtype/playgame.h
===================================================================
--- tuxtype/trunk/tuxtype/playgame.h	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/playgame.h	2007-05-24 21:29:34 UTC (rev 183)
@@ -135,4 +135,7 @@
 
 struct splatter null_splat;
 
+
+
+
 #endif

Modified: tuxtype/trunk/tuxtype/titlescreen.c
===================================================================
--- tuxtype/trunk/tuxtype/titlescreen.c	2007-05-18 22:07:33 UTC (rev 182)
+++ tuxtype/trunk/tuxtype/titlescreen.c	2007-05-24 21:29:34 UTC (rev 183)
@@ -83,9 +83,12 @@
 		max = 0;
 		for (i = 1; i <= TITLE_MENU_ITEMS; i++)
 		{
-
+			DEBUGCODE
+			{
+			  fprintf(stderr, "i = '%d'\tj = '%d'\ttext = '%s'\n",
+                                  i, j,  _((unsigned char*)menu_text[i][j]));
+			}
 			/* --- create text surfaces --- */
-
 			reg_text[i][j] = black_outline( _((unsigned char*)menu_text[i][j]), font, &white);
 			sel_text[i][j] = black_outline( _((unsigned char*)menu_text[i][j]), font, &yellow);
 
@@ -93,7 +96,6 @@
 				max = sel_text[i][j]->w;
 
 			/* --- load animated icon for menu item --- */
-
 			sprintf(fn, "menu/%s", menu_icon[i][j]);
 			menu_gfx[i][j] = LoadSprite(fn, IMG_ALPHA);
 		}
@@ -539,7 +541,7 @@
 
 
             /* Toggle screen mode: */
-            case SDLK_F10: /* NOTE Cool! - should add this to TuxMath*/
+            case SDLK_F10:
             {
               switch_screen_mode();
               redraw = 1;




More information about the Tux4kids-commits mailing list