PDA

View Full Version : Simple changes in RTFont class to possibility of support utf8



Yogi
04-27-2013, 11:06 AM
Hi Seth.

Our team is writing a simple game. We have problem with lack of utf8 support in Proton SDK. I like when you can add functionality without of changing game engine, but RTFont class hasn't this feature. Solution is very simple. Can you add word virtual in front of functions definition (MeasureText, DrawScaled, DrawScaledSolidColor, GetNextLine, CountCharsThatFitX) and add possibility to replace font object (e.g. void SetFont(eFont font, RTFont* font); )?

Seth
04-27-2013, 11:12 AM
Hi Seth.

Our team is writing a simple game. We have problem with lack of utf8 support in Proton SDK. I like when you can add functionality without of changing game engine, but RTFont class hasn't this feature. Solution is very simple. Can you add word virtual in front of functions definition (MeasureText, DrawScaled, DrawScaledSolidColor, GetNextLine, CountCharsThatFitX) and add possibility to replace font object (e.g. void SetFont(eFont font, RTFont* font); )?

Well, if you guys make the change and give me the svn patch, I would apply it if it didn't break anything else. Sounds good to me.

Yogi
04-30-2013, 10:21 AM
This isn't as simple as I thought. I discovered that character table has less than 256 size (is hardcoded in RTPack). If your font (*.fnt file) has letters outside of core then converter drop all all of it. I successfully compiled RTPack (after few hours :sweatdrop:) but something went wrong :( and I got this (screens below). More important is that after resized table to (511 - 32) utf8 letters, mapping info is properly working in proton sdk (extended RTFont). Can you upload RTPack with extended information table? I think size 4096 or 8192 should be ok.


http://yogas.neostrada.pl/proton1.png

feelthat
05-02-2013, 05:32 AM
I use overlay to solve this problem... maybe win32 can use this way too

//old way
[_window addSubview:_HalaViewController.view];

//new way
//[self.IB_window setRootViewController:_HalaViewController];

m_ChatController =
[[[ChatViewController alloc] initWithNibName:@"ChatViewController"
bundle:nil] autorelease];

CGRect setframe = m_ChatController.view.bounds;
m_ChatController.view.bounds = CGRectMake(setframe.origin.x,
setframe.origin.y,
setframe.size.width,
setframe.size.height);

[_window addSubview:m_ChatController.view];

4656

Yogi
05-02-2013, 04:08 PM
I finished first version of utf8 font. You can download it from here (http://yogas.neostrada.pl/Proton_utf8_mod.zip). Instalation is very simple, unpack it and paste shared and tools folder in Proton SDK directory. In visual studdio add RTFontUtf8.h and cpp to shared/GUI filter.

http://yogas.neostrada.pl/visual_help_0.png

From here (http://yogas.neostrada.pl/font_trajan.rtfont) you can download font prepared for below sample (it has only a few japanese and korean letters).

In RTSimpleApp\source\GUI\MainMenu.cpp [function: Entity * MainMenuCreate(Entity *pParentEnt), line:128] paste this code:

GetBaseApp()->SetFont(FONT_SMALL, new RTFontUtf8("interface/font_trajan.rtfont"));
pButtonEntity = CreateTextLabelEntity(pBG, "lang1", 300, 50, "Polish: ąćęłńśźż"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));
pButtonEntity = CreateTextLabelEntity(pBG, "lang2", 300, 100, "Japanese: 日本の手紙"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));
pButtonEntity = CreateTextLabelEntity(pBG, "lang3", 300, 150, "Korean: 한국어 문자"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));

and in the include section add #include "GUI/RTFontUtf8.h"

Remember to save file as properly encoded.

http://yogas.neostrada.pl/visual_help_1.png

http://yogas.neostrada.pl/visual_help_2.png

After all these steps you should get this:

http://yogas.neostrada.pl/app_screen_0.png

feelthat
05-02-2013, 04:57 PM
see this , very good

can it apply on all menu and dialog?


I finished first version of utf8 font. You can download it from here (http://yogas.neostrada.pl/Proton_utf8_mod.zip). Instalation is very simple, unpack it and paste shared and tools folder in Proton SDK directory. In visual studdio add RTFontUtf8.h and cpp to shared/GUI filter.

http://yogas.neostrada.pl/visual_help_0.png

From here (http://yogas.neostrada.pl/font_trajan.rtfont) you can download font prepared for below sample (it has only a few japanese and korean letters).

In RTSimpleApp\source\GUI\MainMenu.cpp [function: Entity * MainMenuCreate(Entity *pParentEnt), line:128] paste this code:

GetBaseApp()->SetFont(FONT_SMALL, new RTFontUtf8("interface/font_trajan.rtfont"));
pButtonEntity = CreateTextLabelEntity(pBG, "lang1", 300, 50, "Polish: ąćęłńśźż"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));
pButtonEntity = CreateTextLabelEntity(pBG, "lang2", 300, 100, "Japanese: 日本の手紙"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));
pButtonEntity = CreateTextLabelEntity(pBG, "lang3", 300, 150, "Korean: 한국어 문자"); y += ySpacer / 3.0f;
SetScale2DEntity(pButtonEntity, CL_Vec2f(0.5f, 0.5f));

and in the include section add #include "GUI/RTFontUtf8.h"

Remember to save file as properly encoded.

http://yogas.neostrada.pl/visual_help_1.png

http://yogas.neostrada.pl/visual_help_2.png

After all these steps you should get this:

http://yogas.neostrada.pl/app_screen_0.png

Yogi
05-02-2013, 05:44 PM
Yes, you can. In BaseApp constructor replace RTFont with RTFontUtf8.

feelthat
05-03-2013, 04:18 AM
cool tks you, another ques. when using input dialog its need IME case
if you have time plz impelement it...and maybe need other way in ios and android

//main.cpp
case WM_IME_CHAR:
{
}


Yes, you can. In BaseApp constructor replace RTFont with RTFontUtf8.

Seth
05-05-2013, 07:46 AM
Wow, cool stuff. I hope to put this in in the Proton svn sometime, a little too busy right now to do it. :sweatdrop: