Class VelvetFonts
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Application-wide font registry backing the font-<name> / font-<weight>
utilities. Mirrors VelvetTheme's "global state + change event" shape: register
families once at startup and swap the active set at runtime (e.g. on a locale change) —
FontsChanged lets the app trigger a re-render so mounted elements re-resolve.
The registry is independent of how the master data is stored. It only consumes VelvetFontFamily values via Register(VelvetFontFamily?) / Register(IEnumerable<VelvetFontFamily>?, string?); producing those from CSV, MasterMemory, a ScriptableObject, or plain code is an adapter concern that lives outside this class.
Font Assets may be supplied directly or by Addressables key; keyed assets are loaded
synchronously and cached on first use, the same mechanism StyleBackgroundImageResolver
uses for bg-[addr:…].
public static class VelvetFonts
- Inheritance
-
objectVelvetFonts
Properties
- DefaultFamily
Family applied to elements that specify a weight/style but no explicit
font-<name>. Null or empty means "inherit the panel's default font".
Methods
- Clear()
Clears every registered family, the addressable cache, and the default family.
- IsRegistered(string?)
True when a family with the given name is registered.
- Register(IEnumerable<VelvetFontFamily>?, string?)
Registers (or replaces) a batch of families and, optionally, the DefaultFamily, raising FontsChanged once for the whole batch. This is the representation-agnostic entry point: the families can come from anywhere — built in code, a CSV importer, MasterMemory, a ScriptableObject, etc. The registry itself has no knowledge of how the master data is stored.
- Register(VelvetFontFamily?)
Registers (or replaces) a single family by its name.
- Resolve(string?, VelvetFontWeight, bool)
Resolves a font request to a ResolvedFont. When
familyis null the DefaultFamily is used. Returns a result with HasAsset false (but meaningful residual flags) when no asset is registered for the request — the caller then falls back to the binary-unity-font-stylethreshold.
- TryLoadAddressableFont(string?, out FontAsset?)
Loads a Font Asset by Addressables key (for the
font-[addr:<key>]arbitrary form), caching the result. Returns false and logs a warning when the key does not resolve.
- Unregister(string?)
Removes a family by name. No-op when it is not registered.
Events
- FontsChanged
Raised whenever the registry changes (register / unregister / config swap / default).