Edited January 15th, 2015.
This code is for those who, like me, don't want to spend money on Glyph Designer, bmGlyph, Text Candy, or any other bitmap font tool for Corona SDK.
I ran into a piece of code written by Aaron Meriwether (a.k.a. 'p120ph37') that was modified by Michael Wilson who removed the legacy Sprite library and switched to a modular class. Albeit messy, this code had all of the features I was looking for. I simply cleaned it up a little bit, removed some unnecessary lines of code, fixed some issues with the alignment and, most importantly, added a dynamic font selection feature. This means devices with higher resolutions will use higher resolution images.
Screen Shot 2014-11-24 at 12.29.59 PM.png 50.48KB 10 downloads
It's very easy to use. Simply require the module, load a font, and print a string. Lines of text are handled as groups and they share the same properties.
Here's the code example in the screenshot.
local bmf = require('bmf') local centerX = display.contentCenterX local centerY = display.contentCenterY local width = display.contentWidth local height = display.contentHeight local rect = display.newRect(centerX, centerY, width, height) rect:setFillColor(0.5,0.78,1) local font = bmf:load('SourceSansProSemibold18') local str = bmf:newString(font, '<-- Right Align') str.align = 'right' str:translate(centerX, centerY - 27) local str2 = bmf:newString(font, '<-- Center Align -->') str2.align = 'center' str2:translate(centerX, centerY - 9) local str3 = bmf:newString(font, 'Left Align -->') str3.align = 'left' str3:translate(centerX, centerY + 9)
local str = bmf:newString(group, font, 'Hello Corona!')