Table of Contents

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 italic into bold-and-italic (impossible from two separate USS classes that share the single -unity-font-style property);
  • render the full font-thinfont-black scale 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
object
StyleFontResolver

Methods

Apply(VisualElement, string[])

Extracts the font intent from classNames and 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 classNames carries 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's HasGapClass early-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-style understands. This is the composition step that -unity-font-style cannot do across two separate classes.