Search in sources :

Example 1 with CFFType1Font

use of org.apache.fontbox.cff.CFFType1Font in project pdfbox by apache.

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(org.apache.fontbox.cff.Type2CharString) CFFType1Font(org.apache.fontbox.cff.CFFType1Font) UniUtil.getUniNameOfCodePoint(org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)

Example 2 with CFFType1Font

use of org.apache.fontbox.cff.CFFType1Font in project pdfbox by apache.

the class PDCIDFontType0 method getPath.

@Override
public GeneralPath 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(org.apache.fontbox.cff.Type2CharString) CFFType1Font(org.apache.fontbox.cff.CFFType1Font) UniUtil.getUniNameOfCodePoint(org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)

Example 3 with CFFType1Font

use of org.apache.fontbox.cff.CFFType1Font in project pdfbox by apache.

the class PDCIDFontType0 method getWidthFromFont.

@Override
public float getWidthFromFont(int code) throws IOException {
    int cid = codeToCID(code);
    float width;
    if (cidFont != null) {
        width = getType2CharString(cid).getWidth();
    } else if (isEmbedded && t1Font instanceof CFFType1Font) {
        width = ((CFFType1Font) t1Font).getType2CharString(cid).getWidth();
    } else {
        width = t1Font.getWidth(getGlyphName(code));
    }
    Point2D p = new Point2D.Float(width, 0);
    fontMatrixTransform.transform(p, p);
    return (float) p.getX();
}
Also used : CFFType1Font(org.apache.fontbox.cff.CFFType1Font) Point2D(java.awt.geom.Point2D) UniUtil.getUniNameOfCodePoint(org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)

Aggregations

CFFType1Font (org.apache.fontbox.cff.CFFType1Font)3 UniUtil.getUniNameOfCodePoint (org.apache.pdfbox.pdmodel.font.UniUtil.getUniNameOfCodePoint)3 Type2CharString (org.apache.fontbox.cff.Type2CharString)2 Point2D (java.awt.geom.Point2D)1