LavaUI docs

enum FontStore

Swift

enum FontStore

Default UI font when Text does not specify one.

Swift owns font policy (face + discrete pixel size). The same (path, pixelSize) is registered with the engine so measure and draw share one FreeType face. C++ never picks a default.

Scale changes re-load/register a face, clear layout caches, and require the app to re-setRoot + Yoga (library: call apply then dirty layout).

Sources/LavaUI/Font.swift:935

Properties

nonisolated(unsafe) static var assetsRoot: String?

Assets root last used by bootstrap / apply (needed to reload sizes).

Sources/LavaUI/Font.swift:948

nonisolated(unsafe) static var `default`: UIFont?

App-wide default face — UI thread only. Environment.current.font falls through to this wherever no .font(_:) override is in scope.

Sources/LavaUI/Font.swift:938

nonisolated(unsafe) static var metricsGeneration: UInt64 { get }

Bumped whenever the active face changes size, so the run loop knows the text measurements Yoga cached are stale.

A counter rather than a callback because the fix has to work for any caller. Invalidating text metrics needs the LayoutHost, which only LavaApp.run has — so before this, the one key handler that knew to call host.invalidateTextMetrics() was the only place zoom worked correctly. A menu item, a button, or an agent script calling zoomIn(into:) changed the font and left the layout measured for the old one.

Sources/LavaUI/Font.swift:964

nonisolated(unsafe) static var scale: ContentScale

Active discrete scale (library state).

Sources/LavaUI/Font.swift:945

nonisolated(unsafe) static var symbols: UIFont?

Symbol face for media / geometric glyphs (▶ ⏸ …). Prefer this over default for icon labels; OpenSans does not cover those codepoints.

Sources/LavaUI/Font.swift:942

nonisolated(unsafe) static var system: UIFont?

Broad-coverage system face used as the last fallback tier, when the machine has one. Never the primary — see loadSystemFallback.

Sources/LavaUI/Font.swift:952

nonisolated(unsafe) static var ui: UIFont? { get set }

Back-compat alias.

Sources/LavaUI/Font.swift:972

Methods

@discardableResult static func apply(scale newScale: ContentScale, into editor: Editor?) -> UIFont?

Install scale's pixel size as FontStore.default, register with the engine, and drop measure/shape caches that referenced the old size. Also reloads symbols at the same pixel size. Returns the new default face, or nil on load failure (keeps previous).

Sources/LavaUI/Font.swift:994

@discardableResult static func bootstrap(assetsRoot: String, pixelSize: Float = 16, into editor: Editor? = nil) -> UIFont?

Load default + symbols faces under assetsRoot and register with the engine.

Sources/LavaUI/Font.swift:979

@discardableResult static func resetScale(into editor: Editor?) -> Bool

Return to multiplier 1.0. true if the scale (and face) changed.

Sources/LavaUI/Font.swift:1075

@discardableResult static func zoomIn(into editor: Editor?) -> Bool

Step up one discrete size. true if the scale (and face) changed.

Sources/LavaUI/Font.swift:1059

@discardableResult static func zoomOut(into editor: Editor?) -> Bool

Step down one discrete size. true if the scale (and face) changed.

Sources/LavaUI/Font.swift:1067