Example usage for com.lowagie.text.pdf BaseFont createFont

List of usage examples for com.lowagie.text.pdf BaseFont createFont

Introduction

In this page you can find the example usage for com.lowagie.text.pdf BaseFont createFont.

Prototype

public static BaseFont createFont(String name, String encoding, boolean embedded, boolean cached, byte ttfAfm[],
        byte pfb[], boolean noThrow) throws DocumentException, IOException 

Source Link

Document

Creates a new font.

Usage

From source file:com.moss.check.us.CheckPdfRenderer.java

License:Open Source License

private BaseFont createMicrFont() throws Exception {

    boolean cached = true;
    byte[] ttf;/*from   w  w  w.j a  v a2 s.c o m*/
    {
        InputStream in = CheckPdfRenderer.class.getResourceAsStream("/com/moss/check/us/GnuMICR.ttf");
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] buffer = new byte[1024 * 10]; //10k buffer
        for (int numRead = in.read(buffer); numRead != -1; numRead = in.read(buffer)) {
            out.write(buffer, 0, numRead);
        }

        ttf = out.toByteArray();
    }
    byte[] pfb = null;
    boolean noThrow = false;

    BaseFont baseFont = BaseFont.createFont("GnuMICR.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, cached, ttf,
            pfb, noThrow);

    return baseFont;
}

From source file:com.moss.check.us.CheckPdfRenderer.java

License:Open Source License

private BaseFont createFixedFont() throws Exception {

    boolean cached = true;
    byte[] ttf;/*from w  w  w .  j av  a2 s  .  co m*/
    {
        InputStream in = CheckPdfRenderer.class.getResourceAsStream("/com/moss/check/us/VeraMono.ttf");
        ByteArrayOutputStream out = new ByteArrayOutputStream();

        byte[] buffer = new byte[1024 * 10]; //10k buffer
        for (int numRead = in.read(buffer); numRead != -1; numRead = in.read(buffer)) {
            out.write(buffer, 0, numRead);
        }

        ttf = out.toByteArray();
    }
    byte[] pfb = null;
    boolean noThrow = false;

    BaseFont baseFont = BaseFont.createFont("VeraMono.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, cached, ttf,
            pfb, noThrow);

    return baseFont;
}

From source file:mpv5.utils.xdocreport.YabsFontFactoryImpl.java

License:Open Source License

private Font buildFont(Fonts f) {
    File tmp = f.__getFont();/*from  www . jav a 2 s . c  o m*/
    if (!"empty".equals(f.__getFilename()) && (tmp == null || !tmp.exists())) {
        f.delete();
        return null;
    }
    String key = f.__getCname() + "#" + f.__getEncoding() + "#";
    if (f.__isEmbedded()) {
        key += "1" + "#" + f.__getSize() + "#" + f.__getStyle() + "#";
    } else {
        key += "0" + "#" + +f.__getSize() + "#" + f.__getStyle() + "#";
    }
    key += f.__getColor();
    BaseFont basefont;
    Font font = null;
    try {
        if (!"empty".equals(f.__getFilename())) {
            basefont = BaseFont.createFont(f.__getFont().getAbsolutePath(), f.__getEncoding(), f.__isEmbedded(),
                    true, null, null, true);
            font = new Font(basefont, f.__getSize(), f.__getStyle(), new Color(f.__getColor()));
        } else {
            font = new Font(Font.UNDEFINED, f.__getSize(), f.__getStyle(), new Color(f.__getColor()));
        }
        used.put(key, font);
    } catch (DocumentException ex) {
        Log.Debug(this, ex.getLocalizedMessage());
    } catch (IOException ex) {
        Log.Debug(this, ex.getLocalizedMessage());
    }
    return font;
}