With the announcement of Public Release 2830 comes changes to how fonts are loaded/displayed.
Previously, the usage of custom fonts was dependent on the operating system and the type of font being used. Sometimes you would need to use a font’s file name and other times you would use the “internal font name.” Many developers made things easier on themselves by ensuring the font file name and the internal font name matched.
Now, you can simply use the font file name + extension. This is consistent across all platforms except Windows Phone 8.
For example, to display a custom font where the file name is superfont.ttf
, simply use:
local myText = display.newText( "Hello World!", 100, 200, "superfont.ttf", 16 )
Windows Phone 8 still has a different requirement which is "#"
. Example:
local myText = display.newText( "Hello World!", 100, 200, "superfont.ttf#Super Font Regular", 16 )
To simplify working with fonts, you should adopt this new method of loading custom fonts moving forward.