@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(); } }
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
@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; }
private void initDescriptions() { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); GlyphData glyph = glyphTable.getGlyph(index); if (glyph != null) { descriptions.put(index, glyph.getDescription()); } } catch (IOException e) { LOG.error(e); } } } }
long height = Math.round((glyph.getYMaximum() + vmtx.getTopSideBearing(cid)) * scaling); long advance = Math.round(-vmtx.getAdvanceHeight(cid) * scaling); if (height == v_y && advance == w1)
private void initDescriptions() { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); GlyphData glyph = glyphTable.getGlyph(index); if (glyph != null) { descriptions.put(index, glyph.getDescription()); } } catch (IOException e) { LOG.error(e); } } } }
/** * Build vertical metrics with Identity CIDToGIDMap (for embedding full font). */ private void buildVerticalMetrics(COSDictionary cidFont) throws IOException { if (!buildVerticalHeader(cidFont)) { return; } int cidMax = ttf.getNumberOfGlyphs(); int[] gidMetrics = new int[cidMax * 4]; for (int cid = 0; cid < cidMax; cid++) { GlyphData glyph = ttf.getGlyph().getGlyph(cid); if (glyph == null) { gidMetrics[cid * 4] = Integer.MIN_VALUE; } else { gidMetrics[cid * 4] = cid; gidMetrics[cid * 4 + 1] = ttf.getVerticalMetrics().getAdvanceHeight(cid); gidMetrics[cid * 4 + 2] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); gidMetrics[cid * 4 + 3] = glyph.getYMaximum() + ttf.getVerticalMetrics().getTopSideBearing(cid); } } cidFont.setItem(COSName.W2, getVerticalMetrics(gidMetrics)); }
@Override public GeneralPath getPath(String name) throws IOException { int gid = nameToGID(name); // some glyphs have no outlines (e.g. space, table, newline) GlyphData glyph = getGlyph().getGlyph(gid); if (glyph == null) { return new GeneralPath(); } else { // must scaled by caller using FontMatrix return glyph.getPath(); } }
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
@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; }
private void initDescriptions() { for (GlyfCompositeComp component : components) { try { int index = component.getGlyphIndex(); GlyphData glyph = glyphTable.getGlyph(index); if (glyph != null) { descriptions.put(index, glyph.getDescription()); } } catch (IOException e) { LOG.error(e); } } } }
long height = Math.round((glyph.getYMaximum() + vmtx.getTopSideBearing(cid)) * scaling); long advance = Math.round(-vmtx.getAdvanceHeight(cid) * scaling); if (height == v_y && advance == w1)
if (glyph != null) return glyph.getPath();
private GlyphData getGlyphData(int gid) throws IOException { GlyphData glyph = new GlyphData(); HorizontalMetricsTable hmt = font.getHorizontalMetrics(); int leftSideBearing = hmt == null ? 0 : hmt.getLeftSideBearing(gid); glyph.initData(this, data, leftSideBearing); // resolve composite glyph if (glyph.getDescription().isComposite()) { glyph.getDescription().resolve(); } return glyph; } }
@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; }
/** * Build vertical metrics with Identity CIDToGIDMap (for embedding full font). */ private void buildVerticalMetrics(COSDictionary cidFont) throws IOException { if (!buildVerticalHeader(cidFont)) { return; } int cidMax = ttf.getNumberOfGlyphs(); int[] gidMetrics = new int[cidMax * 4]; for (int cid = 0; cid < cidMax; cid++) { GlyphData glyph = ttf.getGlyph().getGlyph(cid); if (glyph == null) { gidMetrics[cid * 4] = Integer.MIN_VALUE; } else { gidMetrics[cid * 4] = cid; gidMetrics[cid * 4 + 1] = ttf.getVerticalMetrics().getAdvanceHeight(cid); gidMetrics[cid * 4 + 2] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); gidMetrics[cid * 4 + 3] = glyph.getYMaximum() + ttf.getVerticalMetrics().getTopSideBearing(cid); } } cidFont.setItem(COSName.W2, getVerticalMetrics(gidMetrics)); }
@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 { 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(String name) throws IOException { int gid = nameToGID(name); // some glyphs have no outlines (e.g. space, table, newline) GlyphData glyph = getGlyph().getGlyph(gid); if (glyph == null) { return new GeneralPath(); } else { // must scaled by caller using FontMatrix 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(); } }