DRAWING FUNCTIONS

LoadFontFromBuffer

Loads a font from an in-memory buffer.

Syntax

local fontId, err = ONYX.LoadFontFromBuffer(data, size_px)

Parameters

  • data (string) — Raw font bytes (TTF/OTF).
  • size_px (number) — Native pixel size to bake into the atlas.

Return(s)

fontId (number) — handle for PushFont; on error nil and a string message.

Behavior

  • The atlas copies the bytes, so the input buffer can be released.
  • Loading a font does not change the active font; use PushFont to activate it.
  • Pass size_px 0 to DrawText to render at this font native size.

Example(s)

local fontId = ONYX.LoadFontFromBuffer(bytes, 20)
ONYX.PushFont(fontId)
ONYX.BeginFrame()
ONYX.DrawText(120, 100, "ONYXS", 0, 1, 1, 1, 1)
ONYX.SubmitFrame()
ONYX.PopFont()