use of org.docx4j.fonts.Mapper in project docx4j-template by vindell.
the class PhysicalFontUtils method setPhysicalFont.
/**
* 为 {@link org.docx4j.openpackaging.packages.WordprocessingMLPackage} 增加新的字体
*/
public static void setPhysicalFont(WordprocessingMLPackage wmlPackage, String fontName) throws Exception {
// Mapper fontMapper = new BestMatchingMapper();
Mapper fontMapper = wmlPackage.getFontMapper() == null ? new IdentityPlusMapper() : wmlPackage.getFontMapper();
// 获取字体库
PhysicalFont physicalFont = PhysicalFonts.get(fontName);
// 分别设置字体名和别名对应的字体库
fontMapper.put(fontName, physicalFont);
// 设置文档字体库
wmlPackage.setFontMapper(fontMapper, true);
}
Aggregations