Difference between revisions of "love.graphics.newFont"
Line 8: | Line 8: | ||
=== Arguments === | === Arguments === | ||
{{param|string|filename|The filepath to the font file.}} | {{param|string|filename|The filepath to the font file.}} | ||
+ | {{param|number|size (12)|The size of the font in pixels.}} | ||
+ | === Returns === | ||
+ | {{param|Font|font|A Font object which can be used to draw text on screen.}} | ||
+ | == Function == | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | font = love.graphics.newFont( file, size ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|File|file|A File pointing to a font.}} | ||
+ | {{param|number|size (12)|The size of the font in pixels.}} | ||
+ | === Returns === | ||
+ | {{param|Font|font|A Font object which can be used to draw text on screen.}} | ||
+ | == Function == | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | font = love.graphics.newFont( data, size ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|Data|data|The encoded data to decode into a font.}} | ||
{{param|number|size (12)|The size of the font in pixels.}} | {{param|number|size (12)|The size of the font in pixels.}} | ||
=== Returns === | === Returns === |
Revision as of 18:34, 4 October 2012
Creates a new Font.
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! |
Contents
Function
Synopsis
font = love.graphics.newFont( filename, size )
Arguments
Returns
Font font
- A Font object which can be used to draw text on screen.
Function
Synopsis
font = love.graphics.newFont( file, size )
Arguments
Returns
Font font
- A Font object which can be used to draw text on screen.
Function
Synopsis
font = love.graphics.newFont( data, size )
Arguments
Returns
Font font
- A Font object which can be used to draw text on screen.
Function
This variant uses the default font (Vera Sans) with a custom size.
Synopsis
font = love.graphics.newFont( size )
Arguments
number size (12)
- The size of the font in pixels.
Returns
Font font
- A Font object which can be used to draw text on screen.
Examples
Use newFont to draw a custom styled text
-- load ttf file font. set 20px font-size
mainFont = love.graphics.newFont("anyfont.ttf", 20);
function love.draw()
-- set font before draw text
love.graphics.setFont(mainFont);
-- draw text "Hello world!" at left: 100, top: 200
love.graphics.print("Hello world!", 100, 200);
end;
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info