/** * Returns the width for the given GID. * * @param gid the GID * @return the width * @throws IOException if there was an error reading the metrics table. */ public int getAdvanceWidth(int gid) throws IOException { HorizontalMetricsTable hmtx = getHorizontalMetrics(); if (hmtx != null) { return hmtx.getAdvanceWidth(gid); } else { // this should never happen return 250; } }
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; } }
break; case HorizontalMetricsTable.TAG: table = new HorizontalMetricsTable(font); break; case IndexToLocationTable.TAG:
is.skip(hm.getOffset()); long lastOffset = 0; for (Integer glyphId : glyphIds)
table = new HorizontalMetricsTable(font);
int gid = cmapLookup.getGlyphId(charCode); widths.set(entry.getKey() - firstChar, Math.round(hmtx.getAdvanceWidth(gid) * scaling));
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; } }
is.skip(hm.getOffset()); long lastOffset = 0; for (Integer glyphId : glyphIds)
break; case HorizontalMetricsTable.TAG: table = new HorizontalMetricsTable(font); break; case IndexToLocationTable.TAG:
/** * Build widths with Identity CIDToGIDMap (for embedding full font). */ private void buildWidths(COSDictionary cidFont) throws IOException { int cidMax = ttf.getNumberOfGlyphs(); int[] gidwidths = new int[cidMax * 2]; for (int cid = 0; cid < cidMax; cid++) { gidwidths[cid * 2] = cid; gidwidths[cid * 2 + 1] = ttf.getHorizontalMetrics().getAdvanceWidth(cid); } cidFont.setItem(COSName.W, getWidths(gidwidths)); }
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; } }
long width = Math.round(ttf.getHorizontalMetrics().getAdvanceWidth(gid) * scaling); if (width == 1000)
long width = Math.round(hmtx.getAdvanceWidth(cid) * scaling); w2.add(COSInteger.get(width / 2)); // v_ix
/** * 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)); }
/** * Returns the width for the given GID. * * @param gid the GID * @return the width * @throws IOException if there was an error reading the metrics table. */ public int getAdvanceWidth(int gid) throws IOException { HorizontalMetricsTable hmtx = getHorizontalMetrics(); if (hmtx != null) { return hmtx.getAdvanceWidth(gid); } else { // this should never happen return 250; } }
/** * Returns the width for the given GID. * * @param gid the GID * @return the width * @throws IOException if there was an error reading the metrics table. */ public int getAdvanceWidth(int gid) throws IOException { HorizontalMetricsTable hmtx = getHorizontalMetrics(); if (hmtx != null) { return hmtx.getAdvanceWidth(gid); } else { // this should never happen return 250; } }