use of org.apache.pdfbox.pdmodel.font.PDFontLike in project pdfbox by apache.
the class GlyphCache method getPathForCharacterCode.
public GeneralPath getPathForCharacterCode(int code) {
GeneralPath path = cache.get(code);
if (path != null) {
return path;
}
try {
if (!font.hasGlyph(code)) {
String fontName = ((PDFontLike) font).getName();
if (font instanceof PDType0Font) {
int cid = ((PDType0Font) font).codeToCID(code);
String cidHex = String.format("%04x", cid);
LOG.warn("No glyph for code " + code + " (CID " + cidHex + ") in font " + fontName);
} else if (font instanceof PDSimpleFont) {
LOG.warn("No glyph for code " + code + " in " + font.getClass().getSimpleName() + " " + fontName + " (embedded or system font used: " + ((PDSimpleFont) font).getFontBoxFont().getName() + ")");
PDSimpleFont simpleFont = (PDSimpleFont) font;
if (code == 10 && simpleFont.isStandard14()) {
// PDFBOX-4001 return empty path for line feed on std14
path = new GeneralPath();
cache.put(code, path);
return path;
}
} else {
LOG.warn("No glyph for code " + code + " in font " + fontName);
}
}
path = font.getNormalizedPath(code);
cache.put(code, path);
return path;
} catch (IOException e) {
// todo: escalate this error?
LOG.error("Glyph rendering failed", e);
return new GeneralPath();
}
}
Aggregations