Example usage for com.itextpdf.kernel.font PdfFont getFontProgram

List of usage examples for com.itextpdf.kernel.font PdfFont getFontProgram

Introduction

In this page you can find the example usage for com.itextpdf.kernel.font PdfFont getFontProgram.

Prototype

public FontProgram getFontProgram() 

Source Link

Usage

From source file:org.reactome.server.tools.diagram.exporter.raster.itext.awt.DefaultFontMapper.java

License:Open Source License

private int extractAwtStyle(PdfFont font) {
    final FontNames fontNames = font.getFontProgram().getFontNames();
    int style = Font.PLAIN;
    if (fontNames.isBold())
        style |= Font.BOLD;/*from   www  .  j a va  2s .  c  o m*/
    if (fontNames.isItalic())
        style |= Font.ITALIC;
    return style;
}

From source file:org.reactome.server.tools.diagram.exporter.raster.itext.awt.DefaultFontMapper.java

License:Open Source License

/**
 * Returns an AWT Font which can be used to represent the given BaseFont
 *
 * @param font the font to be converted/* w  w  w  .  j av  a  2  s.  co  m*/
 * @param size the desired point size of the resulting font
 *
 * @return a Font which has similar properties to the provided BaseFont
 */

public Font pdfToAwt(PdfFont font, int size) {
    final String fontName = font.getFontProgram().getFontNames().getFontName();
    //noinspection MagicConstant
    return Font.getFont(fontName).deriveFont(extractAwtStyle(font), size);
}