Open
Description
CSSBoxPdf guess font file url by matching file name and font family name. It's not correct especially for CJK font. I suggest using FontMapper to get font.
Change PDFRender#setFont like this. It is still a POC.
/**
* Creates object describing font
*
* @return the font object
*/
private PDFont setFont(String fontFamily, boolean isItalic, boolean isBold)
{
COSDictionary dictionary = new COSDictionary();
dictionary.setItem( COSName.TYPE, COSName.FONT_DESC );
PDFontDescriptor desc = new PDFontDescriptor(dictionary);
desc.setItalic(isItalic);
desc.setFontWeight(isBold? 700: 400);
desc.setFontFamily(fontFamily);
FontMapping<TrueTypeFont> trueTypeFont = FontMappers.instance().getTrueTypeFont(fontFamily, desc);
PDFont font = null;
if (trueTypeFont != null) {
try {
font = PDType0Font.load(doc, trueTypeFont.getFont(), true);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return font;
}
Metadata
Metadata
Assignees
Labels
No labels