开发者

Custom Font in Android - Simple and Cheap Method

I'm making an Android game, and I want to use a custom font for the score counter.

1) From what I've found I can use a ttf file to easily implement a custom font, but creating a ttf file requires an expensive program.

开发者_StackOverflow社区2) Since it's mainly numbers, and thus only ten images, maybe I can implement it myself. For that, is there a method that can take an int and return a portion of the number, like String.substring()? Or would it be simpler to just transform the number into a string and then parse out the individual numbers?

3) A possibility I haven't considered yet?


1) There are some tools online to create fonts for free, but they might not provide the control over your font that you are looking for. Of the two mentioned in the article I linked to, FontStruct seems simpler and more intuitive, while FontForge seems more powerful. If one of these suits your needs, I imagine it would be less of a resource hog than dealing with 10 individual images.

2) You could definitely implement this. Both Strings and CharSequences have charAt(int index) functions that allow you to access the individual characters. You could use a loop to test each individual character and show the appropriate image. String.substring(start, end) does return a portion of the original string, but I'm unsure of how that would help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