- Fixed a memory leak found by vroad.
Irrlicht i18n (Unicode, FreeType, etc.)
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
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
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);
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
EDIT: A few more irrUString changes.
New version of irrUString:
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.
createTTFont is a static method of the CGUITTFont class. You need to create your font like this: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
does not change my button's Font...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);
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
Code: Select all
CGUITTFont* fontTTF = CGUITTFont::createTTFont(_environment, "fonts/times.ttf", 20, false, false);
-
- Posts: 19
- Joined: Thu Nov 13, 2008 9:11 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 :
How can I convert it back to "scénario" using ustring class ? (Or any other method).
I've tried the following :
Neither toUTF8_s() or toWCHAR_s() gave me the solution.
Thanks in advance for your help
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
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();
Thanks in advance for your help
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.htmSSJ17Vegeta 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
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.
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 wrote:Code: Select all
stringw otherTest = test.toUTF8_s();
-
- Posts: 19
- Joined: Thu Nov 13, 2008 9:11 am
-
- Posts: 89
- Joined: Tue Nov 06, 2007 4:49 pm
CGUITTFont + irrlicht 1.7.2
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
if I comment out the following line
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.
the CGUITTFont version I got is the actual one in the first post (I think is the last).
thanks for the support!
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);
Code: Select all
if(tt_font)
skin->setFont(tt_font);
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;
}
thanks for the support!
-
- Posts: 89
- Joined: Tue Nov 06, 2007 4:49 pm
New version of ustring:
As an example of the new iterator:
- STL compatible iterator. It can be disabled with a #define.
- Fixed a corruption issue that afflicted UTF-8 and UTF-32 parsing.
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.
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.