vc2003 and vc2005

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

User avatar
ttom
Just popping in
Just popping in
Posts: 16
Joined: Wed Jan 12, 2005 12:06

vc2003 and vc2005

Postby ttom » Fri Mar 30, 2007 08:14

Dear All:
I test the CEGUI under the vc2003 and the vc2005. I find the Chinese font in the vc2003 is ok,but vc2005 is not correct.
I want to show "中文測試".
Any can help? thanks
------------------------------
below is vc2003
Image
-------------------------------
below is vc2005
Image

ps:Sorry for my english.
http://tw.myblog.yahoo.com/ttom921/article?mid=27&prev=-1&next=23
Last edited by ttom on Mon Apr 02, 2007 01:40, edited 1 time in total.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Fri Mar 30, 2007 12:44

I edited your title, such that vc200 now shows vc2003. The images are not showing on this board but on your blog I see them. Since I cannot read that language, can you explain the difference between the two? It seems that one character/letter/word is missing from the image below.

How are you specifying these titles, within a .layout file or via a call to Cegui::setText("xxxxxHello World!") ?

Have you checked the font definition file that you are using? Does it in fact contain every character/letter/word that you are trying to use?

User avatar
ttom
Just popping in
Just popping in
Posts: 16
Joined: Wed Jan 12, 2005 12:06

Postby ttom » Mon Apr 02, 2007 01:54

Thanks to Rackle

I amn't to post my code, Sorry. Below is my code.
I modify the Sample_FirstWindow to Show the windows.

Code: Select all

bool FirstWindowSample::initialiseSample()
{
   using namespace CEGUI;
   // load in the scheme file, which auto-loads the TaharezLook imageset
   SchemeManager::getSingleton().loadScheme("../../datafiles/schemes/TaharezLook.scheme");
   // load in a font.  The first font loaded automatically becomes the default font.
   FontManager::getSingleton().createFont("../../datafiles/fonts/mingliu-12.font");

   System::getSingleton().setDefaultFont("mingliu-12");
   System::getSingleton().setDefaultMouseCursor("TaharezLook","MouseArrow");

   ///////////////////////////////////////////////////////////////////////////////
   WindowManager& wmgr = WindowManager::getSingleton();
   Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
   System::getSingleton().setGUISheet(myRoot);
   FrameWindow* fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
   myRoot->addChildWindow(fWnd);
   fWnd->setPosition( UVector2(cegui_reldim(0.25f), cegui_reldim( 0.25f)));
   fWnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
   fWnd->setText((utf8*)"中文測試Hello World!TUTOR1" );
   return true;
}

PS:"mingliu-12.font" is the chinese of TTF.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Apr 02, 2007 16:24

Sadly I do not know the answer to this problem. That source file should be in the proper code page/unicode format since it displays your text correctly when you look at in in your editor. The problem then becomes one of properly converting from your litteral string (in code) to UTF-8. Could the project settings have an impact, such as setting Visual Studio to use unicode versus the other settings?

Hopefully someone else can provide a better answer.

User avatar
ttom
Just popping in
Just popping in
Posts: 16
Joined: Wed Jan 12, 2005 12:06

Postby ttom » Tue Apr 03, 2007 05:21

Thanks again to Rackle.
if I use the file of 'test.layout' to creat the windows, it is ok.
Below is the 'test.layout'

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
    <Window Type="DefaultWindow" Name="root">
        <Window Type="TaharezLook/FrameWindow" Name="testWindow">
            <!-- Property Name="Position" Value="x:0.25 y:0.25" /-->
            <!-- Property Name="Size" Value="w:0.5 h:0.5" /-->
            <!-- with CEGUI >= 0.4.0 you can and should use instead:
             -->
             <Property Name="UnifiedPosition" Value="{{0.25,0},{0.25,0}}" />
             <Property Name="UnifiedSize" Value="{{0.5,0},{0.5,0}}" />
           
            <Property Name="Text" Value="中文測式Hello World!TUTOR2" />
        </Window>
    </Window>
</GUILayout>


So I search the forms to find the solution. I find someone to post the code.

Code: Select all

////////////-------------unicode->utf8
   std::wstring szWstring(L"中文測試wstring" );
   char *szUtf8String = NULL;
   int iLengthAnsiString = 0;
   iLengthAnsiString = WideCharToMultiByte(CP_UTF8, 0,szWstring.c_str(), szWstring.capacity(), NULL, 0, NULL, NULL);
   szUtf8String = new char[ iLengthAnsiString];
   memset(szUtf8String, 0, sizeof(char)*(iLengthAnsiString));
   WideCharToMultiByte(CP_UTF8, 0,szWstring.c_str(), szWstring.length(), szUtf8String, iLengthAnsiString, NULL, NULL);
   fWnd->setText((CEGUI::utf8*)szUtf8String);
   delete [] szUtf8String;
   szUtf8String = NULL;
 

I found this can work.


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest