@Override public boolean hasGlyph(int code) throws IOException { return codeToGID(code) != 0; } }
@Override public boolean hasGlyph(int code) throws IOException { return font.codeToGID(code) != 0; } }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); int width = ttf.getAdvanceWidth(gid); int unitsPerEM = ttf.getUnitsPerEm(); if (unitsPerEM != 1000) { width *= 1000f / unitsPerEM; } return width; }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }
@Override public GeneralPath getNormalizedPath(int code) throws IOException { boolean hasScaling = ttf.getUnitsPerEm() != 1000; float scale = 1000f / ttf.getUnitsPerEm(); int gid = codeToGID(code); GeneralPath path = getPath(code); // Acrobat only draws GID 0 for embedded CIDFonts, see PDFBOX-2372 if (gid == 0 && !isEmbedded()) { path = null; } if (path == null) { // empty glyph (e.g. space, newline) return new GeneralPath(); } else { if (hasScaling) { path.transform(AffineTransform.getScaleInstance(scale, scale)); } return path; } }
@Override public boolean hasGlyph(int code) throws IOException { return codeToGID(code) != 0; } }
@Override public boolean hasGlyph(int code) throws IOException { return codeToGID(code) != 0; } }
@Override public boolean hasGlyph(int code) throws IOException { return font.codeToGID(code) != 0; } }
@Override public boolean hasGlyph(int code) throws IOException { return font.codeToGID(code) != 0; } }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); int width = ttf.getAdvanceWidth(gid); int unitsPerEM = ttf.getUnitsPerEm(); if (unitsPerEM != 1000) { width *= 1000f / unitsPerEM; } return width; }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); int width = ttf.getAdvanceWidth(gid); int unitsPerEM = ttf.getUnitsPerEm(); if (unitsPerEM != 1000) { width *= 1000f / unitsPerEM; } return width; }
@Override public GeneralPath getNormalizedPath(int code) throws IOException { boolean hasScaling = ttf.getUnitsPerEm() != 1000; float scale = 1000f / ttf.getUnitsPerEm(); int gid = codeToGID(code); GeneralPath path = getPath(code); // Acrobat only draws GID 0 for embedded CIDFonts, see PDFBOX-2372 if (gid == 0 && !isEmbedded()) { path = null; } if (path == null) { // empty glyph (e.g. space, newline) return new GeneralPath(); } else { if (hasScaling) { path.transform(AffineTransform.getScaleInstance(scale, scale)); } return path; } }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }
@Override public GeneralPath getPath(int code) throws IOException { if (ttf instanceof OpenTypeFont && ((OpenTypeFont)ttf).isPostScript()) { // we're not supposed to have CFF fonts inside PDCIDFontType2, but if we do, // then we treat their CIDs as GIDs, see PDFBOX-3344 int cid = codeToGID(code); Type2CharString charstring = ((OpenTypeFont)ttf).getCFF().getFont().getType2CharString(cid); return charstring.getPath(); } else { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getPath(); } return new GeneralPath(); } }