如何在JasperReports中使用Gotham-Book.ttf修复凌乱的自定义字体?
自定义字体arial(成功):
字体声明:
<fontFamily name="FreeUniversal">
<normal>jasperutils/fonts/Arial.ttf</normal>
<bold>jasperutils/fonts/Arial.ttf</bold>
<italic>jasperutils/fonts/Arial.ttf</italic>
<boldItalic>jasperutils/fonts/Arial.ttf</boldItalic>
<pdfEncoding>Cp1252</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
自定义字体哥谭(messy):
字体声明:
<fontFamily name="FreeUniversal">
<normal>jasperutils/fonts/gotham/GothamBook.ttf</normal>
<bold>jasperutils/fonts/gotham/GothamBook.ttf</bold>
<italic>jasperutils/fonts/gotham/GothamBook.ttf</italic>
<boldItalic>jasperutils/fonts/gotham/GothamBook.ttf</boldItalic>
<pdfEncoding>Cp1252</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
我正在使用DynamicReports生成报告,示例代码:
private void build() {
FontBuilder defaultFont = stl.font()
.setFontName("FreeUniversal");
StyleBuilder boldStyle = stl.style()
.bold();
StyleBuilder italicStyle = stl.style()
.italic();
StyleBuilder boldItalicStyle = stl.style()
.boldItalic();
try {
report()
.setDefaultFont(defaultFont)
.title(
Templates.createTitleComponent("DefaultFont"),
cmp.text("FreeUniversal font - plain"),
cmp.text("FreeUniversal font - bold").setStyle(boldStyle),
cmp.text("FreeUniversal font - italic").setStyle(italicStyle),
cmp.text("FreeUniversal font - bolditalic").setStyle(boldItalicStyle))
.show();
} catch (DRException e) {
e.printStackTrace();
}
}