I wanted to share this simple class to generate the bitmap fonts at runtime.
This is a SUPER simple/unoptimized utility. Something that can be done with Littera, BMFont, etc or even the DynamicTextureAtlas... but with much less functionality
But, as I faced so many issues through the projects with those solutions (incompatible fonts formats, Java rendering issues, wrong metrics on the xml, poor bitmap rendering, inability to pack multiple fonts at once, etc). I decided it was time to built something useful to me...
Github repo with some examples in it.
I'll try to extend/explain the internals on the github repo later (if someone find this useful).
The cool thing about it, is that you can pack multiple fonts in 1 atlas. And it uses the good old Flash TextField to draw the characters and calculate the metrics. Therefore, the representation of the characters are really decent (didn't test it much).
I'd really like to add a DistanceField generation, but it will not be usable at runtime, as it takes forever to generate a proper atlas for production, maybe in an app... like Littera does.
The bad thing, is that it requires embedded fonts, in order to render the atlas properly and calculate kerning values. So, u'll have to create a project inside your project just to output the font atlases. Although, according to your needs maybe it'll work just fine with Device fonts.
Anyway, let me know what u think, or if u have any feature request.
- I just updated the github repo with code and screenshots to make it more "appealing".
- Added the option to pack rotated glyphs, you can change 1 line in BitmapText.as to make it work, is commented in the DemoBuildAtlas.as line 62, but i don't know if it breaks batching or hurts performance.
- Added Signed Distance Field via DFS.as, not integrated into FAB, but you can generate some the textures out of Sprites, bitmapDatas, etc. Pretty generic and async.
- Added smart autoSize for the canvas in FAB.
So there's no need to define an initial size, just pass -1 for width, height or both to apply autoSize, and have total control over the increment of that value, power of 2 restrictions, and "smart axis auto size" to toggle the passes for width/height to avoid an square output, all to accomplish a more compressed atlas
- Now you can define chars PER fontStyle