Search in sources :

Example 1 with Type1Font

use of org.apache.fontbox.type1.Type1Font in project pdfbox by apache.

the class FileSystemFontProvider method addType1Font.

/**
 * Adds a Type 1 font to the file cache. To reduce memory, the parsed font is not cached.
 */
private void addType1Font(File pfbFile) throws IOException {
    try (InputStream input = new FileInputStream(pfbFile)) {
        Type1Font type1 = Type1Font.createWithPFB(input);
        if (type1.getName() != null && type1.getName().contains("|")) {
            fontInfoList.add(new FSIgnored(pfbFile, FontFormat.PFB, "*skippipeinname*"));
            LOG.warn("Skipping font with '|' in name " + type1.getName() + " in file " + pfbFile);
            return;
        }
        fontInfoList.add(new FSFontInfo(pfbFile, FontFormat.PFB, type1.getName(), null, -1, -1, 0, 0, -1, null, this));
        if (LOG.isTraceEnabled()) {
            LOG.trace("PFB: '" + type1.getName() + "' / '" + type1.getFamilyName() + "' / '" + type1.getWeight() + "'");
        }
    } catch (IOException e) {
        LOG.error("Could not load font file: " + pfbFile, e);
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Type1Font(org.apache.fontbox.type1.Type1Font) FileInputStream(java.io.FileInputStream)

Example 2 with Type1Font

use of org.apache.fontbox.type1.Type1Font in project pdfbox by apache.

the class FontMapperImpl method findFontBoxFont.

/**
 * Finds a font with the given PostScript name, or a suitable substitute, or null.
 *
 * @param postScriptName PostScript font name
 */
private FontBoxFont findFontBoxFont(String postScriptName) {
    Type1Font t1 = (Type1Font) findFont(FontFormat.PFB, postScriptName);
    if (t1 != null) {
        return t1;
    }
    TrueTypeFont ttf = (TrueTypeFont) findFont(FontFormat.TTF, postScriptName);
    if (ttf != null) {
        return ttf;
    }
    OpenTypeFont otf = (OpenTypeFont) findFont(FontFormat.OTF, postScriptName);
    if (otf != null) {
        return otf;
    }
    return null;
}
Also used : TrueTypeFont(org.apache.fontbox.ttf.TrueTypeFont) OpenTypeFont(org.apache.fontbox.ttf.OpenTypeFont) Type1Font(org.apache.fontbox.type1.Type1Font)

Aggregations

Type1Font (org.apache.fontbox.type1.Type1Font)2 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OpenTypeFont (org.apache.fontbox.ttf.OpenTypeFont)1 TrueTypeFont (org.apache.fontbox.ttf.TrueTypeFont)1