自定义字体列表

Boards 把字体选择保存在 Board 数据中。Board 主题可以通过 fontScheme.headingfontScheme.body 定义标题与正文字体;单个文本元素可以通过 textStyle 覆盖字体族、字号和强调样式。

设置文本元素字体

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active Board')const label = board.insertText({  text: 'Milestone',  left: 120,  top: 96,  width: 240,  height: 64,  textStyle: {    fontFamily: 'Inter',    fontSize: 18,    bold: true,  },})if (!label) throw new Error('Cannot insert label')

Board 文本编辑使用通用 Docs UI 文本管线,它是 @univerjs-pro/boards-ui 的技术依赖。请在渲染 Board 前由主页面加载 Web 字体;否则浏览器会替换为可用字体,文本尺寸也可能变化。

通用应用主题请参阅主题与暗黑模式。Board 文档主题仍保存在 Board 快照中。

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.