TrueType font Support by FreeType Library
Bate, which version do you use? Original, mine or Nalin's?
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
You should drop your font only once (for the create). The second ref-count comes probably from setting it to the skin, so the skin gets another reference. So I guess it is correct.
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
Sure, just set another font and the skin will release it's old font. It certainly won't drop as long as it needs it.
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
Strange, fonts seem to use the usual filesystem functions. So I would have guessed that they work also with zip's. Don't know how big of an effort, as I'll have to write a test for that first and the do some debugging. Did you try if other files (like textures or meshes) still work with the zip - maybe it just doesn't find your zip-file or something like that.
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
Oh wait - I think I know the reason for this. Freetype uses normal file-functions ... so this is actually going to be tricky.
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
Not really. We can use this function:CuteAlien wrote:Oh wait - I think I know the reason for this. Freetype uses normal file-functions ... so this is actually going to be tricky.
http://www.freetype.org/freetype2/docs/ ... emory_Face
We could then load the font from the filesystem and throw it through that function. The only issue is that you can't free the memory until you call FT_Done_Face. I'll work on modifying my version of the class to do this tomorrow (if I remember.)
Here is a new version of the class that reads via Irrlicht's filesystem, as long as an IFileSystem pointer is passed to CGUITTFace::load().
Normal:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Unicode:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Test it out and see if it works.
Normal:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Unicode:
http://nalin.suckerfree.org/public/code ... _Nalin.zip
Test it out and see if it works.
Thank you Nalin.
It doesn't compile for me
EDIT:
ah ok, just a typo it's meant to be
works like a charm, thanks again.
It doesn't compile for me
Code: Select all
bool CGUITTFace::load(const io::path& filename, io::IFileSystem* filesystem)
{
if (!libraryLoaded)
{
if (FT_Init_FreeType(&library))
return false;
CGUITTFace::libraryLoaded = true;
}
if (device) // PROBLEM HERE : "device" unknown
{
// Read in the file data.
io::IReadFile* file = filesystem->createAndOpenFile(filename);
font_buffer = new FT_Byte[file->getSize()];
file->read(font_buffer, file->getSize());
font_size = file->getSize();
file->drop();
// Create the face.
if (FT_New_Memory_Face(library, font_buffer, font_size, 0, &face))
{
delete[] font_buffer;
font_buffer = 0;
return false;
}
}
ah ok, just a typo it's meant to be
Code: Select all
if(filesystem)
Never take advice from someone who likes to give advice, so take my advice and don't take it.
Hey, very nice :-)
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
Ha, oops. I fixed it in my unicode version, but forgot to fix it in my normal version. I made the change and re-uploaded it.Bate wrote:ah ok, just a typo it's meant to beworks like a charm, thanks again.Code: Select all
if(filesystem)
-------------
I spent some time today and significantly re-wrote the CGUITTFont class. There has been concerns about licensing issues, so a re-write was necessary. The new class is much easier to use, should have less bugs, and uses a lot less memory.
Ultimately, when this is done, I will include it inside of an internationalization pack along with my unicode string class and UTF-8 XML reader/writer.
Only the unicode version is working at this time, but if anybody wants to check it out so far, you can get it here:
http://nalin.suckerfree.org/public/code ... nt_New.zip
To create a 14-point font:
Code: Select all
gui::CGUITTFont* tt_font = gui::CGUITTFont::createTTFont(device->getGUIEnvironment(), "code2001.ttf", 14);
if (tt_font == 0) { error! }
Do you think it might be possible to add an option to specify a global spacing value between all letters? It would be useful since lots of custom fonts have arbitrary shapes and overlap if used at the moment. So, that would help a lot.
Never take advice from someone who likes to give advice, so take my advice and don't take it.