[Tux4kids-commits] r982 - in tuxtype/trunk: doc/en src

David Bruce dbruce-guest at alioth.debian.org
Thu May 21 15:06:31 UTC 2009


Author: dbruce-guest
Date: 2009-05-21 15:06:30 +0000 (Thu, 21 May 2009)
New Revision: 982

Modified:
   tuxtype/trunk/doc/en/howtotheme.html
   tuxtype/trunk/src/Makefile.am
   tuxtype/trunk/src/alphabet.c
   tuxtype/trunk/src/laser.c
Log:
1. Added null pointer check to laser.c to obviate one of Debian patches
2. Updated howtotheme.html (somewhat) to correct description of keyboard.lst and font handling



Modified: tuxtype/trunk/doc/en/howtotheme.html
===================================================================
--- tuxtype/trunk/doc/en/howtotheme.html	2009-05-21 08:21:41 UTC (rev 981)
+++ tuxtype/trunk/doc/en/howtotheme.html	2009-05-21 15:06:30 UTC (rev 982)
@@ -41,15 +41,19 @@
 </td></tr></table></center>
 <br>
 <li>Fonts
-<p>Tux Typing currently uses three fonts (AndikaDesRevG.ttf, DoulosSILR.ttf, and Rachana_w01.ttf) to provide glyphs for the included themes. The default font is Andika, which has glyphs for English and other Western European languages. Doulos has wider coverage, and is included to support the Cyrillic characters needed for the Russian theme. Rachana provides glyphs for the Malayalam theme. If your theme works with the default Andika font, you do not need to specify anything.  If one of the other fonts is needed, your theme directory needs to have a file "settings.txt" containing a line indicating your font selection, e.g.:
+<p>Tux Typing now uses SDL_Pango whenever possible (meaning Linux/Unix) to provide automated font selection and complex rendering for non-Western languages.  At this writing, we are not able to use SDL_Pango in Windows, BeOS, and (for the most part) Mac OS-X.  So if your desired language displays correctly in other apps on your Linux machine, your system already has a usable font and Tux Typing should be able to use it automagically. Hooray!</p>
+<p>For users without SDL_Pango, the task is more difficult. The font needs to be precisely specified by your theme. Tux Typing bundles in eleven True Type fonts to support the included languages.  AndikaDesRevG.ttf is the default, which basically includes the characters for English and Western European languages. If your theme works with Andika font, you do not need to specify anything.  There are ten other fonts bundled in, which add support for Cyrillic, Greek, and several of the Indic languages.  However, Chinese/Japanese/Korean are not covered. If you need to use one of the other bundled fonts (meaning you don't have SDL_Pango), your theme directory needs to have a file "settings.txt" containing a line indicating your font selection, e.g.:
 <br>
+<br>
 theme_font_name=Rachana_w01.ttf
 <br>
-
+<br>
 Currently, the font name must exactly match one of the supported fonts, or you will wind up with the default.  Note - all non-ASCII text needs to be encoded as UTF-8.  This is not an issue for file names, but it is an issue when adding themes that require Unicode support.
 
-<p>If you want to customize Tux Typing with another font, you can copy the *.ttf font file into data/fonts/ (alongside Andika, Doulos, and Rachana) and put the exact font file name into your theme's settings.txt file, and Tux Typing will use it.
+<p>If your language requires a true type font that is not bundled with Tux Typing, you need to copy the *.ttf font file into data/fonts/ (alongside Andika, Doulos, et. al.) and put the exact font file name into your theme's settings.txt file, and Tux Typing will use it.</p>
 
+<p>Again - the whole font selection issue is handled automatically by SDL_Pango, which is for all practical purposes essential for non-Western languages.  Even if you specify the font correctly, you will not get correct rendering of multicharacter strings in many languages without SDL_Pango.  Note, however, that the Comet Zap and Fish Cascade games do not support right-to-left rendering irrespective of what libraries are used.</p>
+
 <center><table bgcolor="#ccccff" width="75%" border=1 cellpadding=4><tr><td> 
 
 
@@ -90,14 +94,20 @@
 </td></tr></table></center>
 <p>
 <li>Setup the keyboard
-<p>Now you need to setup what characters (like ABCDEFGHIJKLMNOPQRSTUVWXYZ), you are going to have the player hit within the game.  There are several things you need to specify.  First let me explain with an example.  In the English version, we don't mind if the user hit "A" or "a", we want it to mean the same thing "A" (we choose uppercase (capital) letters since they are easier to read).  We also need to specify that the player would normally use the "0" finger to hit the key (see image)
+<p>Now you need to setup what characters (like ABCDEFGHIJKLMNOPQRSTUVWXYZ), you are going to have the player hit within the game.  There are several things you need to specify.  First let me explain with an example.  In the English version, the arcade-type games (Fish Cascade and Comet Zap) are case-insensitive.  That is, we don't mind if the user hit "A" or "a", we want it to mean the same thing "A" (we choose uppercase (capital) letters since they are easier to read). However, the Phrase Typing activity is case-sensitive, so both should be included. We also need to specify that the player would normally use the "0" finger to hit the key (see image).
 <p>
-<center><img src="numhand.jpg" alt="0 1 2 3 4 5 6 7 8 9"></center>
-<p>So you need to create a <b>keyboard.lst</b> file.  This file will contain all the characters that you wish to be typable.  The format for the file is:
+<center><img src="numhand.jpg" alt="0 1 2 3 4 5 6 7 8 9"></center> 
+
+<p>So you need to create a <b>keyboard.lst</b> file.  This file will contain all the characters that you wish to be typable.  As of Tuxtype-1.7.0, there is some flexibility in the format of each line of the file.  For Western languages, the preferred format for each line has three characters - finger, then '|' separator, then the character itself, e.g:
 <center>0|A</center>
 <p>
-First you list the finger(s) that the player should use to press this letter, then a seperator |, then the character that the user can press. Each character is on its own line (this is changed from earlier versions of Tux Typing).  Thus, one line should be "0|A" and another line "0|a".  Tux Typing generates the list of allowed characters from this file.  This is not the same as your theme's alphabet, which should consist only of the characters that correspond to "letters".
+First you list the finger(s) that the player should use to press this letter, then a seperator |, then the character that the user can press. Each character is on its own line (this is changed from earlier versions of Tux Typing).  Thus, one line should be "0|A" and another line "0|a".</p>
+<p>If somehow you do not know the finger for a character, you can just list the character by itself on the line.  Tux Typing will simply skip the fingering hints when this character is used.</p>
+
+<p>Tux Typing generates the list of allowed characters from this file. This is not the same as your theme's alphabet, which should consist only of the characters that correspond to "letters".
 <p>
+
+<p>For non-Western languages (e.g. all the Indic languages), there is support for also including the corresponding Latin character after the native language character. Thus, each line will have four characters: finger, '|', native character, Latin character.</p>
 <center><table bgcolor="#ccccff" width="75%" border=1 cellpadding=4><tr><td> 
 <pre>    cd data/themes/french
 
@@ -118,9 +128,11 @@
     3|F
     3|f
 </pre>
-and so on for each letter including non A-Z characters if needed! Tux Typing will use this list to determine which characters to pre-render (as well as for fingering hints), so be sure to include *all* characters needed for your theme, as omitted characters may not be able to be displayed. (I am trying to find a cross-platform way to query the OS as to what Unicode values can be typed by the user's current keyboard setup - if anyone has any ideas, please post to <a href="mailto:tuxmath-devel at lists.sourceforge.net">the dev list</a>).
+and so on for each letter including non A-Z characters if needed! Tux Typing will use this list to determine which characters to pre-render (as well as for fingering hints), so be sure to include *all* characters needed for your theme, as omitted characters may not be able to be displayed. 
 
 </td></tr></table></center>
+<p>Note - We realize that the keyboard.lst files are tedious and error-prone.  In fact, they are a real pain, both from the themer's and the programmer's perspective. I am trying to find a cross-platform way to query the OS as to what Unicode values can be typed by the user's current keyboard setup - if anyone has any ideas, please post to <a href="mailto:tuxmath-devel at lists.sourceforge.net">the dev list</a>.</p>
+
 <p>
 
 <li>Word Lists

Modified: tuxtype/trunk/src/Makefile.am
===================================================================
--- tuxtype/trunk/src/Makefile.am	2009-05-21 08:21:41 UTC (rev 981)
+++ tuxtype/trunk/src/Makefile.am	2009-05-21 15:06:30 UTC (rev 982)
@@ -10,6 +10,7 @@
 
 AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" \
 	-DLOCALSTATEDIR=\"$(pkglocalstatedir)\" \
+	-DSYSCONFDIRDIR=\"$(pkgsysconfdir)\" \
 	-I../intl -I$(top_srcdir)/intl
 
 if BUILD_MINGW32

Modified: tuxtype/trunk/src/alphabet.c
===================================================================
--- tuxtype/trunk/src/alphabet.c	2009-05-21 08:21:41 UTC (rev 981)
+++ tuxtype/trunk/src/alphabet.c	2009-05-21 15:06:30 UTC (rev 982)
@@ -153,8 +153,8 @@
       /* wide_str[1] =='|'                                  */
       /* wide_str[2] == Unicode value of character          */
 
-      /* FIXME - this might be a good place to use a    */
-      /* hash table to avoid n^2 performance problems.  */
+      /* NOTE the following code is really confusing!       */
+
       /* Some sanity checks:  */
       if ((wcslen(wide_str) >=3)
        && (wcstol(&wide_str[0], NULL, 0) >=0)   /* These lines just make sure the */
@@ -173,11 +173,11 @@
         keyboard_list[k].unicode_value = wide_str[2];
         keyboard_list[k].finger = wcstol(&wide_str[0], NULL, 0);
 
-        if (wcslen(wide_str) <5)
+        if (wcslen(wide_str) < 5)
         {
           if(!settings.use_english)
           {
-            map_keys(-1,&keyboard_list[k]);
+            map_keys(-1, &keyboard_list[k]);
             keyboard_list[k].latin_char=-1;
             keyboard_list[k].finger = wcstol(&wide_str[0], NULL, 0);
           }
@@ -1161,9 +1161,10 @@
 		keyboard_entry->shift=0;
 		keyboard_entry->finger=5;
 		break;
+	// I think this is for when we call "keymap(-1, ...)"
 	default:strcpy(keyboard_entry->keyname,"None");
-		keyboard_entry->shift=0;
-		keyboard_entry->finger=-1;
+		keyboard_entry->shift = 0;
+		keyboard_entry->finger = -1;
 		break;
   }	
   return 0;

Modified: tuxtype/trunk/src/laser.c
===================================================================
--- tuxtype/trunk/src/laser.c	2009-05-21 08:21:41 UTC (rev 981)
+++ tuxtype/trunk/src/laser.c	2009-05-21 15:06:30 UTC (rev 982)
@@ -809,17 +809,17 @@
 
 /* Add an comet to the game (if there's room): */
 
-static void laser_add_comet(int diff_level) {
+static void laser_add_comet(int diff_level)
+{
+  int target, location = 0;
+  static int last = -1;
+  int targeted[NUM_CITIES] = { 0 };
+  int add = (rand() % (diff_level + 2));
 
-	int target, location = 0;
-	static int last = -1;
-	int targeted[NUM_CITIES] = { 0 };
-	int add = (rand() % (diff_level + 2));
+  LOG ("Entering laser_add_comet()\n");
+  DEBUGCODE { fprintf(stderr, "Adding %d comets \n", add); }
 
-	LOG ("Entering laser_add_comet()\n");
-	DEBUGCODE { fprintf(stderr, "Adding %d comets \n", add); }
-
-	if (0 == NUM_CITIES % 2) /* Even number of cities */
+  if (0 == NUM_CITIES % 2) /* Even number of cities */
 	{
           LOG("NUM_CITIES is even\n");
 	  while ((add > 0) && (location != MAX_COMETS))
@@ -867,6 +867,12 @@
           int i = 0;
           comet_type* prev_comet = NULL;
 
+          if(!word || wcslen(word) == 0)
+          {
+            fprintf(stderr, "Error - GetWord() returned NULL or zero-length word\n");
+            return; 
+          }
+
           DEBUGCODE {fprintf(stderr, "word is: %S\tlength is: %d\n", word, (int)wcslen(word));}
           do
           { 
@@ -874,7 +880,7 @@
           } while (target == last);
           last = target;
 
-		for (i=0; i < wcslen(word); i++)
+		for (i = 0; i < wcslen(word); i++)
 		{
  			while ((comets[location].alive == 1) && (location < MAX_COMETS))
 				location++; 




More information about the Tux4kids-commits mailing list