Irrlicht i18n (Unicode, FreeType, etc.)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Jake007
Posts: 16
Joined: Wed Jun 29, 2011 8:39 pm
Location: Slovenia

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Jake007 »

I managed to get it working :).
When I tried to run it again ( directly from Code::Blocks CTRL + F10) with new version of CGUITTFont compiled in, it crashed again. It wrote that it couldn't open arial.ttf although I have it in correct folder. Then I tried to run just compiled .exe ( double click) in and it worked.

I feel stupid because I didn't try this earlier. Sorry for the caused trouble and my bad English.

Eariler it crashed on this line, but I guess that it doesn't matter any more ;):

Code: Select all

tt_font->draw( L"Simple font test!", rect<s32>( 0, 0,100, 100), SColor( 0, 50, 50, 50), false, false,0);
Regards,
Jake
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

Jake007 wrote:Eariler it crashed on this line, but I guess that it doesn't matter any more ;)
I think I see what happened. It failed to load the font, so it returned a nullptr. You then tried to use tt_font->draw. Well, tt_font was 0, so you got a null pointer exception.
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Virror »

The TTF loader was just what i was looking for! Great one : D
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Virror »

Hmm, getting "error C2664: 'irr::video::ITexture::lock' : cannot convert parameter 1 from 'bool' to 'irr::video::E_TEXTURE_LOCK_MODE'"
When compiling the code. Error is on line 923
"void* ptr = tex->lock(true);"
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

Virror wrote:Hmm, getting "error C2664: 'irr::video::ITexture::lock' : cannot convert parameter 1 from 'bool' to 'irr::video::E_TEXTURE_LOCK_MODE'"
When compiling the code. Error is on line 923
"void* ptr = tex->lock(true);"
It looks like you are using the 1.7.2 patch set on the SVN trunk code. That problem is fixed if you use the SVN trunk patches. You can fix it like this:

Code: Select all

void* ptr = tex->lock(video::ETLM_READ_ONLY);
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Virror »

Works like a charm!
Thanx alot for the help and this super nice project : D
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

New version of irrUString:
  • Fixed a bug with the replace() function.
  • Added new operator+= overloads. char appends characters while short/long, unsigned short/long, and double convert a number into a string. If you are using GCC 4.5 in C++11 mode, int and unsigned int also convert a number into a string, as char32_t takes over their assigned function of adding individual unicode characters.
  • Added new operator+ overloads. char appends characters while short/long/int, unsigned short/long/int, and float/double convert a number into a string. If you are using GCC 4.5 in C++11 mode, char32_t can be used to append unicode characters.
randombob
Posts: 1
Joined: Sat Oct 22, 2011 10:33 pm

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by randombob »

how do you incorporate this into a project? can someone give me a project with just this, or is there a framework with this and irrbullet allready on it? btw good job looks great :D
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

randombob wrote:how do you incorporate this into a project? can someone give me a project with just this, or is there a framework with this and irrbullet allready on it? btw good job looks great :D
You can make use of the unicode string class, TrueType fonts, and string tables without modifying Irrlicht.

For the unicode string class, you just have to #include "irrUString.h" in your headers (you can put it into irrlicht.h to make it easier on you.)

For TrueType fonts and string tables, just add the sources directly to your project and use them.

If you need the ability to read/write unicode XML files, you will have to modify the Irrlicht source and build it yourself. You won't be able to use the pre-compiled library.
sagetarian
Posts: 1
Joined: Sat Oct 29, 2011 10:18 am

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by sagetarian »

Just wanted to thank you for this. Works like charm :D
Felyza
Posts: 9
Joined: Sun Aug 09, 2009 4:30 am

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Felyza »

Visual Studio Express 2008, irrLicht 1.7.2

Added irrUString.h to project, got this...

Code: Select all

 
1>path\irrUString.h(3849) : error C2039: 'unary_function' : is not a member of 'std'
1>path\irrUString.h(3849) : error C2504: 'unary_function' : base class undefined
1>path\irrUString.h(3849) : error C2143: syntax error : missing ',' before '<'
 
Fixed it with this...

Code: Select all

 
#ifndef USTRING_NO_STL
#   include <string>
#   include <iterator>
#   include <ostream>
#   include <functional> // Add this line
#endif
 
Don't know if this is the ideal solution (didn't look for a better define to throw it under), but it works for my instance.

With these errors fixed, CGUITTFont.cpp built fine and works a charm, thanks.

Sure wish someone who's more skilled than I would get around to adding TTF functionality into irrlicht (hint hint)....
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

Thanks for catching that. You put it in the right place, so don't worry about that. I've uploaded the fixed version.

For anyone who still watches this thread, I have a newer version of irrUString.h in the pipeline. It replaces occurrences of u32 and s32 with size_t to make it more portable. The only problem is that it isn't a trivial change, so I am going to have to (finally) create a test suite and test it. And I am sure I also saw some potential issues with iterators in some of the algorithms...
Felyza
Posts: 9
Joined: Sun Aug 09, 2009 4:30 am

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Felyza »

Ok, so I decided to check out the svn. After fixing a problem with the project file where someone forgot to add files to all projects, I found out CGUITTFont doesn't build anymore.

So, here's what to change to make this work with current svn (r4032)!

Code: Select all

 
  video::IImage* CGUITTFont::createTextureFromChar(const uchar32_t& ch)
  {
        using namespace video; //add this line, might as well here since its only needed in this scope
 

Code: Select all

 
        // Acquire a read-only lock of the corresponding page texture.
        void* ptr = tex->lock(ETLM_READ_ONLY); //true gets changed to ETLM_READ_ONLY (needs video namespace)
 

Code: Select all

 
                                IMesh* meshcopy = mani->createMeshCopy(shared_plane_ptr_);
                                mani->scale(meshcopy, vector3df((f32)letter_size.Width, (f32)letter_size.Height, 1)); //this line is changed to scale from scaleMesh
 
With these changes, and the previous one I posted yesterday, all is well and working in latest svn.
Nalin
Posts: 194
Joined: Thu Mar 30, 2006 12:34 am
Location: Lacey, WA, USA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by Nalin »

Felyza wrote:Ok, so I decided to check out the svn. After fixing a problem with the project file where someone forgot to add files to all projects, I found out CGUITTFont doesn't build anymore.

So, here's what to change to make this work with current svn (r4032)!
Thanks, but I caught that a while ago. I have two different patch sets in the OP: svn trunk and 1.7.2. The trunk patches contain these fixes already. If you happen to find anything else, let me know. That reminds me, though, that I haven't checked out the latest Irrlicht trunk head in a while now. I'll upload a newer trunk patch that will apply cleanly to the latest head revision.
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: Irrlicht i18n (Unicode, FreeType, etc.)

Post by christianclavet »

Hi, Nalin.

Been trying lately to use your ustring class. Don't know if I'm using it properly:

- Since I don't want to patch Irrlicht in any way, I included the file from my own project

Code: Select all

#include <irrlicht.h>
#include "irrUString.h"
I load a string from a irrXML node (My file is UTF8) and want it converted to wchar so I can use and display it properly in Irrlicht:

Code: Select all

core::stringw  result = L"";
core::ustring result2 = L"";
 
result2=(core::ustring)description; // change the data type to ustring (Is this ok?), "description is the raw text in stringw"
result = (result2.toWCHAR()); // Try to get the proper conversion to WCHAR (got error C2679)
list->addItem(result.c_str()); // Add the result in a listbox to see if the text is converted properly.
Edit: Reading from of this thread, I think I will have to patch the XML loader, as the data came from there.
Post Reply