Builtin Library
README.md
text
Text rasterisation resource. Create a text handle, set its content and style, then rasterise it into a runtime GPU texture you own. A handle owns a glyph layout plus raster; Text3D builds one per label, rasterises it into its texture, and shows it on a quad whose material binds that texture.
Exports
text.create(options) -> any— create a handle from an initial content + style table (contentplusfontSize,color,alignment,richText,maxWidth, ...). Returns an opaque handle passed to every other call.text.setText(handle, content)— replace the handle's text content.text.setStyle(handle, style)— replace the handle's style; fields not present keep their current value.text.rasterize(handle, texture, scale?) -> any— rasterise current text + style into the given GPU texture (arenderer.texture.createhandle or its guid); returns{ width, height }(pixels). Re-rasterising the same texture overwrites it in place.text.measure(handle) -> any— measure the rasterised text in pixels without producing a texture; returns{ width, height }.text.destroy(handle)— release the handle's raster + glyph layout.text.listFonts() -> { string }— font families currently available.text.loadFont(ref) -> any— load a font from an asset reference so it becomes available tosetStyle'sfontFamily; returns the loaded family name.
Usage
local text = require("@builtin::modules.api.engine.text")
local h = text.create({ content = "Hello", fontSize = 48 })
local tex = renderer.texture.create({ width = 1, height = 1, rgba = string.char(0, 0, 0, 0), name = "label" })
text.rasterize(h, tex, 1.0)
-- bind tex.guid as a material texture (base_color_texture) to display it