Custom Font List

Font structure definition

In Univer, the IFontConfig interface describes a font:

PropertyTypeDescription
valuestringThe unique identifier of the font, usually the first entry in a CSS font-family.
labelstringTranslation key. If the key has no translation when the Univer instance is created, the supplied value is shown unchanged.
categoryFontCategoryFont category, which groups fonts in the UI. Optional.

Univer does not prevent users from selecting a font that is not installed. If the client does not have the font, the browser substitutes its default font.

Using custom fonts

The customFontFamily parameter on UniverUIPlugin controls which options the font dropdown offers.

UniverUIPlugin

  • container
    string | HTMLElement
    The element to mount into, or the DOM ID of that element.
  • customFontFamily
    IFontConfig[] | object
    Adds these font choices to the dropdown.
    • list
      IFontConfig[]
      Adds these font choices to the dropdown.
      • value
        string
        Font family name used in CSS.
      • label
        string
        Display name or translation key.
      • category
        FontCategory
        Font group. Use sans-serif, serif, monospace, display, or handwriting.
    • override
      booleanDefault: false
      Replaces the built-in choices with the supplied list.
TypeScript
import { FontCategory, UniverUIPlugin } from '@univerjs/ui'univer.registerPlugin(UniverUIPlugin, {  container: 'app',  customFontFamily: {    list: [      {        value: 'PingFang SC',        label: '苹方(简)',        category: FontCategory.SANS_SERIF,      },      {        value: 'Helvetica Neue',        label: 'Helvetica Neue',        category: FontCategory.SANS_SERIF,      },    ],    // Whether to override the default font list, defaults to false    override: true,  },})

Facade API

Fonts do not have to be known at startup. The Facade API can add new fonts at runtime, which is required when font resources load asynchronously.

TypeScript
import { FontCategory } from '@univerjs/ui'univerAPI.addFonts([{  value: 'PingFang SC',  label: 'PingFang SC',  category: FontCategory.SANS_SERIF,}, {  value: 'Helvetica Neue',  label: 'Helvetica Neue',  category: FontCategory.SANS_SERIF,}])

How is this guide?

© 2026 DreamNum Co., Ltd.