Results 1 to 9 of 9

Thread: Simple changes in RTFont class to possibility of support utf8

  1. #1

    Default Simple changes in RTFont class to possibility of support utf8

    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); )?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Quote Originally Posted by Yogi View Post
    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.
    Seth A. Robinson
    Robinson Technologies

  3. #3

    Default

    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 ) 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.


    Last edited by Yogi; 04-30-2013 at 06:40 PM.

  4. #4
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default show in mobile overlay utf8

    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];

    Name:  螢幕快照 2013-05-02 下午1.21.11.png
Views: 28
Size:  395.7 KB

  5. #5

    Default

    I finished first version of utf8 font. You can download it from here. 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.



    From here 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.





    After all these steps you should get this:


  6. #6
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default cool , can it apply in all menu

    see this , very good

    can it apply on all menu and dialog?

    Quote Originally Posted by Yogi View Post
    I finished first version of utf8 font. You can download it from here. 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.



    From here 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.





    After all these steps you should get this:


  7. #7

    Default

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

  8. #8
    Lesser Wizard
    Join Date
    Feb 2013
    Posts
    142

    Default tks

    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:
    {
    }

    Quote Originally Posted by Yogi View Post
    Yes, you can. In BaseApp constructor replace RTFont with RTFontUtf8.

  9. #9
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Wow, cool stuff. I hope to put this in in the Proton svn sometime, a little too busy right now to do it.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Help to create UTF8 surface cache!!!
    By feelthat in forum Proton SDK
    Replies: 2
    Last Post: 04-09-2013, 09:16 AM
  2. help to show utf8 text input box
    By feelthat in forum Game development
    Replies: 2
    Last Post: 02-24-2013, 12:59 AM
  3. CL_MoviePlayer, a possibility?
    By ByteKiller in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 06-01-2010, 04:14 PM
  4. CL_Random Class
    By rombust in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 07-21-2009, 07:54 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •