Font

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Aspiring
Posts: 6
Joined: Fri May 09, 2008 1:43 am

Font

Post by Aspiring »

I've run into a problem using Irrlicht's font class, the examples show that when you are finished with it you call its drop() function.

However, when I do this and then later in my program ask the engine for the same font, it will return me a pointer pointing to garbage and cause my program to crash.

With textures there seems to be a function called removeTexture() so that the engine knows it's been deleted, but I can't find a function like this for fonts.

Can anyone help me please
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There's no such thing ATM. Even the patch in the tracker doesn't always work as expected, due to internal changes of the engine. However, a proper usage of drop should always lead to a working app. Moreover, the mem doesn't really leak, it's just not freed completely (but still some internal pointers do know about this issue). So unless you use hundreds of fonts you shouldn't notice this problem.
Aspiring
Posts: 6
Joined: Fri May 09, 2008 1:43 am

Post by Aspiring »

It's not really a memory leak that's the issue, but when I call drop() the engine doesn't seem to realise I've deleted the font, then later when I ask for the same font it will return me a pointer to the font that was deleted, thus a corrupt/invalid pointer which I can't use
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Font

Post by rogerborg »

Aspiring wrote:I've run into a problem using Irrlicht's font class, the examples show that when you are finished with it you call its drop() function.
Uh, I'm having a bad Monday: which example shows calling drop() on a font?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Aspiring
Posts: 6
Joined: Fri May 09, 2008 1:43 am

Post by Aspiring »

Heh, I just looked through all the examples for it finding nothing.

I swear I remember seeing it somewhere, I'm not crazy :(


Oh well, the question still stands, is there a way to release the memory being used by a font and still be able to re-load it later on?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

the font's texture is loaded by the driver as you'd load a normal texture and it doesn't seem to be removed, so maybe try removeTexture(font filename) after you drop it... although that may not be safe unless it's actually deleted by the drop...

although that shouldn't actually stop it from being reloaded as the texture cache should provide it...
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

JP wrote:the font's texture is loaded by the driver as you'd load a normal texture and it doesn't seem to be removed, so maybe try removeTexture(font filename) after you drop it... although that may not be safe unless it's actually deleted by the drop...

although that shouldn't actually stop it from being reloaded as the texture cache should provide it...
Uh...

1) Don't drop() it. Fonts are "add", not "create".

2) There's no method to remove a texture by name. You can however retrieve the texture by name and remove it.

Code: Select all

		gui::IGUIFont * bigFont = smgr->getGUIEnvironment()->getFont("../../media/bigfont.png");
		
		video::ITexture * fontTexture = driver->getTexture("../../media/bigfont.png");
		driver->removeTexture(fontTexture);
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Font

Post by robmar »

with large 2D font textures, is there a newer method to handle fonts?

Also, with XML font names, how can the texture be retrieved?
Post Reply