@Override public boolean hasGlyph(int code) throws IOException { return codeToGID(code) != 0; }
@Override public boolean hasGlyph(int code) throws IOException { if (font.isEmbedded()) { int gid = font.codeToGID(code); return gid != 0; } return false; } }
/** * Inverts the font's code -> GID mapping. Any duplicate (GID -> code) mappings will be lost. */ protected Map<Integer, Integer> getGIDToCode() throws IOException { if (gidToCode != null) { return gidToCode; } gidToCode = new HashMap<>(); for (int code = 0; code <= 255; code++) { int gid = codeToGID(code); if (!gidToCode.containsKey(gid)) { gidToCode.put(gid, code); } } return gidToCode; }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); float width = ttf.getAdvanceWidth(gid); float unitsPerEM = ttf.getUnitsPerEm(); if (Float.compare(unitsPerEM, 1000) != 0) { width *= 1000f / unitsPerEM; } return width; }
@Override public GeneralPath getPath(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); // some glyphs have no outlines (e.g. space, table, newline) if (glyph == null) { return new GeneralPath(); } else { return glyph.getPath(); } }
@Override public float getHeight(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getBoundingBox().getHeight(); } return 0; }
@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 or "Standard 14" fonts, see PDFBOX-2372 if (gid == 0 && !isEmbedded() && !isStandard14()) { 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; } }
for (int code = 0; code <= 256; code++) int gid = codeToGID(code); if (gid > 0)
@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 { if (font.isEmbedded()) { int gid = font.codeToGID(code); return gid != 0; } return false; } }
/** * Inverts the font's code -> GID mapping. Any duplicate (GID -> code) mappings will be lost. */ protected Map<Integer, Integer> getGIDToCode() throws IOException { if (gidToCode != null) { return gidToCode; } gidToCode = new HashMap<>(); for (int code = 0; code <= 255; code++) { int gid = codeToGID(code); if (!gidToCode.containsKey(gid)) { gidToCode.put(gid, code); } } return gidToCode; }
private int getGIDForCharacterCode(int code) throws IOException { if (isCIDFont) { return ((PDType0Font)font).codeToGID(code); } else { return ((PDTrueTypeFont)font).codeToGID(code); } }
@Override public boolean hasGlyph(int code) throws IOException { if (font.isEmbedded()) { int gid = font.codeToGID(code); return gid != 0; } return false; } }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); float width = ttf.getAdvanceWidth(gid); float unitsPerEM = ttf.getUnitsPerEm(); if (unitsPerEM != 1000) { width *= 1000f / unitsPerEM; } return width; }
@Override public float getWidthFromFont(int code) throws IOException { int gid = codeToGID(code); float width = ttf.getAdvanceWidth(gid); float unitsPerEM = ttf.getUnitsPerEm(); if (unitsPerEM != 1000) { width *= 1000f / unitsPerEM; } return width; }
@Override public GeneralPath getPath(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); // some glyphs have no outlines (e.g. space, table, newline) if (glyph == null) { return new GeneralPath(); } else { return glyph.getPath(); } }
@Override public GeneralPath getPath(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); // some glyphs have no outlines (e.g. space, table, newline) if (glyph == null) { return new GeneralPath(); } else { return glyph.getPath(); } }
@Override public float getHeight(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getBoundingBox().getHeight(); } return 0; }
@Override public float getHeight(int code) throws IOException { int gid = codeToGID(code); GlyphData glyph = ttf.getGlyph().getGlyph(gid); if (glyph != null) { return glyph.getBoundingBox().getHeight(); } return 0; }