make multiply/divide key (on OLPC XO keyboard) work

This commit is contained in:
Albert Cahalan 2007-03-29 05:06:45 +00:00
parent 7ab2175799
commit 19b0c3d33d
5 changed files with 22 additions and 4 deletions

View file

@ -118,6 +118,9 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
user_font_styles[num_font_styles]->score += charset_works(font, gettext("017")); // digits
user_font_styles[num_font_styles]->score += charset_works(font, gettext("O0")); // distinct circle-like characters
user_font_styles[num_font_styles]->score += charset_works(font, gettext("1Il|")); // distinct line-like characters
#ifdef OLPC_XO
user_font_styles[num_font_styles]->score += charset_works(font, "\xc3\x97\xc3\xb7"); // multiply and divide
#endif
num_font_styles++;
//printf("Accepted: %s, %s, %s, score(%d)\n", files[i].str, family, style, user_font_styles[num_font_styles]->score);
files[i].str = NULL; // so free() won't crash -- we stole the memory

View file

@ -168,6 +168,7 @@ TTF_Font *load_locale_font(TTF_Font * fallback, int size)
putenv((char *) "LANG=C");
putenv((char *) "OUTPUT_CHARSET=C");
setlocale(LC_ALL, "C");
ctype_utf8();
set_current_language();
}

View file

@ -274,6 +274,18 @@ void set_langstr(const char *s)
langstr = strdup(s);
}
// This is to ensure that iswprint() works beyond ASCII,
// even if the locale wouldn't normally support that.
void ctype_utf8(void)
{
#ifndef _WIN32
char *names[] = {"en_US.UTF8","en_US.UTF-8","UTF8","UTF-8",};
int i = sizeof(names)/sizeof(names[0]);
while(i-- && !iswprint((wchar_t)0xf7) && !setlocale(LC_CTYPE,names[i]))
;
#endif
}
/* Determine the current language/locale, and set the language string: */
void set_current_language(void)
@ -572,6 +584,7 @@ void setup_language(const char *const prg)
}
setlocale(LC_ALL, "");
ctype_utf8();
free(langstr);
}
@ -590,4 +603,5 @@ void do_locale_option(const char *const arg)
// of the environment. If it were local, the environment would
// get corrupted.
setlocale(LC_ALL, ""); /* use arg ? */
ctype_utf8();
}

View file

@ -122,6 +122,7 @@ void show_lang_usage(FILE * f, const char *const prg);
void show_locale_usage(FILE * f, const char *const prg);
void setup_language(const char *const prg);
void do_locale_option(const char *const arg);
void ctype_utf8(void);
#endif

View file

@ -1366,21 +1366,20 @@ static void eat_sdl_events(void)
int main(int argc, char *argv[])
{
CLOCK_TYPE time1;
CLOCK_TYPE time2;
SDL_Rect dest;
SDL_Rect src;
CLOCK_ASM(time1);
#ifdef FORKED_FONTS
run_font_scanner(screen);
#endif
/* Set up locale support */
setlocale(LC_ALL, "");
CLOCK_ASM(time1);
ctype_utf8();
/* Set up! */
setup(argc, argv);