Load

Loads a font from a True-Type Font (.ttf) file.

Syntax

Parameters

Returns

Returns the loaded Font. If the Font cannot be loaded, NULL is returned.

Remarks

Fonts can be loaded with either the Font::Smooth or Font::Pixel settings.

At this time, only the Font::English character set is supported. Additional character sets may be supported in the future.

If the flags parameter includes value Asset::Unmanaged, a unique asset will be loaded from the file. Otherwise, an instance of the Asset will be returned, if it is already in system memory.

Example

window=Window:Create()
context=Context:Create(window)
font = Font:Load("Fonts/arial.ttf",36)
context:SetFont(font)


while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

context:SetColor(0,0,0)
context:Clear()
context:SetColor(1,1,1)

--Display some centered text
local text = "Leadwerks"
local screenwidth = window:GetWidth()
local screenheight = window:GetHeight()
local x = (screenwidth - font:GetTextWidth(text))/2
local y = (screenheight - font:GetHeight())/2

context:SetBlendMode(Blend.Alpha)
context:DrawText(text,x,y)
context:SetBlendMode(Blend.Solid)

context:Sync()
end