Irrlicht i18n (Unicode, FreeType, etc.)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

New version of CGUITTFont:
  • Fixed a memory leak found by vroad.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

New version of CGUITTFont:
  • Fixed a bug where glyphs weren't being allocated correctly. It could lead to crashes on exit.
hilnius
Posts: 33
Joined: Tue Jun 29, 2010 9:55 pm

Post by hilnius »

Hi
This stuff seems to be great, but it doesn't work on my PC...

i installed everything, files compiles well (on Code::blocks)

but the code

Code: Select all

    CGUITTFont* fontTTF = NULL;
    fontTTF->createTTFont(_environment, "fonts/times.ttf", 20, false, false);
    IGUIFont* font = fontTTF;
    irr::gui::IGUIButton* button = _device->getGUIEnvironment()->addButton(irr::core::rect<irr::s32>(0,0,200,100),0,1,L"salut",L"tooltip");
    button->setOverrideFont(fontTTF);
does not change my button's Font...
I got freetype6.dll, and installed freetype on my computer;

So can you tell me if it is a bug or if i didnt load it in the good way.

Thanks
Hilnius
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

EDIT: A few more irrUString changes.

New version of irrUString:
  • Fixed a compile error when compiling on GCC 4.5+ with C++0x support.
  • Doxygen improvements for irrUString.h.
  • Added ustring::toPATH_s() function for returning an io::path string.
hilnius wrote:Hi
This stuff seems to be great, but it doesn't work on my PC...

i installed everything, files compiles well (on Code::blocks)

but the code

Code: Select all

    CGUITTFont* fontTTF = NULL;
    fontTTF->createTTFont(_environment, "fonts/times.ttf", 20, false, false);
    IGUIFont* font = fontTTF;
    irr::gui::IGUIButton* button = _device->getGUIEnvironment()->addButton(irr::core::rect<irr::s32>(0,0,200,100),0,1,L"salut",L"tooltip");
    button->setOverrideFont(fontTTF);
does not change my button's Font...
I got freetype6.dll, and installed freetype on my computer;

So can you tell me if it is a bug or if i didnt load it in the good way.

Thanks
Hilnius
createTTFont is a static method of the CGUITTFont class. You need to create your font like this:

Code: Select all

CGUITTFont* fontTTF = CGUITTFont::createTTFont(_environment, "fonts/times.ttf", 20, false, false);
elfuz
Posts: 14
Joined: Wed Oct 13, 2010 10:20 am

Post by elfuz »

never mind... found the answer already
SSJ17Vegeta
Posts: 19
Joined: Thu Nov 13, 2008 9:11 am

Post by SSJ17Vegeta »

Hi,

Having stumbled upon your amazing work, I had been more than happy to test it, as I'm having a string encoding problem in my Irrlicht application.

When using CGUITTFont with hard-coded values, everything works fine in the GUI.

The problem rises when I'm retrieving data from a UTF-8 encoded SQLite3 database. Let's say, for example, that i'm receiving the string for the french translation of the word "scenario", which is : "scénario".

When looking in the debugger, the string I'm receiving ( of type const char* ), looks like that :

Code: Select all

Sc\303\251nario
How can I convert it back to "scénario" using ustring class ? (Or any other method).

I've tried the following :

Code: Select all

const char* initial = q.fieldValue("trad_label"); // the initial string
const uchar8_t* transtyped = (uchar8_t*) initial;
ustring test(transtyped);
stringw otherTest = test.toUTF8_s();
stringw anotherTest = test.toWCHAR_s();
Neither toUTF8_s() or toWCHAR_s() gave me the solution.

Thanks in advance for your help :)
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

SSJ17Vegeta wrote:The problem rises when I'm retrieving data from a UTF-8 encoded SQLite3 database. Let's say, for example, that i'm receiving the string for the french translation of the word "scenario", which is : "scénario".

When looking in the debugger, the string I'm receiving ( of type const char* ), looks like that :

Code: Select all

Sc\303\251nario
That isn't a properly encoded UTF-8 string at all. It looks like it was returned as an unescaped string. This is how the é is encoded in UTF-8: http://www.fileformat.info/info/unicode ... /index.htm

