Creates a new Font by loading a specifically formatted image.
In versions prior to 0.9.0, LÖVE expects ISO 8859-1 encoding for the glyphs string.
![]() |
This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused! |
font = love.graphics.newImageFont( filename, glyphs )
string filename
string glyphs
Font font
font = love.graphics.newImageFont( imagedata, glyphs )
ImageData imageData
string glyphs
Font font
Available since LÖVE 0.10.0 |
This variant is not supported in earlier versions. |
font = love.graphics.newImageFont( filename, glyphs, extraspacing )
string filename
string glyphs
number extraspacing
Font font
Instead of using this function, consider using a BMFont generator such as bmfont, littera, or bmGlyph with love.graphics.newFont. Because slime said it was better.
Creating a simple image font. Download this image file which will be used by LÖVE to create the font. Obviously when you want to create a font for your game you want to make the background transparent.
local font = love.graphics.newImageFont( 'font_example.png', ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ) function love.draw() love.graphics.setFont( font ) love.graphics.print( 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 16, 16 ) love.graphics.print( 'Text is now drawn using the font', 16, 32 ) end