private void readGlyf()

in src/java/org/apache/fop/render/pdf/pdfbox/MergeTTFonts.java [74:119]


    private void readGlyf(Map<Integer, Integer> glyphs, FontFileReader in) throws IOException {
        OFDirTabEntry entry = dirTabs.get(OFTableName.GLYF);
        if (entry != null) {
            int[] origIndexes = buildSubsetIndexToOrigIndexMap(glyphs);
            for (int i = 0; i < origIndexes.length; i++) {
                int nextOffset = 0;
                int origGlyphIndex = origIndexes[i];
                if (origGlyphIndex >= (mtxTab.length - 1)) {
                    nextOffset = (int)lastLoca;
                } else {
                    nextOffset = (int)mtxTab[origGlyphIndex + 1].getOffset();
                }
                int glyphOffset = (int)mtxTab[origGlyphIndex].getOffset();
                int glyphLength = nextOffset - glyphOffset;
                if (glyphLength < 0) {
                    continue;
                }
                byte[] glyphData = in.getBytes(
                        (int)entry.getOffset() + glyphOffset,
                        glyphLength);

                Glyph g = new Glyph(glyphData, mtxTab[origGlyphIndex],
                        composedGlyphs.contains(origGlyphIndex),
                        compositeGlyphs.contains(origGlyphIndex), origGlyphIndex);
                if (!cid && (origIndexesLen == 0 || (glyphLength > 0 && i > 0))) {
                    if (added.containsKey(i)) {
                        Glyph existing = added.get(i);
                        if (existing.data.length == 0) {
                            added.put(i, g);
                        }
                    } else {
                        added.put(i, g);
                    }
                } else if (cid) {
                    added.put(i + origIndexesLen, g);
                }
            }
            if (!cid) {
                origIndexesLen = origIndexes.length;
            } else {
                origIndexesLen += origIndexes.length;
            }
        } else {
            throw new IOException("Can't find glyf table");
        }
    }