我正在使用BaseFont.getWidthPoint()
和Chunk.getWidthPoint()
来计算字符串大小。我发现将样式设置为"BOLD"
并不会影响两个函数的结果。我假设"BOLD"
会增加String的大小。我做错了吗?
String ls = "test length lalalalalala";
Font laFont = new Font(FontFamily.HELVETICA, 12);
laFont.setStyle("BOLD");
BaseFont bf_helv = laFont.getCalculatedBaseFont(false);
float width_helv = bf_helv.getWidthPoint(ls, 12);
System.out.println("------size----------" + width_helv);
Chunk laC = new Chunk(ls);
laC.setFont(laFont);
System.out.println("------size C----------" + laC.getWidthPoint());