设置文字加粗
示例代码
package test.create.c01;
import iofd.kernel.constant.FontWeight;
import iofd.layout.OfdDocument;
import iofd.layout.block.Paragraph;
import iofd.layout.block.paragraph.Text;
import test.create.TestDocUtil;
/**
* 展示如何设置文字的粗细模式
* */
public class C0108SetFontBold {
public static void main(String[] args) throws Throwable {
C0108SetFontBold o = new C0108SetFontBold();
o.done();
}
private void done() throws Throwable {
String clzName = this.getClass().getSimpleName();
System.out.println(clzName + " begin");
OfdDocument doc = new OfdDocument();
String s;
Paragraph p;
Text text;
s = "最细的字体100";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.lightest);
p.add(text);
doc.add(p);
s = "次细的字体200";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.lighter);
p.add(text);
doc.add(p);
s = "细的字体300";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.light);
p.add(text);
doc.add(p);
s = "正常的字体400";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.normal);
p.add(text);
doc.add(p);
s = "粗一点的字体500";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.lightest_bold);
p.add(text);
doc.add(p);
s = "再粗一点的字体600";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.lighter_bold);
p.add(text);
doc.add(p);
s = "正常加粗的字体700";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.bold);
p.add(text);
doc.add(p);
s = "更粗的字体800";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.bolder);
p.add(text);
doc.add(p);
s = "最粗的字体900";
p = new Paragraph();
text = new Text(s);
text.setWeight(FontWeight.boldest);
p.add(text);
doc.add(p);
String fileName = TestDocUtil.getOfdFilePath(this.getClass());
doc.save(fileName);
System.out.println(clzName + " end");
}
}