Irrlicht i18n (Unicode, FreeType, etc.)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki

Postby Nalin » Wed Sep 29, 2010 4:40 am

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

Postby Nalin » Thu Oct 07, 2010 1:12 am

New version of CGUITTFont:
  • Fixed a bug where glyphs weren't being allocated correctly. It could lead to crashes on exit.
Nalin
 
Posts: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby hilnius » Sun Oct 10, 2010 12:31 pm

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
hilnius
 
Posts: 33
Joined: Tue Jun 29, 2010 9:55 pm

Postby Nalin » Wed Oct 13, 2010 7:16 pm

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);
Nalin
 
Posts: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby elfuz » Thu Oct 14, 2010 11:40 am

never mind... found the answer already
elfuz
 
Posts: 14
Joined: Wed Oct 13, 2010 10:20 am

Postby SSJ17Vegeta » Sun Oct 31, 2010 9:53 am

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 :)
SSJ17Vegeta
 
Posts: 7
Joined: Thu Nov 13, 2008 9:11 am

Postby Nalin » Tue Nov 09, 2010 11:32 pm

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.
Nalin
 
Posts: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby SSJ17Vegeta » Sat Nov 13, 2010 12:26 pm

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.
SSJ17Vegeta
 
Posts: 7
Joined: Thu Nov 13, 2008 9:11 am

Postby Nalin » Fri Nov 19, 2010 5:59 am

New version of irrUString:
  • Fixed a regression introduced with the GCC 4.5+ fixes in the last release.
Nalin
 
Posts: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

CGUITTFont + irrlicht 1.7.2

Postby EvIl_DeViL » Sat Jan 15, 2011 1:09 am

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

Postby EvIl_DeViL » Sun Jan 16, 2011 3:08 pm

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!
EvIl_DeViL
 
Posts: 89
Joined: Tue Nov 06, 2007 4:49 pm

Postby Nalin » Sun Jan 23, 2011 5:43 am

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: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby Nalin » Mon Jan 24, 2011 7:10 am

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: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby Nalin » Thu Feb 17, 2011 10:51 pm

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.
Nalin
 
Posts: 188
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA

Postby zillion42 » Fri Feb 18, 2011 6:50 pm

could I do square roots huge brackets greek alphabet and such things with this ?
zillion42
 
Posts: 320
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

PreviousNext

Return to Project Announcements

Who is online

Users browsing this forum: No registered users and 1 guest