right to left languages

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

right to left languages

Postby samsamsam » Thu Mar 05, 2009 13:34

hi:
am trying to write arabic worlds (as btn->setText("إنهاء")).
i tryed many thing but didn't work, as taking the world as wchar_t,, then using the minibidi, then replacing it to string...
but i guess that there is a missing point which is i didn't determine an arabic font file and ask cegui to take the font from that file...
so my question is:
how i can use an arabic font file (font files from operating system for examples) in my cegui application??
any help please...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Mar 05, 2009 19:29

Hi, and welcome ;)

With regards to string literals in C++ files you need to do two things; first you have to cast to CEGUI::utf8* (so for example, btn->setText((CEGUI::utf8*)"إنهاء"); ), and second and importantly, you must then ensure your source file encoding is specified as UTF8.

With regards to fonts, you can use any ttf font that has a Unicode character page. The ttf font can be loaded directly in code, or more usually is 'wrapped' with an XML font definition file. The example fonts that come with CEGUI and also Ogre in the Media/Gui directory use the XML wrapper approach and are a good place to start looking for examples of our approach to fonts :)

HTH

CE.

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

Postby samsamsam » Tue Mar 10, 2009 09:24

Thanks CrazyEddie...
i should read more about unicoding...

you are trying to help here and there...
so thanks :wink:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Mar 10, 2009 11:03

samsamsam wrote:Thanks CrazyEddie...
i should read more about unicoding...

you are trying to help here and there...
so thanks :wink:


NP ;)

Unicode is a massive, but quite interesting topic. IMO it's well worth people's time to become more familiar with the basic concepts and encodings (which is basically what I did back in '04).

CE.

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

Postby samsamsam » Thu Mar 19, 2009 08:42

hi again...
am still working on my problem...
i wrote this code:

Code: Select all

mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
mSystem = new CEGUI::System(mRenderer);
CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
CEGUI::MouseCursor::getSingleton().setImage(CEGUI::System::getSingleton().getDefaultMouseCursor());
if(!CEGUI::FontManager::getSingleton().isFontPresent("DejaVuSans-10"))
{
   CEGUI::FontManager::getSingleton().createFont("DejaVuSans-10.font");
}
mSystem->setDefaultFont((CEGUI::utf8*)"DejaVuSans-10");
////
CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "CEGUIDemo/Sheet");
//sheet->setFont("DejaVuSans-10");
CEGUI::Window *quit = win->createWindow("TaharezLook/Button", "CEGUIDemo/QuitButton");
quit->setFont("DejaVuSans-10");
quit->setText((CEGUI::utf8*) "إنهاء");


and i got this running time error error:

Unhandled exception at 0x00822848 in startTest.exe: 0xC0000005:
Access violation reading location 0x0043c000.

and if i removed the (CEGUI::utf8*) in the (CEGUI::utf8*) "إنهاء"
to be quit->setText( "إنهاء");
the program will excute normally but the word إنهاء will be written ÓæãÑ :cry:
i really don't know what to do...
but am thinking about using a newer release of CEGUI because am using the CEGUI libs which come with OGRE 1.6.1
so i copied the new libs to my projects but the program also crashed...
so what should i do ???? help please ... :roll:

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

Postby samsamsam » Thu Mar 19, 2009 08:44

samsamsam wrote:hi again...
am still working on my problem...
i wrote this code:

Code: Select all

mRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, mSceneMgr);
mSystem = new CEGUI::System(mRenderer);
CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");
mSystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
CEGUI::MouseCursor::getSingleton().setImage(CEGUI::System::getSingleton().getDefaultMouseCursor());
if(!CEGUI::FontManager::getSingleton().isFontPresent("DejaVuSans-10"))
{
   CEGUI::FontManager::getSingleton().createFont("DejaVuSans-10.font");
}
mSystem->setDefaultFont((CEGUI::utf8*)"DejaVuSans-10");
////
CEGUI::WindowManager *win = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window *sheet = win->createWindow("DefaultGUISheet", "CEGUIDemo/Sheet");
//sheet->setFont("DejaVuSans-10");
CEGUI::Window *quit = win->createWindow("TaharezLook/Button", "CEGUIDemo/QuitButton");
quit->setFont("DejaVuSans-10");
quit->setText((CEGUI::utf8*) "إنهاء");


and i got this running time error error:

Unhandled exception at 0x00822848 in startTest.exe: 0xC0000005:
Access violation reading location 0x0043c000.

and if i removed the (CEGUI::utf8*) in the (CEGUI::utf8*) "إنهاء"
to be quit->setText( "إنهاء");
the program will excute normally but the word إنهاء will be written ÓæãÑ :cry:
i really don't know what to do...
but am thinking about using a newer release of CEGUI because am using the CEGUI libs which come with OGRE 1.6.1
so i copied the new libs to my projects but the program also crashed...
so what should i do ???? help please ... :roll:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Mar 20, 2009 09:21

For the original issue, using the CEGUI that comes with Ogre, I think perhaps your source file is not saved with UTF8 encoding?

With regards to copying over the newer version CEGUI libs and what have you, you also need to recompile the OgreGUIRenderer module against the newer CEGUI version or it will not work correctly (you probably already did this, but I thought I'd mention it - just in case).

CE.

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Sun Mar 22, 2009 12:50

Yes, you must save your source code file as UTF8 and also, I recommend you to cast to const Utf8 * for string literals, as any reasonable compiler makes a string literal become a const char *

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

Postby samsamsam » Wed Mar 25, 2009 13:48

hi:
i got my my word "إنهاء" as i want... i did that:

Code: Select all

System::Text::UTF8Encoding^ utf8 = gcnew System::Text::UTF8Encoding;
      
BYTE ara_buf[256];
wchar_t wara_buf[] = L"إنهاء";

doBidi(wara_buf,5,1,1);

utf8->GetBytes(wara_buf,5,ara_buf,256);
quit->setText((CEGUI::utf8*) ara_buf);


i want here to ask a question even if i think that i know what to do:
am loading my gui from *.layout files, so what to do for arabic worlds in them?
i am saving them as utf-8 so arabic charectars r right but it needs reversing and testing the positinn of letter (as dobidi does)...
so after i load the layout how i can reach all windows in it (all children)??
i only can reach them by name, and i need now to reach them all, without knowing their names...
so could i??
i am thinking now about using XML parser to edit the *.layout files, and make the dobidi work on them, but i prefer the first choice by getting all children of the main window an updating the text values of them...
thanks...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Mar 25, 2009 14:17

First, a heads-up: Assaf Raman's bi-directional text support has been committed to svn trunk, so future versions of CEGUI will be able to support this natively.

As for your question about how to affect all windows within a hierarchy, what you want is something like this:

Code: Select all

void doSomethingToWindowHierachy(CEGUI::Window* start, void(*func)(CEGUI::Window*))
{
    // do it to the starting window.
    func(start);

    // recursively iterate over all children (thus doing it to them, too)
    const size_t child_count = start->getChildCount();
    for (size_t i = 0; i < child_count; ++i)
        doSomethingToWindowHierachy(start->getChildAtIdx(i), func);
}

You pass in a 'start' window, and a pointer to a function that takes a window pointer, the passed function will then be called for every window within the hierarchy. Obviously this is just a silly example and can be customised as needed.

(I didn't actually test this, btw; but it should work).

HTH

CE.

samsamsam
Just popping in
Just popping in
Posts: 6
Joined: Thu Mar 05, 2009 13:24

Postby samsamsam » Wed Apr 01, 2009 08:18

Very very very thanks... :D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests