Fixed UTF8 text rendering in Guichan

This commit is contained in:
pelya
2014-11-06 21:26:10 +02:00
parent 088f43c8c8
commit d65b899ec6
6 changed files with 333 additions and 330 deletions

View File

@@ -23,7 +23,7 @@ InhibitSuspend=n
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
# these files are put inside .apk package by build system
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
AppDataDownloadUrl="data file|files.zip"
AppDataDownloadUrl="!!data file|files.zip"
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
@@ -161,7 +161,7 @@ StartupMenuButtonTimeout=3000
# Menu items to hide from startup menu, available menu items:
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
HiddenMenuOptions=''
HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig'
# Menu items to show at startup - this is Java code snippet, leave empty for default
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
@@ -171,7 +171,7 @@ FirstStartMenuOptions=''
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
MultiABI=all
MultiABI='armeabi-v7a'
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
AppMinimumRAM=256
@@ -191,7 +191,7 @@ DeleteFilesOnUpgrade="%"
# Optional shared libraries to compile - removing some of them will save space
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
CompiledLibraries="sdl_image guichan"
CompiledLibraries="sdl_image sdl_ttf guichan"
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
CustomBuildScript=n

View File

@@ -1,6 +1,6 @@
<container name="top" width="640" height="480">
<label name="logo_text" caption="Simple example of using XmlGui" />
<button x="5" y="20" name="exit" caption="Please click to exit" />
<label name="logo_text" caption="Simple example of using XmlGui АбВгЁ" />
<button x="5" y="20" name="exit" caption="Please click to exit АбВгЁ" />
<icon name="logo" x="250" y="160" image="darkbitslogo_by_haiko.bmp" />
<dropdown name="dp" x="100" y="100">
<li>Item 1</li>

View File

@@ -5,6 +5,7 @@
#include <guichan.hpp>
#include <guichan/sdl.hpp>
#include <guichan/contrib/sdl/sdltruetypefont.hpp>
namespace sdl
{
@@ -34,6 +35,7 @@ namespace sdl
SDL_EnableUNICODE(1);
// We also want to enable key repeat.
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
TTF_Init();
// Now it's time to initialise the Guichan SDL back end.

View File

@@ -5,7 +5,7 @@
namespace widgets
{
gcn::ImageFont* font;
gcn::Font* font;
gcn::Container* top;
gcn::Label* label;
gcn::Icon* icon;
@@ -80,7 +80,8 @@ namespace widgets
globals::gui->setTop(top);
// Now we load the font used in this example.
font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
//font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
font = new gcn::contrib::SDLTrueTypeFont("Roboto-Bold.ttf", 10);
// Widgets may have a global font so we don't need to pass the
// font object to every created widget. The global font is static.
gcn::Widget::setGlobalFont(font);
@@ -94,9 +95,9 @@ namespace widgets
button = new gcn::Button("Button");
textField = new gcn::TextField("Text field");
textField = new gcn::TextField("Text field АбВгЁ");
textBox = new gcn::TextBox("Multiline\nText box");
textBox = new gcn::TextBox("Multiline\nText box\nАбВгЁ");
textBoxScrollArea = new gcn::ScrollArea(textBox);
textBoxScrollArea->setWidth(200);
textBoxScrollArea->setHeight(100);
@@ -109,14 +110,14 @@ namespace widgets
checkBox1 = new gcn::CheckBox("Checkbox 1");
checkBox2 = new gcn::CheckBox("Checkbox 2");
radioButton1 = new gcn::RadioButton("RadioButton 1", "radiogroup", true);
radioButton2 = new gcn::RadioButton("RadioButton 2", "radiogroup");
radioButton3 = new gcn::RadioButton("RadioButton 3", "radiogroup");
radioButton1 = new gcn::RadioButton("RadioButton 1 АбВгЁ", "radiogroup", true);
radioButton2 = new gcn::RadioButton("RadioButton 2 АбВгЁ", "radiogroup");
radioButton3 = new gcn::RadioButton("RadioButton 3 АбВгЁ", "radiogroup");
slider = new gcn::Slider(0, 10);
slider->setSize(100, 10);
window = new gcn::Window("I am a window Drag me");
window = new gcn::Window("I am a window Drag me АбВгЁ");
window->setBaseColor(gcn::Color(255, 150, 200, 190));
darkbitsImage = gcn::Image::load("darkbitslogo_by_haiko.bmp");
@@ -126,10 +127,10 @@ namespace widgets
tabbedArea = new gcn::TabbedArea();
tabbedArea->setSize(200, 100);
tabOneButton = new gcn::Button("A button in tab 1");
tabbedArea->addTab("Tab 1", tabOneButton);
tabTwoCheckBox = new gcn::CheckBox("A check box in tab 2");
tabbedArea->addTab("Tab 2", tabTwoCheckBox);
tabOneButton = new gcn::Button("A button in tab 1 АбВгЁ");
tabbedArea->addTab("Tab 1 АбВгЁ", tabOneButton);
tabTwoCheckBox = new gcn::CheckBox("A check box in tab 2 АбВгЁ");
tabbedArea->addTab("Tab 2 АбВгЁ", tabTwoCheckBox);
// Now it's time to add the widgets to the top container
// so they will be conected to the GUI.

View File

@@ -121,11 +121,11 @@ namespace gcn
SDL_Surface *textSurface;
if (mAntiAlias)
{
textSurface = TTF_RenderText_Blended(mFont, text.c_str(), sdlCol);
textSurface = TTF_RenderUTF8_Blended(mFont, text.c_str(), sdlCol);
}
else
{
textSurface = TTF_RenderText_Solid(mFont, text.c_str(), sdlCol);
textSurface = TTF_RenderUTF8_Solid(mFont, text.c_str(), sdlCol);
}
SDL_Rect dst, src;