如果想在信息图中使用自定义字体,可以通过以下步骤实现:
- 部署字体或者使用已有字体资源,部署方式可参考:字体分包部署与使用
- 使用 registerFont 注册字体。
- 在主题配置中通过配置
font-family使用注册的字体。
以下为示例代码:
import {registerFont, Infographic} from '@antv/infographic'; registerFont({ fontFamily: 'Alibaba PuHuiTi', name: '阿里巴巴普惠体', baseUrl: 'https://assets.antv.antgroup.com/AlibabaPuHuiTi-Regular/result.css', fontWeight: {regular: 'regular'}, }); const infographic = new Infographic({ // 其他配置项... themeConfig: { base: { text: { // 配置全局字体 'font-family': 'Alibaba PuHuiTi', }, }, item: { label: { // 仅配置数据项标题字体 'font-family': 'Alibaba PuHuiTi', }, }, }, });