Corona SDK – Use custom Fonts

I the last days I have been looking how to include a custom font within my game with the Corona SDK. Its pretty easy but it took my some research to find out how to do it. In this short post I will show you how can include custom fonts. First I downloaded a free custom font via http://www.1001freefonts.com/bitmap-pixel-fonts.php

I downloaded the Arcade.ttf. Copy/paste or drag and drop this Arcade.ttf (or any other custom font) into your project folder. Sometimes a certain font needs to be first installed on your PC to make it visible in the Corona Simulator. I’m a MAC OS users, if you are as well, double click the downloaded font and install the font on your i-Machine. In case you use a Windows machine, I can refer you to this Microsoft reference: http://windows.microsoft.com/en-ca/windows-vista/install-or-uninstall-fonts

In your newText (API from Corona to create text) refer to your Arcade font

gameovertxt = display.newText(  "Game Over", cWidth-110, cHeight-100, "Arcade", 50 )

Now the tricky part is that you also need to make a change in your build.settings

settings = {
	orientation =
	{
		default = "portrait",
	},
	iphone =
	{
		plist=
		{
			UIAppFonts = { "Arcade.ttf"  }
			--UIStatusBarHidden=true,
		},
	},
}

For more information, especially on making the fonts work on different devices, continue to read on the CoronaLabs website http://www.coronalabs.com/blog/2011/07/13/custom-fonts-corona/

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*