LoadFontFromBuffer
Load a TTF/OTF font into ImGui and return its handle.
Syntax
Susano.LoadFontFromBuffer(data, size_px) -> number
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 Susano.PushFont.
On error: nil, err (string).
Behavior
Adds the font to the renderer atlas; the atlas owns the copied bytes.
Loading a font does not change the active font. Use Susano.PushFont(fontId) to use it.
In Susano.DrawText, pass 0 for size to render at this font’s native size_px; non-zero scales at draw time.
If loaded at runtime, it becomes usable after the atlas is uploaded by the renderer (typically next frame).
Example(s)
local bytes = "" -- font buffer
local id, err = Susano.LoadFontFromBuffer(bytes, 20)
assert(id, err)
Susano.PushFont(id)
Susano.BeginFrame()
Susano.DrawText(1200, 100, "Consolas @ native", 0, 1,1,1,1) -- 0 => native 20px
Susano.SubmitFrame()
Susano.PopFont()