SetFont

Syntax

Parameters

Example

window = Window:Create()
context = Context:Create(window)
local font = Font:Load("Fonts/Arial.ttf",48)
context:SetFont(font)

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

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

--Draw some text centered on the screen
local text = "Hello!"

local x = context:GetWidth()/2
local y = context:GetHeight()/2

x = x - font:GetTextWidth(text)/2
y = y - font:GetHeight()/2

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

context:Sync()
end