O'Reilly logo

Lua Game Development Cookbook by Mário Kašuba

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading and using bitmap fonts

Bitmap fonts are used mainly with monospaced fonts. Mainly, that's because you can evenly divide bitmap into rectangular areas. Each of these areas contains one font character. Usually, such font characters are sorted by ASCII coding or use a part of this coding. Once you have loaded the image file with the bitmap font, you can easily access each font character finding its rectangular coordinates. These coordinates can be stored in a Lua table which makes character lookup fast. This kind of font is quite popular mainly because each font character has equal spacing between characters, so you don't have to handle problems with font kerning.

The following example shows a bitmap font stored in an image:

This recipe will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required