It seems like either you aren't putting proper UTF-8 strings into your database, or you aren't retrieving them as UTF-8 strings. I just searched for information on UTF-8 and sqlite3, and it does seem that people have problems with it. You may want to look there.
SSJ17Vegeta wrote:

Code: Select all

stringw otherTest = test.toUTF8_s();
Be careful not to do that. toUTF8_s() returns a core::stringc. If you put it into a core::stringw, it will break the string.
SSJ17Vegeta
Posts: 19
Joined: Thu Nov 13, 2008 9:11 am

Post by SSJ17Vegeta »

Hi, and thanks for the tip ;)

Currently looking for more information about that, it seems that sqlite3returns unescaped characters because they are interpreted as binary.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

New version of irrUString:
  • Fixed a regression introduced with the GCC 4.5+ fixes in the last release.
EvIl_DeViL
Posts: 89
Joined: Tue Nov 06, 2007 4:49 pm

CGUITTFont + irrlicht 1.7.2

Post by EvIl_DeViL »

hi, I regret to say I got this error when i run the project:
Unhandled exception at 0x1019a1fd in IrrTrueTypeTest.exe: 0xC0000005: Access violation reading location 0xffffffff.
on line

Code: Select all

guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", rect<s32>(10,10,260,22), true);
if I comment out the following line

Code: Select all

if(tt_font)
	skin->setFont(tt_font);
the font isn't applied so the program doesn't crash.
I post below my whole code so if it's correct anyone can copy it and have a quick response and know if everything work.

Code: Select all

#include <irrlicht.h>
#include "CGUITTFont.h"

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif

int main()
{
	IrrlichtDevice *device = createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16, false, false, false, 0);
	if (!device)
		return 1;
	device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo");
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	gui::CGUITTFont* tt_font = gui::CGUITTFont::createTTFont(guienv, "comic.ttf", 14, true, false);
	gui::IGUISkin* skin = guienv->getSkin();
	if(tt_font)
		skin->setFont(tt_font);
	guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", rect<s32>(10,10,260,22), true);
	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
	while(device->run())
	{
		driver->beginScene(true, true, SColor(255,100,101,140));
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();
	}
	device->drop();

	return 0;
}
the CGUITTFont version I got is the actual one in the first post (I think is the last).
thanks for the support!
EvIl_DeViL
Posts: 89
Joined: Tue Nov 06, 2007 4:49 pm

Post by EvIl_DeViL »

ok figured out myself... it conflicts with acki's irrExtensions in fact I tried to use original irrlicht version and it doesn't crash!
maybe for his still existing "getFont" system
I hope to be helpful for someone!
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

Thanks for reporting the issue. I've added a warning note to the OP. I also updated the patches to apply to 1.7.2 and to the latest trunk.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

New version of ustring:
  • STL compatible iterator. It can be disabled with a #define.
  • Fixed a corruption issue that afflicted UTF-8 and UTF-32 parsing.
I also updated CGUITTFont to work with the latest trunk.

As an example of the new iterator:

Code: Select all

core::ustring test("This is a test \xEF\xBF\xBD okay?");
test += 10400;

// Returns 3.
int s_count = std::count(test.begin(), test.end(), 's');

// Returns 2.
int non_ascii_count = std::count_if(test.begin(), test.end(), [](uchar32_t val) -> uchar32_t { return val > 127; });
Last edited by Nalin on Thu Feb 17, 2011 10:52 pm, edited 1 time in total.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

New version of ustring:
  • Renamed USTRING_NO_STL_COMPATIBLE_ITERATOR to USTRING_NO_STL.
  • Added a constructor for constructing from a std::basic_string.
  • Added a constructor for constructing from an iterator.
  • Added operator+ methods for appending a ustring with an Irrlicht string.
  • Added operator+ methods for appending a ustring with a std::basic_string.
  • Fixed some possible heap corruption bugs.
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

could I do square roots huge brackets greek alphabet and such things with this ?
Post Reply