Java Code Examples for org.docx4j.openpackaging.packages.WordprocessingMLPackage#getFontMapper()

The following examples show how to use org.docx4j.openpackaging.packages.WordprocessingMLPackage#getFontMapper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicalFontUtils.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
public static void setPhysicalFont(WordprocessingMLPackage wmlPackage,PhysicalFont physicalFont) throws Exception {
Mapper fontMapper = wmlPackage.getFontMapper() == null ? new IdentityPlusMapper() : wmlPackage.getFontMapper();
//分别设置字体名和别名对应的字体库
fontMapper.put(physicalFont.getName(), physicalFont );
//设置文档字体库
wmlPackage.setFontMapper(fontMapper, true);
  }
 
Example 2
Source File: PhysicalFontUtils.java    From docx4j-template with Apache License 2.0 5 votes vote down vote up
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);
  }