Creates a new Font from a TrueType Font or BMFont file. Created fonts are not cached, in that calling this function with the same arguments will always create a new Font object.
All variants which accept a filename can also accept a Data object instead.
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!
Create a new BMFont or TrueType font.
font = love.graphics.newFont( filename )
string filenameFont fontIf the file is a TrueType font, it will be size 12. Use the variant below to create a TrueType font with a custom size.
Create a new TrueType font.
font = love.graphics.newFont( filename, size, hinting, dpiscale )
HintingMode hinting ("normal") Available since 0.10.0
number dpiscale (love.graphics.getDPIScale()) Available since 11.0
Font fontCreate a new BMFont.
font = love.graphics.newFont( filename, imagefilename )
string filenamestring imagefilenameFont fontCreate a new instance of the default font (Vera Sans) with a custom size.
font = love.graphics.newFont( size, hinting, dpiscale )
number size (12)HintingMode hinting ("normal") Available since 0.10.0
number dpiscale (love.graphics.getDPIScale()) Available since 11.0
Font font-- Create a ttf file font with a custom size of 20 pixels.
mainFont = love.graphics.newFont("anyfont.ttf", 20)
function love.draw()
-- Setting the font so that it is used when drawning the string.
love.graphics.setFont(mainFont)
-- Draws "Hello world!" at position x: 100, y: 200 with the custom font applied.
love.graphics.print("Hello world!", 100, 200)
end
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.graphics.newFont