Custom Font List
The Slides text editor uses Univer’s shared font list for its font-family dropdown. That list belongs to the application, and you configure it on UniverUIPlugin.
Configure font choices
UniverUIPlugin
containerstring | HTMLElementElement to mount into, or its DOM ID.customFontFamilyIFontConfig[] | objectAdds these font choices to the dropdown.listIFontConfig[]Adds these font choices to the dropdown.valuestringFont family name used in CSS.labelstringDisplay name, or a translation key.categoryFontCategoryFont group. Usesans-serif,serif,monospace,display, orhandwriting.
overridebooleanDefault:falseReplaces the built-in choices with the supplied list.
TypeScript
import { FontCategory, UniverUIPlugin } from '@univerjs/ui'univer.registerPlugin(UniverUIPlugin, { container: 'app', customFontFamily: { list: [ { value: 'Inter', label: 'Inter', category: FontCategory.SANS_SERIF, }, { value: 'Noto Serif', label: 'Noto Serif', category: FontCategory.SERIF, }, ], override: false, },})value is written as the text run’s font family. label is the text that the dropdown displays, or an i18n key. category is optional and groups the choice.
Each font must be loaded with @font-face or a stylesheet. Adding a name to the list does not download a font file. If the family is unavailable, the browser uses a fallback.
Facade API
After the UI Facade has loaded, call addFonts to append font choices at runtime:
TypeScript
import { FontCategory } from '@univerjs/ui'univerAPI.addFonts([ { value: 'Inter', label: 'Inter', category: FontCategory.SANS_SERIF, },])The dropdown updates immediately, but the corresponding font bytes are not loaded.
How is this guide?