TrueType font Support by FreeType Library
Yes, I've updated the gui_freetype_font files recently so they should work now with 1.6
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Well, I tryed you code and I get a runtime error (error repport...)
Edit : the error occurs when calling the "attach" function.
Code: Select all
CGUITTFace face;
face.load("GameData/showcard.ttf");
CGUIFreetypeFont *font=new CGUIFreetypeFont(device->getVideoDriver());
font->grab();
font->attach(&face, 12); //runtime error here
font->AntiAlias=true;
Probably because you allocate face on the stack. Try it with face = new CGUITTFace;
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Ok, I made it working.
I had a problem with the attach function call. I was sending the value of my face variable instead of its memory adress. So it's now working, however I got a problem as this is getting more and more time to attach faces to font... Morover there're some bad values comming from getWidth/getHeight functions. All there problems are not in the original version I modified to fit in Irrlicht 1.6 however your version don't make some letters desapearing randomly when using the attach function
Also my version wasn't making chars desapearing randomly when used with Irrlicht 1.4.2, so there must be something I changed which do that strange stuff.
I'll try to mix both versions
EDIT : I think characters are not rendering randomly because of a bug in FreeType.
Thanks.
I had a problem with the attach function call. I was sending the value of my face variable instead of its memory adress. So it's now working, however I got a problem as this is getting more and more time to attach faces to font... Morover there're some bad values comming from getWidth/getHeight functions. All there problems are not in the original version I modified to fit in Irrlicht 1.6 however your version don't make some letters desapearing randomly when using the attach function
Also my version wasn't making chars desapearing randomly when used with Irrlicht 1.4.2, so there must be something I changed which do that strange stuff.
I'll try to mix both versions
EDIT : I think characters are not rendering randomly because of a bug in FreeType.
Thanks.
The original version had several memory bugs, so I wouldn't be too surprised on some random behaviour. I don't think I changed the width, but the height is more or less wrong in both versions. My latest workaround does return as height the largest height of any single characters used so far - which is why I initialize in CGUIFreetypeFont::attach a bunch of characters which formerly caused trouble. If some more cause problems please tell me which ones. There is possibly a better solution as TrueType actually knows the correct height itself but I found no way to access it without doing some calculations for which I didn't manage to find all necessary values (but I only invested a few hours before I gave and used my workaround).
edit: If you have an example which compiles and can be used to reproduce any problems ... I'm always glad to get those.
edit: If you have an example which compiles and can be used to reproduce any problems ... I'm always glad to get those.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Textures are not grab()'ed so no need to release them. Though they should probably be grab()'ed usually.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
I have recently gone through and made many changes to CGUITTFont, making it work for Irrlicht 1.6+.
Some changes I have made:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Update 11/23/2009:
I fixed a problem where a glyph's true height was not calculated correctly. Also, I added some code to work around Irrlicht's handling of text height. Irrlicht assumes you will be using bitmapped fonts with a set size. FreeType has a set glyph size, but the glyph may hang under the origin, giving it a larger "true" height. This fixes a problem where characters like 'j' and 'g' would get cut off in tooltip text, which calculates the text size based on the single character 'A', instead of the whole text string.
Some changes I have made:
- Compiles with Irrlicht 1.6 and up (added missing functionality).
- You can turn hinting on or off.
- Kerning.
- Multi-line text.
- Ability to specify font sizes in pixels or points.
- Comments to the source files.
- Various bug fixes.
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Update 11/23/2009:
I fixed a problem where a glyph's true height was not calculated correctly. Also, I added some code to work around Irrlicht's handling of text height. Irrlicht assumes you will be using bitmapped fonts with a set size. FreeType has a set glyph size, but the glyph may hang under the origin, giving it a larger "true" height. This fixes a problem where characters like 'j' and 'g' would get cut off in tooltip text, which calculates the text size based on the single character 'A', instead of the whole text string.
-
- Posts: 135
- Joined: Thu Oct 30, 2008 11:56 am
- Location: UK
- Contact:
I haven't found time yet to merge Nalin's changes, but I found a bug in my bugfix for the font-heights. I had cached the largest Glyph for a Face instead for the Font - so it was messed up if you used the same Font with different Sizes. An updated version is as usual on my website.
I've also put my fontmanager back on the website, as it allows using fonts easier without the need to patch the engine. So unless you need serialization that is easier to use.
I've also put my fontmanager back on the website, as it allows using fonts easier without the need to patch the engine. So unless you need serialization that is easier to use.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 70
- Joined: Tue Oct 28, 2008 12:59 pm
I got an e-mail from a Mr. Hong about a crash issue he encountered with my modified class. I have fixed the issue he encountered as well as a separate crash issue and uploaded a fixed version.
The issue Mr. Hong discovered was a crash if you tried to delete a CGUITTFont object. CGUITTGlyph was improperly reference counted. The other issue is if you tried to delete a CGUITTFace object and create a new one (a class static variable wasn't being reset correctly on the first deletion.)
You can download my changes here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
---
Also, I made a version of my CGUITTFont class that works in conjunction with my UTF-16 string class, which can be found here:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=36406
You can download the class here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Basically, this version will allow you to have proper multi-byte character support in Windows.
The issue Mr. Hong discovered was a crash if you tried to delete a CGUITTFont object. CGUITTGlyph was improperly reference counted. The other issue is if you tried to delete a CGUITTFace object and create a new one (a class static variable wasn't being reset correctly on the first deletion.)
You can download my changes here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
---
Also, I made a version of my CGUITTFont class that works in conjunction with my UTF-16 string class, which can be found here:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=36406
You can download the class here:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Basically, this version will allow you to have proper multi-byte character support in Windows.
Code: Select all
myFace = new CGUITTFace;
myFace->load("data/font.ttf");
myFont = new CGUITTFont(guienv);
myFont->attach(myFace, 8, true);
myFont->AntiAlias = true;
myFont->Transparency = true;
myFont->AutoHinting = true;
myFont->FontHinting = true;
mySkin->setFont(myFont);
std::cout << myFont->getReferenceCount() << std::endl; // = 2
std::cout << myFace->getReferenceCount() << std::endl; // = 1
IrrArray.h
Code: Select all
//! Clears the array and deletes all allocated memory.
void clear()
{
for (u32 i=0; i<used; ++i)
allocator.destruct(&data[i]); // CRASH HERE
allocator.deallocate(data); // delete [] data;
data = 0;
used = 0;
allocated = 0;
is_sorted = true;
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.