Skip to content
ComPDF

在内容编辑器中设置字体

You can edit the font family on the panel of the content editor. The following code shows you how to set the font family: 你可以在内容编辑器的面板上编辑字体。以下代码演示了如何设置字体:

javascript
const customFonts = instance.UI.getCustomFonts();
// 添加自定义字体
customFonts.push({
  fontFamily: "CustomFont",
  fontName: "CustomFont"
});
// 移除字体
customFonts.splice(0, 1);

// 你也可以设置字体的顺序
const font = customFonts[0];
customFonts[0] = customFonts[1];
customFonts[1] = font;

在内容编辑器中设置字体大小

你也可以在内容编辑器的面板上设置字体大小。以下代码演示了如何设置字体大小:

javascript
// 获取可设置的字体大小列表
instance.UI.getFontSizes();

// 设置字体大小列表
instance.UI.setFontSizes([12, 14, 16, 18, 20]);