use of org.apache.fontbox.ttf.GlyphData in project pdfbox by apache.
the class PDCIDFontType2Embedder method buildVerticalMetrics.
/**
* 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));
}
Aggregations