设置字体样式
示例代码
package test.create.c01;
import iofd.io.util.FontUtil;
import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import test.create.TestDocUtil;
/**
* 设置字体样式
* */
public class C0103SetFontStyle {
public static void main(String[] args) throws Throwable {
C0103SetFontStyle o = new C0103SetFontStyle();
o.done();
}
private void done() throws Throwable {
String clzName = this.getClass().getSimpleName();
System.out.println(clzName + " begin");
OfdDocument doc = new OfdDocument();
Paragraph p = new Paragraph();
Text text = new Text("设置不同字体,这是微软雅黑,");
text.setFont(FontUtil.MSYH);
p.add(text);
text = new Text("这是默认的仿宋");
p.add(text);
doc.add(p);
String fileName = TestDocUtil.getOfdFilePath(this.getClass());
doc.save(fileName);
System.out.println(clzName + " end");
}
}