Page 7 of 12

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

Posted: Wed Jul 06, 2011 6:00 am
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

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

Posted: Wed Jul 06, 2011 1:38 pm
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.

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

Posted: Mon Sep 26, 2011 12:15 pm
by Virror
The TTF loader was just what i was looking for! Great one : D

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

Posted: Mon Sep 26, 2011 4:06 pm
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);"

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

Posted: Mon Sep 26, 2011 4:40 pm
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);

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

Posted: Mon Sep 26, 2011 6:09 pm
by Virror
Works like a charm!
Thanx alot for the help and this super nice project : D

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

Posted: Fri Sep 30, 2011 3:37 pm
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.

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

Posted: Sun Oct 23, 2011 12:01 am
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

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

Posted: Sun Oct 23, 2011 4:55 am
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.

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

Posted: Sun Oct 30, 2011 8:37 am
by sagetarian
Just wanted to thank you for this. Works like charm :D

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

Posted: Mon Jan 09, 2012 8:21 am
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)....

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

Posted: Mon Jan 09, 2012 8:17 pm
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...

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

Posted: Tue Jan 10, 2012 3:18 pm
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.

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

Posted: Tue Jan 10, 2012 7:33 pm
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.

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

Posted: Sun May 20, 2012 6:47 pm
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.