如何使用Apache POI PPT API设置文本字体?

3

我正在使用Apache POI PPT API创建PPTX。我想将特定的字体系列应用于我添加到幻灯片中的文本。

我已经探索了API,并发现只有以下方法可以指定颜色和字体大小,但不知道如何设置字体系列,请帮忙。

XSLFTextRun run1 = paragraph.addNewTextRun();
run1.setText("This is test"); 
run1.setFontColor(java.awt.Color.red);      
run1.setFontSize(24);    
1个回答

5
 XSLFTextRun run1 = p.addNewTextRun(); 
       run1.setText("This is test"); 
       run1.setFontFamily(HSSFFont.FONT_ARIAL);
       run1.setFontColor(Color.red);    
       run1.setFontSize(24);  

您可以使用setFontFamily方法来指定字体系列。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接