Irrlicht i18n (Unicode, FreeType, etc.)

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

Post by Nalin »

zet.dp.ua wrote:One suggestion: it would be better to minimize the additional info in the xml file. <entry id="My string">My string</entry>, <s id="My string">My string</s> could be enough.

Integrating string table with irrlicht's text node can really save a lot of time.
Don't write any possibly localizable text in the code!!! :)
Hmm. I guess I could use both methods. The reason I did it that way was because people may do something like this:

Code: Select all

core::ustring info = st::_T("<Information>");
They would assume that if no translations were loaded, st::_T("<Information>") would return <Information>. They could target their default language and allow people to optionally load/install language packs.

Of course, because they used < and >, it breaks XML. Which is why I support CDATA:

Code: Select all

<entry>
    <id><![CDATA[<Information>]]></id>
    <translation>sdfsdfgjkdfhg</translation>
</entry>
But, I can definitely see your point. I'll make it recognize that "condensed" mode.

---

I've uploaded new changes:
ustring:
  • Fixed operator= that I broke with the previous upload.
  • Fixed an error in UTF-8 and UTF-32 parsing that I introduced in the previous upload.
CStringTable:
  • Support for a more condensed XML style.
LosNir
Posts: 43
Joined: Wed Dec 19, 2007 6:38 pm
Location: Israel
Contact:

Post by LosNir »

Thanks for sharing this!

The CGUITTFont crashes when I try to load a font. When I call createTTFont it crash on line 251 of CGUITTFont.cpp.

Code: Select all

Driver = Environment->getVideoDriver();
Waiting for your response on how to fix it.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

LosNir wrote:Thanks for sharing this!

The CGUITTFont crashes when I try to load a font. When I call createTTFont it crash on line 251 of CGUITTFont.cpp.

Code: Select all

Driver = Environment->getVideoDriver();
Waiting for your response on how to fix it.
The only way that could crash is if you are passing in an invalid pointer to the IGUIEnvironment when calling createTTFont(). You should debug your code to make sure your IrrlichtDevice isn't being mangled or dropped somewhere.
LosNir
Posts: 43
Joined: Wed Dec 19, 2007 6:38 pm
Location: Israel
Contact:

Post by LosNir »

Sweet! Thanks. I dropped a line that sets the IGUIEnvironment on the class, so I passed a NULL pointer. Thanks :)

EDIT:

Now it crashed on line 196 :(
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

LosNir wrote:Sweet! Thanks. I dropped a line that sets the IGUIEnvironment on the class, so I passed a NULL pointer. Thanks :)

EDIT:

Now it crashed on line 196 :(
What error does it give?
Possible issues could be:
1. Your font size is 0.
2. You called setMaxPageTextureSize() and set the maximum texture size to 0x0.
3. driver->getMaxTextureSize() is returning 0x0 for some reason.

-----

Anyways, I've updated CGUITTFont, to prevent it from crashing in the previous specified circumstances, and CStringTable, to fix a bug and add a function.

CGUITTFont:
  • If the maximum texture size is calculated as 0x0 pixels, set it to 2048x2048 pixels.
  • Don't attempt to load the font if the filename is empty, the font size is set to 0, or a null pointer was passed to the environment.
  • Fixed a memory leak in some back up code that generally shouldn't run (backup code in case no IFileSystem exists, which generally shouldn't happen.)
CStringTable:
  • The CStringTableUString copy constructor copies the prefix and postfix values properly.
  • New helper function in CStringTableUString named wcs(). It returns a const wchar_t*, to make it easier to pass information to Irrlicht functions.
LosNir
Posts: 43
Joined: Wed Dec 19, 2007 6:38 pm
Location: Israel
Contact:

Post by LosNir »

I used different fonts, with size 14, and never called the functions you mentioned. Anyway after the update it now works.

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

Post by Nalin »

SVN Trunk: CXMLReaderImpl_trunk.patch
SVN Trunk: CFileSystem_trunk.patch

Recently, I noticed that a change to irrXML.h in the SVN trunk, made on revision 3256, broke my unicode XML reading patch. I've added some new .patch files to the OP that you can use against the latest SVN trunk.
Valodim
Posts: 4
Joined: Sun May 09, 2010 11:20 am

