Class StyleFontResolver
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Applies an element's font utility classes as inline style, resolving family + weight + italic
together against the VelvetFonts registry. Setting unityFontDefinition and
unityFontStyleAndWeight in one pass is what lets Velvet:
- compose
font-bold italicintobold-and-italic(impossible from two separate USS classes that share the single-unity-font-styleproperty); - render the full
font-thin…font-blackscale when weight-specific Font Assets are registered, and gracefully fold to the binary bold/normal threshold when they are not.
Inline styles win over the USS fallback classes in _typography.uss, so this resolver is the
authoritative font layer for every Velvet element.
public static class StyleFontResolver
- Inheritance
-
objectStyleFontResolver
Methods
- Apply(VisualElement, string[])
Extracts the font intent from
classNamesand applies it, or clears the inline font style when no font class is present. Called by the reconciler whenever an element's class list changes (and on creation).
- ApplyIfPresent(VisualElement, string[])
Create/mount-time entry point: resolves the font intent only when
classNamescarries a font class. A freshly created (or pool-reset) element has no inline font to clear, so for the ~99% of elements with no font class this gate skips the resolve entirely (mirroring the gap manipulator'sHasGapClassearly-out). Single source of truth for the create-side gate.
- ApplyOnClassChange(VisualElement, string[], string[])
Patch-time entry point: re-resolves the font intent when the class list changed and either the new or the old list carried a font class. The old-side check is what clears the inline font style when the last font class is removed. No-op when neither list has a font class. Single source of truth for the patch-side gate.
- Clear(VisualElement)
Reverts both inline font properties to their USS / inherited defaults.
- ComputeFontStyle(bool, bool)
Folds a (bold, italic) pair into the single UnityEngine.FontStyle value that
-unity-font-styleunderstands. This is the composition step that-unity-font-stylecannot do across two separate classes.