DrawFont.Register Synchronous

Register font-file bytes and receive a handle you can assign to the Font property of a Text drawing. Use it when built-in fonts do not fit the text you want to display.

Syntax
Luau
DrawFont.Register(bytes: string, options: {PixelSize: number}) -> DrawFont?

Parameters

Function parameters
ParameterTypeDescription
bytesstringRaw font-file bytes, such as readfile("fonts/interface.ttf").
options{PixelSize: number}Table with a positive, finite PixelSize.

Returns

DrawFont?

A DrawFont handle, or nil if the font bytes fail validation.

Usage notes

Missing or invalid PixelSize raises an error. Check the returned handle before assigning it; rendering also depends on Android font support.

Drawing.new("Font") is a separate font-resource path.

Differences from Volt

Volt describes loading font data while rebuilding a font atlas. Kawaii returns its handle synchronously after validating the input; registration alone does not establish that the Android renderer supports every feature of the font.

Example

Example
Luau
if isfile("fonts/interface.ttf") then
    local font = DrawFont.Register(readfile("fonts/interface.ttf"), { PixelSize = 18 })
    if font then
        local label = Drawing.new("Text")
        label.Font = font
        label.Text = "Custom font"
        label.Size = 18
        label.Position = Vector2.new(40, 40)
        label.Visible = true
        task.delay(5, function() label:Remove() end)
    end
end
Kawaii documentation