PDA

View Full Version : How to display numbers in Custom image fonts



SlaynX
18th June 2011, 17:52
Hi there,

I was wondering how do you display numbers (Let say a whole number 32412) in a custom image fonts. I got the images that display 0 to 9. I was thinking of getting the each number position and display it with the custom image font that I created but I'm not sure whether this is memory sufficient. Any suggestions? Thank you.

SixDegrees
18th June 2011, 19:28
There are many ways to do this. One straightforward approach: convert the number to a string; step through the string one character at a time. Arrange for your numeric images to have names like "imageX.png" where 'X' is the number it represents, like 'image3.png'. Now, append your character to "image" and append ".png" to that, and you're done.

You can also convert the character back to an integer and store your images or their names in a suitably arranged array. You could also skip the integer/string conversion altogether with some minor arithmetic.