Bitmap font tutorial for windows

Monkey Forums/Monkey Programming/Bitmap font tutorial for windows

christianstrang(Posted 2012) [#1]
I'm messing around with fantomengine and the "CreateText" method for the last couple of hours, but I'm making no progress. I installed the "Bitmap font generator" and tried to create a font which would display in my app, but nothing so far.

Is there some kind of tutorial/step-by-step guide on how to create a bitmap font that works with fantomengine?


Jesse(Posted 2012) [#2]
I don't know for sure but he probably explains it in his book:
http://link.packtpub.com/Nh4hMA


christianstrang(Posted 2012) [#3]
Well, sometimes you just have to sleep on it :D

Not sure why it didn't work yesterday, but today it works just fine, here are my settings if somebody is struggling as well:







Now go to "Options -> Save Bitmap Font as"

After that you will get one or multiple ".png"-files and a ".fnt"-File. Rename the ".fnt"-filetype to ".txt", copy all the files that were generated into your GAMENAME.data folder and you are done :)


MikeHart(Posted 2012) [#4]
I am glad you got it working. Where did you find that tool? So I can place a link into the fE Wiki?


vmakar85(Posted 2012) [#5]
@christianstrang thx it's work.


Jesse(Posted 2012) [#6]
you can download the installer from here:
http://www.angelcode.com/products/bmfont/


vmakar85(Posted 2012) [#7]
It looks for the Russian (add Cyrilic) language does not work, ie. I can get a picture with Russian characters and a text file from bmfont program, but something goes wrong, and when i try to run it on android me an error, on html work fine
(use v66 with fEng )


christianstrang(Posted 2012) [#8]
I tried it myself and I also get an "Array index out of range" error message (tested in HTML5)


MikeHart(Posted 2012) [#9]
Can you provide the font files and a test script so I can see if I can do something about it in fantomEngine?


DarkyCrystal(Posted 2012) [#10]
I tested this software, but I don't like it because I can't have some colored font easly or may be I don't know how to use it.


christianstrang(Posted 2012) [#11]
@MikeHart: If the "char id=" is bigger than 255, for example "char id=256" it crashes. Basically if you select anything except "Latin + Latin Supplement" its going to crash, at least in my environment. Hope that helps to track down the issue :)

@DarkCrystal: Which software are you using? I'm on windows so I can't use GlyphDesigner :(


MikeHart(Posted 2012) [#12]
@christinastrang: I know, was just hoping you could provide a test script and files for my bug hunting. This way I safe time for downloading the software, learn how to use it, and and and! :-) time is money and I don't make any from it :-)


christianstrang(Posted 2012) [#13]
Ah, gotcha sorry!

https://dl.dropbox.com/u/49348646/works.zip
https://dl.dropbox.com/u/49348646/fails.zip

Its enough to load the font to crash it (without using it):
font1 = eng.LoadFont("test_font")


Which software do you use to create bitmap fonts?


MikeHart(Posted 2012) [#14]
Thanks for the files.

I am on a iMac and there I use GlyphDesigner. Love it! But of course, there is need to support other tools as well.


MikeHart(Posted 2012) [#15]
Mmmh, the fails files can be loaded without an error. I wonder why. Will look into this. These are good too, because I didn't thought about supporting bitmap fonts spread over several images.


MikeHart(Posted 2012) [#16]
Dooh, found my mistake and it crashes.


vmakar85(Posted 2012) [#17]
@MikeHart so any chans to get it work with chr id = 1071 =) ??


MikeHart(Posted 2012) [#18]
Please test this cftFont.monkey file:

https://dl.dropbox.com/u/23622899/cftFont.monkey

Let me know if it worked.


vmakar85(Posted 2012) [#19]
@MikeHart awesome, on my sony phone work fine.. many thx

checked to be working:
HTML ( chrom )
GLFW
Android
XNA
FLASH

can't check on iDevice =)


christianstrang(Posted 2012) [#20]
Works like a charm (also tested it with cyrillic characters)! :D

What is the limit of this though? I generated a file-collection with all the languages BMFont had to offer (2920 characters - 13 .png-files) and managed to crash it again (sorry!). I tried increasing the array limits to "4096" in the cftFont.monkey file but that didn't fix it.

Thank you for your fast reponse and your help, I really appreciate it!


christianstrang(Posted 2012) [#21]
Ah, I think its because the generated .txt file contains ID's that are over 917000 (no idea why the ID's are generated this way). I uploaded the .zip file if you are curious:

https://dl.dropbox.com/u/49348646/all.data.zip


MikeHart(Posted 2012) [#22]
You are crazy, that would be a memory monster. How many atlas files where defined?


MikeHart(Posted 2012) [#23]
I will look into this tommorow.


christianstrang(Posted 2012) [#24]
I think its just a flaw of BMFont on how it generates the ID's. Don't worry, I won't need this anyway, I'm fine with the latin characters and a few additional ones, but those work with the update :)


vmakar85(Posted 2012) [#25]
@christianstrang can i repost ( and translate ) youer tutorial to http://monkeycoder.ru/


christianstrang(Posted 2012) [#26]
sure :)


MikeHart(Posted 2012) [#27]
Could you please test if the ASC value returns that high value too? If it does, then i can try to support it.


christianstrang(Posted 2012) [#28]
Not sure what you mean


MikeHart(Posted 2012) [#29]
That character, that has that 917000 value, will that return a similar ASC value? Because to detect which Character has to be printed, I read from a text each character, determine its ASC value, and then find the corresponding bitmap. If Monkey doesn't support unicode, then I don't see a possibility atm, to support these characters.


MikeHart(Posted 2012) [#30]
Ok, I have put the ftFont class into a blender, spinned it backwards, shaked and stirred it for 20 minutes and now I have fantomEngine supporting unlimited bitmap font images and characters. As long as you have enough memory. :-)
I had to switch to a IntMap to store the single characters, but now it doesn't grab a new image for a char anymore but draws directly from the bitmap file. I hope it increases the drawing performance, or at least doesn't make it worse. Grab the file here:

http://code.google.com/p/fantomengine/downloads/list