From 9254ca61f1e459cbaf137ce4511332365da9c225 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 7 Jun 2009 16:06:03 +0000 Subject: fixed utf8 support --- src/game/client/components/menus.cpp | 17 +++++++++++++++++ src/game/client/gameclient.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) (limited to 'src/game') diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 53b57e2c..050c7056 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1003,6 +1003,23 @@ extern "C" void font_debug_render(); void MENUS::on_render() { + /* + // text rendering test stuff + render_background(); + + TEXT_CURSOR cursor; + gfx_text_set_cursor(&cursor, 10, 10, 20, TEXTFLAG_RENDER); + gfx_text_ex(&cursor, "ようこそ - ガイド", -1); + + gfx_text_set_cursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER); + gfx_text_ex(&cursor, "ようこそ - ガイド", -1); + + //gfx_texture_set(-1); + gfx_quads_begin(); + gfx_quads_drawTL(60, 60, 5000, 5000); + gfx_quads_end(); + return;*/ + if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK) set_active(true); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index a90cdc49..70aee255 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -183,8 +183,39 @@ void GAMECLIENT::on_console_init() suppress_events = false; } +/* +unsigned char utf8lut[] = {} + +static int utf8_decode(unsigned char **ptr) +{ + unsigned char first = **ptr; + if(first&0x80 == 0) + { + *ptr += 1; + return first; + } + + if(first&(0x80|0x40|0x20) == (0x80|0x40)) + { + // two bytes + } + + if(first&(0x80|0x40|0x20|0x10) == (0x80|0x40|0x20)) + { + // three bytes + } +}*/ + +#include + void GAMECLIENT::on_init() { + /*const char *p = "Hello World åäö ようこそ - ガイド "; + for(; *p; ) + { + dbg_msg("", "%d", utf8_decode(&p)); + }*/ + // init all components for(int i = 0; i < all.num; i++) all.components[i]->on_init(); @@ -197,6 +228,7 @@ void GAMECLIENT::on_init() // load default font static FONT *default_font; + //default_font = gfx_font_load("data/fonts/sazanami-gothic.ttf"); default_font = gfx_font_load("data/fonts/vera.ttf"); gfx_text_set_default_font(default_font); -- cgit 1.4.1