Creates a new [[Font]] by loading a [[ImageFontFormat|specifically formatted]] image.

In versions prior to [[0.9.0]], LÖVE expects ISO 8859-1 encoding for the glyphs string.

{{newobjectnotice}}
== Function ==
=== Synopsis ===
<source lang="lua">
font = love.graphics.newImageFont( filename, glyphs )
</source>
=== Arguments ===
{{param|string|filename|The filepath to the image file.}}
{{param|string|glyphs|A string of the characters in the image in order from left to right.}}
=== Returns ===
{{param|Font|font|A Font object which can be used to draw text on screen.}}

== Function ==
=== Synopsis ===
<source lang="lua">
font = love.graphics.newImageFont( imagedata, glyphs )
</source>
=== Arguments ===
{{param|ImageData|imageData|The ImageData object to create the font from.}}
{{param|string|glyphs|A string of the characters in the image in order from left to right.}}
=== Returns ===
{{param|Font|font|A Font object which can be used to draw text on screen.}}

== Function ==
{{newin|[[0.10.0]]|100|type=variant}}
=== Synopsis ===
<source lang="lua">
font = love.graphics.newImageFont( filename, glyphs, extraspacing )
</source>
=== Arguments ===
{{param|string|filename|The filepath to the image file.}}
{{param|string|glyphs|A string of the characters in the image in order from left to right.}}
{{param|number|extraspacing|Additional spacing (positive or negative) to apply to each glyph in the Font.}}
=== Returns ===
{{param|Font|font|A Font object which can be used to draw text on screen.}}

== Notes ==
Instead of using this function, consider using a BMFont generator such as [http://www.angelcode.com/products/bmfont/ bmfont], [http://kvazars.com/littera/ littera], or [https://www.bmglyph.com/ bmGlyph] with [[love.graphics.newFont]]. Because slime said it was better.

== Examples ==
Creating a simple image font. Download this [[:File:font_example.png|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.
<source lang="lua">
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
</source>

== See Also ==
* [[parent::love.graphics]]
* [[Constructs::Font]]
* [[ImageFontFormat | Image Font Format]]
[[Category:Functions]]
[[Sub-Category::Object Creation| ]]
{{#set:Description=Creates a new [[Font]] by loading a specifically formatted image.}}
{{#set:Since=020}}
{{#set:PrettySince=0.2.0}}
== Other Languages ==
{{i18n|love.graphics.newImageFont}}