Post by Valodim »

Hey dude.

Good work on those libs, works great for displaying text as 2d hud.

However, I am having problems using it as font to display on a bilboard using addBillboardTextSceneNode(). The type check works and it compiles, but at runtime the content of the CGUITTFont pointer gets garbled right after the addBillboardTextSceneNode() call (which does work using the builtinFont), and the program crashes.

Is this known / intended behavior? I couldn't find any info on using your class on billboards on this forum..

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

Post by Nalin »

Valodim wrote:Is this known / intended behavior? I couldn't find any info on using your class on billboards on this forum..
It is an unknown / unintended behavior.

Basically, I haven't tested my class at all when using billboards. I'll make myself a note to search for and test anything that can take an IGUIFont*.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

Okay, I've figured out the issue.
IBillboardTextSceneNode was written to specifically use the normal IGUIFontBitmap class. When it looks at my CGUITTFont class, it detects that it isn't an IGUIFontBitmap, so it writes this to the log and aborts:

Code: Select all

os::Printer::log("Sorry, CBillboardTextSceneNode does not support this font type", ELL_INFORMATION);
This is all fine and dandy, but it then calls:

Code: Select all

setText(text);
setText() doesn't check to see if the font was loaded successfully and immediately tries to gain access to the SMesh that should have been created in the constructor, causing a null pointer exception.

So there you have it. It is a bug with Irrlicht. I suppose I should create my own version of IBillboardTextSceneNode that works with my CGUITTFont class, as the one in Irrlicht only works with Irrlicht's bitmap font format.

EDIT:
I fixed it and submitted a patch. It should be fixed in future versions of Irrlicht.
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks for the patch. I applied it to the 1.7 svn branch.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Valodim
Posts: 4
Joined: Sun May 09, 2010 11:20 am

Post by Valodim »

Wow, that's some quick replies around here.

Thanks for the insight.

Is getting your font class to work with billboards a very difficult endeavor? As in, could a quick dive into the irrlicht source be enough to implement this, or would that require some dedication?
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

Valodim wrote:Is getting your font class to work with billboards a very difficult endeavor? As in, could a quick dive into the irrlicht source be enough to implement this, or would that require some dedication?
A quick dive into the source wouldn't be enough. I will have to design a billboard class from scratch to work with my font class. My CGUITTFont class and Irrlicht's IGUIFontBitmap class are very different in implementation. It is further complicated by the fact that my CGUITTFont class ends up creating its own textures full of glyphs, and those textures can change when you attempt to draw a glyph that hasn't been cached to a texture first. This will require some changes to CGUITTFont to make everything work well and not crash.

I've been busy lately with some XNA projects, so I won't be able to devote a bunch of time to this, but I'll try to put in some time here and there to get it working.

Until then, you could use normal font bitmaps for billboards until my class is finished. Or, you can use an ITextSceneNode. An ITextSceneNode converts its 3D position into screen coordinates, then draws the text. The text won't scale and rotate like it is part of the world, but it will somewhat simulate a billboard. Kinda. Or, you could try for an RTT solution. Render a string of text to a texture, then use that texture as a normal billboard.
Valodim
Posts: 4
Joined: Sun May 09, 2010 11:20 am

Post by Valodim »

Ah. That's probably more time than I could spend on this matter myself, especially since I have next to no experience with Irrlicht's internals.

I guess I'll just stick to bitmap font billboards for now. Thanks for your time :)
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Post by Nalin »

Well, it has been a while, has it? I've been busy with my XNA projects so I haven't had time to update things. A while ago, archilife created some really nice patches for CGUITTFont, so I have merged his work into my copy. So, here we go:

New version of CGUITTFont:
  • Lowered memory usage. (archilife)
  • The font texture atlas is now smaller (less fonts per page) to reduce memory usage. (archilife)
  • Added the ability to generate text scene nodes for rendering text in 3D space. (archilife)
I have also added proper license info to the top of irrUString.h, CGUITTFont.h, CGUITTFont.cpp, CStringTable.h, and CStringTable.cpp. It is the zlib license, the same license that Irrlicht uses. I've mentioned that all my work in this thread uses the zlib license somewhere, but I can't remember where, so adding the information directly to the source files will serve to fully clarify any confusion.
Post Reply