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

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

Introduction

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

Prototype

public abstract String getPostscriptFontName();

Source Link

Document

Gets the postscript font name.

Usage

From source file:org.eclipse.birt.report.engine.emitter.postscript.PostscriptWriter.java

License:Open Source License

public void drawString(String str, float x, float y, FontInfo fontInfo, float letterSpacing, float wordSpacing,
        Color color, boolean linethrough, boolean overline, boolean underline, CSSValue align) {
    y = transformY(y);/*from www  .j av a 2s.  com*/
    String text = str;
    boolean needSimulateItalic = false;
    boolean needSimulateBold = false;
    boolean hasSpace = wordSpacing != 0 || letterSpacing != 0;
    float offset = 0;
    if (fontInfo != null) {
        float fontSize = fontInfo.getFontSize();
        int fontStyle = fontInfo.getFontStyle();
        if (fontInfo.getSimulation()) {
            if (fontStyle == Font.BOLD || fontStyle == Font.BOLDITALIC) {
                offset = (float) (fontSize * Math.log10(fontSize) / 100);
                needSimulateBold = true;
            }
            if (fontStyle == Font.ITALIC || fontStyle == Font.BOLDITALIC) {
                needSimulateItalic = true;
            }
        }
        BaseFont baseFont = fontInfo.getBaseFont();
        String fontName = baseFont.getPostscriptFontName();
        text = applyFont(fontName, fontStyle, fontSize, text);
    }
    outputColor(color);
    out.print(x + " " + y + " ");
    if (hasSpace)
        out.print(wordSpacing + " " + letterSpacing + " ");
    out.print(text + " ");
    if (needSimulateBold)
        out.print(offset + " ");
    String command = getCommand(hasSpace, needSimulateBold, needSimulateItalic);
    out.println(command);
}

From source file:org.projectforge.framework.renderer.FontMap.java

License:Open Source License

public void loadFonts(File fontDir) {
    @SuppressWarnings("unchecked")
    final Collection<File> files = FileUtils.listFiles(fontDir, new String[] { "afm" }, true); // Read all afm files recursively.
    if (CollectionUtils.isNotEmpty(files) == true) {
        for (File file : files) {
            BaseFont font = null;
            try {
                font = BaseFont.createFont(file.getAbsolutePath(), BaseFont.CP1252, BaseFont.EMBEDDED);
            } catch (DocumentException ex) {
                log.error("Error while loading font '" + file.getAbsolutePath() + "': " + ex.getMessage(), ex);
                continue;
            } catch (IOException ex) {
                log.error("Error while loading font '" + file.getAbsolutePath() + "': " + ex.getMessage(), ex);
                continue;
            }/*w  w  w  .  j  ava 2  s .  com*/
            final String fontName = font.getPostscriptFontName();
            fontMap.put(fontName, font);
        }
    }
}