3
votes

I can't add any .fnt/.png type of fonts to SpriteBuilder, so I can't select them for a CCLabelBMFont. What is the procedure? The docs seem to have nothing on the matter.

I am using this font:

https://github.com/cocos2d/cocos2d-iphone/blob/v3.1/Resources/Fonts/arial16.fnt https://github.com/cocos2d/cocos2d-iphone/blob/v3.1/Resources/Fonts/arial16.png

Update: seems to be no real good solution at this point, except workarounds like:

  • Don't use SpriteBuilder when dealing with CCLabelBMFont, after all you CAN use the arial16 font if you do it from code. It's a shame SB doesn't support a font that is "bundled" with existing Cocos2D. Of course there are probably good reasons...

  • In my case I just use a CCLayoutBox and add fixed-sized character sprites to it, not using any font classes at all. It's actually really fast and enough to make a countdown timer etc.

2
It's a good question that doesn't have an answer (yet). You may want to follow the discussion here: github.com/spritebuilder/SpriteBuilder/issues/98 Supposedly the problem stems from using the wrong extension but I also tried .bmFont and .bmfont without luck. github.com/spritebuilder/SpriteBuilder/pull/529LearnCocos2D
It should be a pretty pressing issue. Updating a CCLabelTTF in update for something like a countdown timer, including hundreds of a second, somehow makes memory usage kill your app very quickly. Of course CCLabelTTF was not designed for this purpose, but there seems to be no other way... well, except using CCLabelBMFont, but defining it in code, NOT using SpriteBuilder. SpriteBuilder is nice but it cannot ignore these things... it should not constrain existing functionality of Cocos2D, imho.Jonny

2 Answers

0
votes

If you have GlyphDesigner, you can use my bash script to convert the .GlyphProject file to the .bmfont font structure needed by SpriteBuilder.

You can check out my post here: Bash script to generate CCLabelBMFont bmfont files for use with SpriteBuilder using GlyphDesigner’s command line tool

-1
votes

I found this in the old SpriteBuilder documentation.

Apparently you need to create a subfolder with the extension .bmfont containing subfolders named "resource-xxxx" with resolution-specific versions of the bitmap font.

enter image description here

Only bmGlyph currently support this format through Publish -> Publish Wizard. In other tools you'll have to export your font to the myfont.bmfont/resources-tablethd folder with a given font size, say 64. Then re-export it to resources-table and resources-phonehd with font size 32, and publish it once more to resources-phone with font size 16.

The actual scaling for phone(hd) are not exactly 50%/25%, see the bmGlyph publish wizard: enter image description here

I haven't tried this but this should generally be the way to do it. I don't know if all resource folders are required or if you can also use the resources-auto folder.