Assets.font
luastra/assetsAssets.font(id: string): Font
Creates a typed reference to a font declared by the project manifest. The result distinguishes font resources from images and audio before a host attempts to consume them.
Before you use it
Add luastra/assets to this module's dependencies in luastra.json, then import it with require("luastra/assets"). Declare the referenced file in luastra.json with its stable asset id and admitted media type. Image assets are PNG, JPEG, WebP, or AVIF; audio assets and WOFF2 fonts use their own declared types.
How it fits
The constructor validates an asset id and returns a typed reference synchronously. It does not read a file. Assets.uri exposes the packaged asset URI for a consuming UI or Media API.
When to use it
Use Assets.font when a supported styling or host workflow requests a packaged font reference. Keep font licensing and the manifest declaration alongside the asset; creating the reference alone does not apply the font to text.
Parameters
| Parameter | Type / values | Description |
|---|---|---|
| id | string | Manifest asset ID whose declared media type is an admitted font. |
Returns
Font — a typed font reference admitted from the project manifest.
What happens next
A checked reference or canonical asset URI that a compatible API can consume.
Failures and fixes
A malformed id, missing manifest entry, wrong media kind, unsupported media type, or missing source file fails during project checking or packaging. Assets.font can be applied through UI.TextStyle in the 0.3 source SDK. A missing or wrong-kind font fails when the rendered tree resolves its asset; a failed browser font decode/load retains the selected fallback.
Availability
Public-source alpha API in 0.5.0-alpha; supported consumers vary by asset kind.
Focused example
local Assets = require("luastra/assets")
local displayFont = Assets.font("font/display")