Can anyone tell me what FntDefineFont is doing behind the scenes?  And is there 
any valid way to undefine a font?

It seems to me (and someone else posted a message earlier - FntDefineFont and 
Dynamic Heap) that when you use FntDefineFont, it takes up space in the heap (I 
can see this happen in View->Heap in the Simulator).

I have a Unicode library that defines multiple fonts in order to be able to 
display large parts of the Unicode supported languages.  So I may be using 
every FontID from 128 to 255, if it is displaying Chinese, for example.  

Sometimes the same FontID may be used for two different fonts, which I flip 
back and forth.  This is the case for Chinese characters in the 0x8000 range, 
and Latin characters (like the space character) in the 0x0000 range. I use 
FontID 128 for both of those.

So when I want to print a space, I use FntDefineFont with a pointer to the 
Latin font, and when I want to print a Chinese character in the 0x8000 range, I 
use FntDefineFont with a pointer to that part of the Chinese font.

What seems to happen, though, is that just flipping back and forth between 
those two fonts, the entire heap is quickly depleted, and FntDefineFont starts 
returning error code 258, which means "out of memory".

So does FntDefineFont make a copy of my database record in heap?  Is there any 
way to clear font when I'm done with it?

This is essentially the code I use to define a font:

//To define the font
fontHandle = DmQueryRecord(database, fontRecordIndex);
fontPtr = MemHandleLock(fontHandle);
FntDefineFont(fontID /*e.g. 128*/, fontPtr);

//To use the font
FntSetFont(fontID);

//To unlock the handle before defining 
//a new font with the same fontID
MemPtrUnlock(fontPtr);


Repeating that code with a high density font 100 times or so results in no more 
heap space.  It takes more repititions with a low density font, since the font 
is smaller.

Is there anything I'm missing here?
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to