Page 10 of 13
Posted: Fri Jan 22, 2010 9:35 pm
by CuteAlien
Bate, which version do you use? Original, mine or Nalin's?
Posted: Fri Jan 22, 2010 9:40 pm
by Bate
Nalin's latest with FreeType 2.3.11 and Irrlicht 1.6.1.
Posted: Fri Jan 22, 2010 10:25 pm
by CuteAlien
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.
Posted: Fri Jan 22, 2010 11:38 pm
by Nalin
Yes, the skin calls grab() on it. It doesn't look like there is any way to ask a skin to get rid of a font, so if you want to delete it, you will have to modify Irrlicht to let the skin drop it.
Posted: Fri Jan 22, 2010 11:52 pm
by CuteAlien
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.
Posted: Fri Jan 29, 2010 2:06 pm
by Bate
Alright then. One last thing, loading from the Irrlicht filesystem (tried to load from a zip) doesn't seem to work.
Since I have no idea how to add this feature: would it be a big effort?
Posted: Fri Jan 29, 2010 4:10 pm
by CuteAlien
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.
Posted: Fri Jan 29, 2010 4:21 pm
by Bate
Yes, textures meshes and my font are inside the same zip file. Everything else loads fine.
Posted: Fri Jan 29, 2010 4:30 pm
by CuteAlien
Oh wait - I think I know the reason for this. Freetype uses normal file-functions ... so this is actually going to be tricky.
Posted: Sat Jan 30, 2010 12:33 am
by Nalin
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.
Not really. We can use this function:
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.)
Posted: Sat Jan 30, 2010 7:45 am
by Nalin
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.
Posted: Sat Jan 30, 2010 12:38 pm
by Bate
Thank you Nalin.
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;
}
}
EDIT:
ah ok, just a typo
it's meant to be
works like a charm, thanks again.
Posted: Sat Jan 30, 2010 6:32 pm
by CuteAlien
Hey, very nice :-)
Posted: Sun Jan 31, 2010 3:15 am
by Nalin
Bate wrote:ah ok, just a typo
it's meant to be
works like a charm, thanks again.
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.
-------------
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! }
Posted: Wed Feb 03, 2010 10:48 pm
by Bate
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.