Difference between revisions of "love.graphics.newImageFont"

m (Replace newin with PrettySince)
Line 1: Line 1:
{{newin|[[0.2.0]]|020|type=function}}
+
Creates a new font by loading a [[ImageFontFormat|specifically formatted]] image. There can be up to 256 glyphs.
Creates a new [[Font]] by loading a [[ImageFontFormat|specifically formatted]] image. There can be up to 256 glyphs.
 
 
 
In versions prior to [[0.9.0]], LÖVE expects ISO 8859-1 encoding for the glyphs string.
 
 
 
 
{{newobjectnotice}}
 
{{newobjectnotice}}
 +
{{notice|LÖVE expects ISO 8859-1 encoding for the glyphs string.}}
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 15: Line 12:
 
=== Returns ===
 
=== Returns ===
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
 
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
font = love.graphics.newImageFont( image, glyphs )
+
font = love.graphics.newImageFont( file, glyphs )
 +
</source>
 +
=== Arguments ===
 +
{{param|File|file|A File pointing to an image.}}
 +
{{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( data, glyphs )
 +
</source>
 +
=== Arguments ===
 +
{{param|Data|data|The encoded data to decode into image data.}}
 +
{{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>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|Image|image|The Image object to create the font from.}}
+
{{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.}}
 
{{param|string|glyphs|A string of the characters in the image in order from left to right.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
 
 
== Function ==
 
== Function ==
{{newin|[[0.10.0]]|100|type=variant}}
 
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
font = love.graphics.newImageFont( filename, glyphs, extraspacing )
+
font = love.graphics.newImageFont( image, glyphs )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|string|filename|The filepath to the image file.}}
+
{{param|Image|image|The Image object to create the font from.}}
 
{{param|string|glyphs|A string of the characters in the image in order from left to right.}}
 
{{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 ===
 
=== Returns ===
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
 
{{param|Font|font|A Font object which can be used to draw text on screen.}}
Line 44: Line 57:
 
* [[ImageFontFormat | Image Font Format]]
 
* [[ImageFontFormat | Image Font Format]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Sub-Category::Object Creation| ]]
+
{{#set:Description=Creates a new font by loading a specifically formatted image.}}
{{#set:Description=Creates a new [[Font]] by loading a specifically formatted image.}}
 
 
{{#set:Since=000}}
 
{{#set:Since=000}}
 +
{{#set:PrettySince=0.2.0}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics.newImageFont}}
 
{{i18n|love.graphics.newImageFont}}

Revision as of 10:21, 27 December 2015

Creates a new font by loading a specifically formatted image. There can be up to 256 glyphs.

O.png 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!  



O.png LÖVE expects ISO 8859-1 encoding for the glyphs string.  


Function

Synopsis

font = love.graphics.newImageFont( filename, glyphs )

Arguments

string filename
The filepath to the image file.
string glyphs
A string of the characters in the image in order from left to right.

Returns

Font font
A Font object which can be used to draw text on screen.

Function

Synopsis

font = love.graphics.newImageFont( file, glyphs )

Arguments

File file
A File pointing to an image.
string glyphs
A string of the characters in the image in order from left to right.

Returns

Font font
A Font object which can be used to draw text on screen.

Function

Synopsis

font = love.graphics.newImageFont( data, glyphs )

Arguments

Data data
The encoded data to decode into image data.
string glyphs
A string of the characters in the image in order from left to right.

Returns

Font font
A Font object which can be used to draw text on screen.

Function

Synopsis

font = love.graphics.newImageFont( imageData, glyphs )

Arguments

ImageData imageData
The ImageData object to create the font from.
string glyphs
A string of the characters in the image in order from left to right.

Returns

Font font
A Font object which can be used to draw text on screen.

Function

Synopsis

font = love.graphics.newImageFont( image, glyphs )

Arguments

Image image
The Image object to create the font from.
string glyphs
A string of the characters in the image in order from left to right.

Returns

Font font
A Font object which can be used to draw text on screen.

See Also


Other Languages