Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

font

Font primitive — parse a font file ONCE into a baked, vectorized glyph format (ZFNT), then drive every text surface from it. A font is a general CPU resource addressed by name (the CPU counterpart of a renderer GPU resource), so a single registration is usable from UI text, 2D text, and true 3D glyph geometry. Thin public Luau surface over the __font Internal FFI namespace; authored fonts are .font assets whose onRegister hook calls font.register.

font.parse does the heavy decode + outline extraction once (at .font import); font.register loads that baked payload into the runtime store cheaply and installs the embedded face into the shaping-based raster surfaces, so one registration resolves fontFamily = "<name>" everywhere and feeds font.glyph / font.textMesh.

Exports

  • font.parse(bytes: string) -> string? — parse raw TTF / OTF bytes into the baked ZFNT payload (binary-safe string), or nil when the bytes don't parse as a font. Heavy — run at import time, then store the result as the asset payload.
  • font.register(name: string, zfnt: string) — load a baked ZFNT payload into the runtime store under name and install its face into the raster surfaces.
  • font.glyph(...) / font.textMesh(...) — query baked glyph outlines / build 3D glyph geometry from a registered font.

Usage

local font = require("@builtin::modules.api.engine.font")

local zfnt = font.parse(vfs.read("/zero/source/Inter.ttf"))
font.register("Inter", zfnt)
-- now fontFamily = "Inter" resolves across UI text, 2D text, and 3D glyphs.