Skip to content

Add a custom font

Register a font with Tick UI so calls like ui.Text("...", "myFont", 18, ...) resolve to your font asset. Fonts ship inside a GUIResourceProvider asset that you attach to your BaseGameUI subclass through the Inspector.

For the model behind the resource chain, refer to Resource providers. To produce the atlas Texture and Metrics JSON this page registers, refer to Generate a font atlas.

Add a custom font

To add a custom font:

  1. Create a GUIResourceProvider asset. In the Project view, right-click and choose Create > Interlude Software > UI > GUIResourceProvider. Name it after your font set (MyGameFonts, for example).
  2. Add the font asset to the provider. Open the new asset in the Inspector, expand the Fonts list, and add an entry per font and size variant. Each entry holds two references: the MSDF atlas Texture and the JSON Metrics Path. The font name (the string passed to ui.Text) and the size are derived from the metrics file — its name supplies the lookup key and its JSON supplies the atlas size.
  3. Add the provider to your BaseGameUI subclass. Select the GameObject hosting your subclass. In the Inspector, expand Resource Providers and add the new asset to the array. Index 0 is checked first, so place project-wide providers ahead of more specific ones.
  4. Reference the font from your DoUI.
    ui.Text("Hello, world", "myFont", 18, Color.white,
        TextAlign.MiddleCenter);
    

The lookup walks your provider list, then falls back to the bundled DefaultTickConfig. If the requested name and size do not exist in any provider, the call logs a warning and renders nothing.

Push a provider for theme or locale swaps

For runtime swaps (a localisation pack, an unlockable theme), push a provider at runtime and remove it later:

m_baseGameUI.ResourceProviders.Push(localePack);
// when the locale changes again
m_baseGameUI.ResourceProviders.Remove(localePack);

Push inserts at the highest priority, so the new provider's fonts shadow lower-priority entries with the same name until the matching Remove.

Add multiple sizes of one font

The provider's Fonts list keeps one entry per (name, size) pair. Add an entry per size you want available:

Name Size
myFont 14
myFont 18
myFont 24

Calls with sizes outside the registered set return false from TryGetFont, and the call falls through to the next provider. For the lookup mechanics, refer to Resource providers.

Pitfalls

The font does not appear. : The provider's array index is below another provider that lists the same name. Move the provider higher in the array, or rename the font.

A specific size renders with a different size font. : The requested size variant is not in the provider. Add the missing size, or accept the fallback to a different size.

Editor-only fonts go missing in player builds. : The font asset is not included in the build. Mark the asset as included in the Asset Bundle or Resources, or reference it directly from a serialised field that survives stripping.

Pink characters appear when the font otherwise works. : The font's text shader is not in the provider chain. Either leave the provider's shader list empty (so the bundled default supplies the shader) or populate it fully.

Additional resources

  • Generate a font atlas: bake the MSDF atlas and metrics files this page registers.
  • Resource providers: the composite chain and runtime push semantics.
  • Theming: the broader workflow with colours and icons.
  • Compile flags: ENABLE_INPUT_SYSTEM affects how typed input arrives into a textbox using the registered font.