Example usage for org.apache.pdfbox.pdmodel.font PDFontDescriptor getFontFile2

List of usage examples for org.apache.pdfbox.pdmodel.font PDFontDescriptor getFontFile2

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel.font PDFontDescriptor getFontFile2.

Prototype

public PDStream getFontFile2() 

Source Link

Document

A stream containing a true type font program.

Usage

From source file:org.apache.fop.render.pdf.pdfbox.FOPPDFMultiByteFont.java

License:Apache License

private InputStream readFontFile(PDFont font) throws IOException {
    PDFontDescriptor fd = font.getFontDescriptor();
    if (font instanceof PDType0Font) {
        PDCIDFont cidFont = ((PDType0Font) font).getDescendantFont();
        fd = cidFont.getFontDescriptor();
    }/* ww w  .j av a  2 s .c  o  m*/
    PDStream ff = fd.getFontFile3();
    if (ff == null) {
        ff = fd.getFontFile2();
        if (ff == null) {
            ff = fd.getFontFile();
        }
    }
    if (ff == null) {
        throw new IOException(font.getName() + " no fontfile");
    }
    InputStream is = ff.createInputStream();
    return new ByteArrayInputStream(IOUtils.toByteArray(is));
}

From source file:org.apache.fop.render.pdf.pdfbox.FOPPDFSingleByteFont.java

License:Apache License

private PDStream readFontFile(PDFont font) throws IOException {
    PDFontDescriptor fd = font.getFontDescriptor();
    setFlags(fd.getFlags());/*from   ww w  .ja v  a 2s.  c  o m*/
    PDStream ff = fd.getFontFile3();
    if (ff == null) {
        ff = fd.getFontFile2();
        if (ff == null) {
            ff = fd.getFontFile();
        }
    } else {
        setFontType(FontType.TYPE1C);
    }
    if (ff == null) {
        throw new IOException(font.getName() + " no font file");
    }
    return ff;
}