Page 1 of 1

right to left languages

Posted: Thu Mar 05, 2009 13:34
by samsamsam
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...

Posted: Thu Mar 05, 2009 19:29
by CrazyEddie
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.

Posted: Tue Mar 10, 2009 09:24
by samsamsam
Thanks CrazyEddie...
i should read more about unicoding...

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

Posted: Tue Mar 10, 2009 11:03
by CrazyEddie
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.

Posted: Thu Mar 19, 2009 08:42
by samsamsam
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:

Posted: Thu Mar 19, 2009 08:44
by samsamsam
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:

Posted: Fri Mar 20, 2009 09:21
by CrazyEddie
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.

Posted: Sun Mar 22, 2009 12:50
by Pompei2
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 *

Posted: Wed Mar 25, 2009 13:48
by samsamsam
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...

Posted: Wed Mar 25, 2009 14:17
by CrazyEddie
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.

Posted: Wed Apr 01, 2009 08:18
by samsamsam
Very very very thanks... :D