private int getGIDForCharacterCode(int code) throws IOException { if (isCIDFont) { return ((PDType0Font)font).codeToGID(code); } else { return ((PDTrueTypeFont)font).codeToGID(code); } }
public PBGlyph(Boolean glyphPresent, Boolean widthsConsistent, PDFont font, int glyphCode, String type, int renderingMode) { super(type); this.glyphPresent = glyphPresent; this.widthsConsistent = widthsConsistent; this.renderingMode = Long.valueOf(renderingMode); if (font instanceof PDSimpleFont) { Encoding encoding = ((PDSimpleFont) font).getEncoding(); this.name = encoding == null ? null : encoding.getName(glyphCode); } else if (font instanceof PDType0Font){ try { if (((PDType0Font) font).codeToGID(glyphCode) == 0) { this.name = ".notdef"; } else { this.name = null; } } catch (IOException e) { LOGGER.debug("Can't convert code to glyph",e); this.name = null; } } try { this.toUnicode = font.toUnicode(glyphCode); } catch (IOException e) { LOGGER.debug(e); this.toUnicode = null; } this.id = IDGenerator.generateID(font.getCOSObject().hashCode(), font.getName(), glyphCode, renderingMode); }