Search in sources :

Example 1 with Type2CharString

use of com.tom_roush.fontbox.cff.Type2CharString in project PdfBox-Android by TomRoush.

the class PDCIDFontType0 method hasGlyph.

@Override
public boolean hasGlyph(int code) throws IOException {
    int cid = codeToCID(code);
    Type2CharString charstring = getType2CharString(cid);
    if (charstring != null) {
        return charstring.getGID() != 0;
    } else if (isEmbedded && t1Font instanceof CFFType1Font) {
        return ((CFFType1Font) t1Font).getType2CharString(cid).getGID() != 0;
    } else {
        return t1Font.hasGlyph(getGlyphName(code));
    }
}
Also used : Type2CharString(com.tom_roush.fontbox.cff.Type2CharString) CFFType1Font(com.tom_roush.fontbox.cff.CFFType1Font) UniUtil.getUniNameOfCodePoint(com.tom_roush.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)

Example 2 with Type2CharString

use of com.tom_roush.fontbox.cff.Type2CharString in project PdfBox-Android by TomRoush.

the class PDCIDFontType0 method getPath.

@Override
public Path getPath(int code) throws IOException {
    int cid = codeToCID(code);
    if (cid2gid != null && isEmbedded) {
        // PDFBOX-4093: despite being a type 0 font, there is a CIDToGIDMap
        cid = cid2gid[cid];
    }
    Type2CharString charstring = getType2CharString(cid);
    if (charstring != null) {
        return charstring.getPath();
    } else if (isEmbedded && t1Font instanceof CFFType1Font) {
        return ((CFFType1Font) t1Font).getType2CharString(cid).getPath();
    } else {
        return t1Font.getPath(getGlyphName(code));
    }
}
Also used : Type2CharString(com.tom_roush.fontbox.cff.Type2CharString) CFFType1Font(com.tom_roush.fontbox.cff.CFFType1Font) UniUtil.getUniNameOfCodePoint(com.tom_roush.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)

Example 3 with Type2CharString

use of com.tom_roush.fontbox.cff.Type2CharString in project PdfBox-Android by TomRoush.

the class PDCIDFontType2 method getPath.

@Override
public Path 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 Path();
    }
}
Also used : Type2CharString(com.tom_roush.fontbox.cff.Type2CharString) Path(android.graphics.Path) GlyphData(com.tom_roush.fontbox.ttf.GlyphData) OpenTypeFont(com.tom_roush.fontbox.ttf.OpenTypeFont)

Aggregations

Type2CharString (com.tom_roush.fontbox.cff.Type2CharString)3 CFFType1Font (com.tom_roush.fontbox.cff.CFFType1Font)2 UniUtil.getUniNameOfCodePoint (com.tom_roush.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)2 Path (android.graphics.Path)1 GlyphData (com.tom_roush.fontbox.ttf.GlyphData)1 OpenTypeFont (com.tom_roush.fontbox.ttf.OpenTypeFont)1