I need to fit a text of any length to fixed area (i.e.200x300)
If text is short then the font size would be big, if text is long then font size smaller.
I use these methods to determine an approprieted font size:
while(....)
----font = [UIFont fontWithName:fontName size:currentFontSize];
----realSize = [str sizeWithFont: font constrainedToSize:rect];
Than I create a Label like this:
[Label initWithString: str dimensions: rect ....]
It works perfect, but I need to change the text in the area for many times,
every time I must create a new Label. I can't use single Label and setString method, becuase font sizes is different.
After 3-4 new Labels, FPS fall down, From 60 to 30 ftp. After new 4-5 labels to 20 fps, and goes to 0 quickly.
I've tried to delete an old label before creating new one:
label=nil;
[label release];
[[TextureMgr sharedTextureMgr] removeUnusedTextures];
[[TextureMgr sharedTextureMgr] removeAllTextures];
there is no effect.
Please help! I'm gonna crazy with this...
-I can't use BitmapFont because I need to scale it and for the small fonts it looks too bad.
- I don't want to use UILabel directly becuase this is the text in the game.
Thanks.