Utility classes for changing an element's font weight property.

By default, Doddle contains no imported font, and will need to be imported during setup. You will need to import and create font assets of your desired font. For instructions, read Installation.

Classes for font weight are named using the format: [fw]-[weight]-[style].

Where weight includes:

  • 100 - for -unity-font-definition: var(--font-thin)
  • 300 - for -unity-font-definition: var(--font-light)
  • 400 - for -unity-font-definition: var(--font-regular)
  • 700 - for -unity-font-definition: var(--font-bold)
  • 900 - for -unity-font-definition: var(--font-black)

Where style includes:

  • nothing - for the defined font weight, in non italic form
  • italic - for unity-font-definition: var(--font-[weight]-italic)
ClassContents

Changing font weight, and style through your imported font's supported weights is the recommended approach for consistency and accuracy. However, classes '.bold', and '.italic' still exist and can be stacked. You can still manually apply a bold or italics property in the UI toolkit inspector to an already bolded/italicized font asset. You end up with a bolded italicized bold italics font. The bold and italics amount applied by Unity seems to be some arbitrary amount, as applying the class '.bold' will result in a slightly different look than applying your font's '.fw-700'.

font-thin
font-light
font-regular
font-bold
font-black

UXML

font-thin-italic
font-light-italic
font-regular-italic
font-bold-italic
font-black-italic

UXML

Doddle USS provides extension and helper methods. One of those methods are SetFontWeightByEnum() which allows you to pre-define multiple instances of static UI content from ScriptableObjets with simple population scripts. Supported font weight enums are:

  • Black = 0 - for the .fw-100 class
  • BlackItalic = 1 - for the .fw-100-italic class
  • Bold = 2 - for the .fw-300 class
  • BoldItalic = 3 - for the .fw-300-italic class
  • Regular = 4 - for the .fw-400 class
  • RegularItalic = 5 - for the .fw-500-italic class
  • Light = 6 - for the .fw-700 class
  • LightItalic = 7 - for the .fw-700-italic class
  • Thin = 8 - for the .fw-900 class
  • ThinItalic = 9 - for the .fw-900-italic class
Font weight enum example image showing scriptable object

UXML