Search in sources :

Example 6 with GlyphData

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));
}
Also used : GlyphData(org.apache.fontbox.ttf.GlyphData)

Aggregations

GlyphData (org.apache.fontbox.ttf.GlyphData)6 GeneralPath (java.awt.geom.GeneralPath)3 UniUtil.getUniNameOfCodePoint (org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)3 TreeSet (java.util.TreeSet)1 Type2CharString (org.apache.fontbox.cff.Type2CharString)1 GlyphTable (org.apache.fontbox.ttf.GlyphTable)1 HorizontalMetricsTable (org.apache.fontbox.ttf.HorizontalMetricsTable)1 OpenTypeFont (org.apache.fontbox.ttf.OpenTypeFont)1 VerticalHeaderTable (org.apache.fontbox.ttf.VerticalHeaderTable)1 VerticalMetricsTable (org.apache.fontbox.ttf.VerticalMetricsTable)1 COSArray (org.apache.pdfbox.cos.COSArray)1 COSInteger (org.apache.pdfbox.cos.COSInteger)1