nLove, Dingoo and fonts

For anyone who’s been following my twitter feed you may know that I’ve been starting to develop a game in Lua and LOVE, a 2D game engine. After messing about with LOVE I found out that there was a version of love2D for the dingoo, canoo and gp2x called nLove. This is a great library that allows me to develop a game on my mac, using LOVE and then run it on my dingoo using nLove.

After making a few examples I decided to use a font I created myself, and have this displayed in the game. LOVE and nLove both support this, however it seems that there’s a bug in the nLove implementation where the user defined font is not displayed correctly, or at all. So, I’ve created a quick module that allows you to pass in a font image and a table of characters that are represented in the image.

Note that this does require the LOVE framework

Here’s the code as well as an example of how to use it:

And here’s an example of a font image to pass in:

Font_complete

Use the code as you wish, I haven’t been using lua for so long though so I can’t guarantee it’s bug free!

Update 1:

I’ve now updated the code so that you can use multiple fonts. See above for usage.

David Roberts

Read more posts by this author.

Newcastle upon Tyne, UK https://davidatroberts.github.io/