Page 1 of 1

Tool: simple love2d image fonts

Posted: Sat Feb 13, 2021 2:07 am
by davidkonsumer
I made a simple little html tool for assembling image-fonts, as I need extended characters quickly. You can use it online, or locally (with attached file). The main thing that is different from other tools is you need those lines to tell love how spacing works.

https://lovefont.surge.sh/

* open the tool in a browser
* set the characters you want in the first box
* set the font (it's CSS-style, so like "16px monospace") more fonts may be added later, but for now, it's just the fonts built-in to your browser, and whatever you have installed on your system (by name). The input box will match the style so you can see it without the the lines.
* set text (black) and spacer (red) colors to something different from each other. The can be anything, they just need to be different, so I use red for black text.
* Click download to save the font-image

You can use it in your code, like this:

Code: Select all

local font = love.graphics.newImageFont( "font.png", [[ ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=_+!@#$%^&*()[]{}\|;':",./<>?↥↧↤↦]] )
love.graphics.setFont( font )
love.graphics.setBackgroundColor( 1,1,1,1 )

function love.draw()
    love.graphics.print( "This is a test of the font. ↥↧↧↧", 0, 0 )
end
Just make sure the character-set is the same as you entered in the tool , and I use [[TEXT]] to not have to worry about escaping it.