Example usage for com.lowagie.text Font BOLD

List of usage examples for com.lowagie.text Font BOLD

Introduction

In this page you can find the example usage for com.lowagie.text Font BOLD.

Prototype

int BOLD

To view the source code for com.lowagie.text Font BOLD.

Click Source Link

Document

this is a possible style.

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  w  w  w  . j  a  va  2  s.  co m
    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.eclipse.birt.report.engine.emitter.ppt.PPTWriter.java

License:Open Source License

/**
 * Draws a chunk of text on the PPT./*from www  . j av  a2  s  . com*/
 * 
 * @param text
 *            the textArea to be drawn.
 * @param textX
 *            the X position of the textArea relative to current page.
 * @param textY
 *            the Y position of the textArea relative to current page.
 * @param width
 *            the Width of the textArea
 * @param height
 *              the height of the textArea
 * @param textStyle
 *            the style of the textArea
 * @param link
 *            the hyperlink of the textArea
 */
public void drawText(String text, float textX, float textY, float width, float height, TextStyle textStyle,
        HyperlinkDef link) {
    FontInfo fontInfo = textStyle.getFontInfo();
    Color color = textStyle.getColor();
    boolean rtl = textStyle.isRtl();

    if (fontInfo == null) {
        return;
    }

    float descend = fontInfo.getBaseFont().getFontDescriptor(BaseFont.DESCENT, fontInfo.getFontSize());
    height = height + descend * 0.6f;

    BaseFont baseFont = fontInfo.getBaseFont();
    String fontName = getFontName(baseFont);

    println("<v:shape id=3D\"_x0000_s" + (++shapeCount) + "\" type=3D\"#_x0000_t202\""); //$NON-NLS-1$ //$NON-NLS-2$
    println(" style=3D'position:absolute;left:" + textX + "pt;top:" + textY + "pt;width:" + width + "pt;height:" //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            + height + "pt;v-text-anchor:bottom-baseline;mso-wrap-style:none;'"); //$NON-NLS-1$
    println(" filled=3D'f' stroked=3D'f'>"); //$NON-NLS-1$
    println("<v:textbox style=3D'mso-fit-shape-to-text:f;' inset=3D'0.00pt 0.00pt 0.00pt 0.00pt'/>"); //$NON-NLS-1$
    println("</v:shape>"); //$NON-NLS-1$
    println("<div v:shape=3D\"_x0000_s" + shapeCount + "\">"); //$NON-NLS-1$ //$NON-NLS-2$

    println("<div style=3D'mso-text-indent-alt:" //$NON-NLS-1$
            + 0 + ";text-align:left;'>" //$NON-NLS-1$
            + "<span style=3D'font-family:" //$NON-NLS-1$
            + fontName + ";font-size:" //$NON-NLS-1$
            + fontInfo.getFontSize() + "pt;color:#" //$NON-NLS-1$
            + getColorString(color) + ";'" + buildI18nAttributes(text, rtl) + ">"); //$NON-NLS-2$

    boolean isItalic = fontInfo != null && (fontInfo.getFontStyle() & Font.ITALIC) != 0;
    boolean isBold = fontInfo != null && (fontInfo.getFontStyle() & Font.BOLD) != 0;

    boolean isUnderline = textStyle.isUnderline();

    if (isItalic) {
        print("<i>");
    }
    if (isBold) {
        print("<b>");
    }
    if (isUnderline) {
        print("<u>");
    }
    if (link != null) {
        String hyperlink = link.getLink();
        String tooltip = link.getTooltip();
        if (hyperlink != null) {
            hyperlink = codeLink(hyperlink);
            print("<p:onmouseclick  hyperlinktype=3D\"url\" href=3D\"" + hyperlink + "\"");
            if (tooltip != null) {
                tooltip = codeLink(tooltip);
                print(" tips=3D\"" + tooltip + "\"");
            }
            println("/><a href=3D\"" + hyperlink
                    + "/\" target=3D\"_parent\" onclick=3D\"window.event.cancelBubble=3Dtrue;\">");
        }
    }
    print(getEscapedStr(text));
    if (link != null) {
        print("</a>");
    }
    if (isUnderline) {
        print("</u>");
    }
    if (isBold) {
        print("</b>");
    }
    if (isItalic) {
        print("</i>");
    }
    println("</span></div>"); //$NON-NLS-1$
    println("</div>"); //$NON-NLS-1$
}

From source file:org.eclipse.birt.report.engine.emitter.pptx.PPTXCanvas.java

License:Open Source License

private void setTextProperty(String fontName, float fontSize, int fontStyle, Color color, boolean isUnderline,
        boolean isLineThrough, HyperlinkDef link) {
    writer.openTag("a:rPr");
    writer.attribute("lang", "en-US");
    writer.attribute("altLang", "zh-CN");
    writer.attribute("dirty", "0");
    writer.attribute("smtClean", "0");
    if (isLineThrough) {
        writer.attribute("strike", "sngStrike");
    }//from  ww w  .  j av  a 2s  .  c  o  m
    if (isUnderline) {
        writer.attribute("u", "sng");
    }
    writer.attribute("sz", (int) (fontSize * 100));
    boolean isItalic = (fontStyle & Font.ITALIC) != 0;
    boolean isBold = (fontStyle & Font.BOLD) != 0;
    if (isItalic) {
        writer.attribute("i", 1);
    }
    if (isBold) {
        writer.attribute("b", 1);
    }
    setBackgroundColor(color);
    setTextFont(fontName);
    setHyperlink(link);
    writer.closeTag("a:rPr");
}

From source file:org.eclipse.birt.report.engine.emitter.pptx.writer.Slide.java

License:Open Source License

private void setTextProperty(String fontName, float fontSize, int fontStyle, Color color, boolean isUnderline,
        boolean isLineThrough, HyperlinkDef link) {
    writer.openTag("a:rPr");
    writer.attribute("lang", "en-US");
    writer.attribute("altLang", "zh-CN");
    writer.attribute("dirty", "0");
    writer.attribute("smtClean", "0");
    if (isLineThrough) {
        writer.attribute("strike", "sngStrike");
    }/*from  www.  java2  s  .c o m*/
    if (isUnderline) {
        writer.attribute("u", "sng");
    }
    writer.attribute("sz", (int) (fontSize * 100));
    boolean isItalic = (fontStyle & Font.ITALIC) != 0;
    boolean isBold = (fontStyle & Font.BOLD) != 0;
    if (isItalic) {
        writer.attribute("i", 1);
    }
    if (isBold) {
        writer.attribute("b", 1);
    }
    setColor(color);
    setTextFont(fontName);
    setHyperlink(link);
    writer.closeTag("a:rPr");
}

From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.java

License:Open Source License

/**
 * The constructor/*from   ww w. j  a  v a 2 s .  com*/
 * 
 * @param textContent
 *            the textContent whose font need to be handled
 * @param fontSubstitution
 *            If it set to false, we needn't check if the character exists
 *            in the selected font.
 * @param format
 *            the output format type
 */
public FontHandler(FontMappingManager fontManager, ITextContent textContent, boolean fontSubstitution) {
    this.fontManager = fontManager;

    IStyle style = textContent.getComputedStyle();

    CSSValueList families = (CSSValueList) style.getProperty(StyleConstants.STYLE_FONT_FAMILY);
    this.fontFamilies = new String[families.getLength()];
    for (int i = 0; i < fontFamilies.length; i++) {
        fontFamilies[i] = families.item(i).getCssText();
    }

    this.fontWeight = PropertyUtil.parseFontWeight(style.getProperty(StyleConstants.STYLE_FONT_WEIGHT));

    if (CSSConstants.CSS_OBLIQUE_VALUE.equals(style.getFontStyle())
            || CSSConstants.CSS_ITALIC_VALUE.equals(style.getFontStyle())) {
        this.fontStyle |= Font.ITALIC;
    }

    if (PropertyUtil.isBoldFont(fontWeight)) {
        this.fontStyle |= Font.BOLD;
    }

    this.fontSize = PropertyUtil.getDimensionValueConsiderDpi(style.getProperty(StyleConstants.STYLE_FONT_SIZE),
            textContent) / PDFConstants.LAYOUT_TO_PDF_RATIO;

    if (!fontSubstitution) {
        for (int i = 0; i < fontFamilies.length; i++) {
            String fontName = fontManager.getAliasedFont(fontFamilies[i]);
            bf = fontManager.createFont(fontName, fontStyle);
            if (bf != null)
                return;
        }
        bf = fontManager.createFont(FontMappingManager.DEFAULT_FONT, fontStyle);
    }
}

From source file:org.eclipse.birt.report.engine.layout.pdf.font.FontHandler.java

License:Open Source License

/**
 * If the BaseFont can NOT find the correct physical glyph, we need to
 * simulate the proper style for the font. The "simulate" flag will be set
 * if we need to simulate it./*from  w  ww. j av  a  2  s.co  m*/
 */
private boolean needSimulate(BaseFont font) {
    if (fontStyle == Font.NORMAL) {
        return false;
    }

    String[][] fullNames = bf.getFullFontName();
    String fullName = getEnglishName(fullNames);
    String lcf = fullName.toLowerCase();

    int fs = Font.NORMAL;
    if (lcf.indexOf("bold") != -1) {
        fs |= Font.BOLD;
    }
    if (lcf.indexOf("italic") != -1 || lcf.indexOf("oblique") != -1) {
        fs |= Font.ITALIC;
    }
    if ((fontStyle & Font.BOLDITALIC) == fs) {
        if (fontWeight > 400 && fontWeight != 700) {
            // not a regular bold font.
            return true;
        } else {
            return false;
        }
    }
    return true;
}

From source file:org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil.java

License:Open Source License

public static int getFontStyle(String fontStyle, String fontWeight) {
    int styleValue = Font.NORMAL;

    if (CSSConstants.CSS_OBLIQUE_VALUE.equals(fontStyle) || CSSConstants.CSS_ITALIC_VALUE.equals(fontStyle)) {
        styleValue |= Font.ITALIC;
    }/*from   w  ww . ja  va2 s. c  o  m*/

    if (CSSConstants.CSS_BOLD_VALUE.equals(fontWeight) || CSSConstants.CSS_BOLDER_VALUE.equals(fontWeight)
            || CSSConstants.CSS_600_VALUE.equals(fontWeight) || CSSConstants.CSS_700_VALUE.equals(fontWeight)
            || CSSConstants.CSS_800_VALUE.equals(fontWeight) || CSSConstants.CSS_900_VALUE.equals(fontWeight)) {
        styleValue |= Font.BOLD;
    }
    return styleValue;
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeHeader(Table table, String[] headers) throws Exception {
    for (String header : headers) {
        Cell cell = new Cell();
        cell.setHeader(true);//w w w .j a v a 2s  . co m
        cell.setColspan(1);
        cell.setBackgroundColor(WebColors.getRGBColor("#d9d9d9"));
        cell.setHorizontalAlignment(ElementTags.ALIGN_CENTER);

        Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.BOLD,
                WebColors.getRGBColor("#000000"));
        Paragraph paragraph = new Paragraph(header, font);
        paragraph.setAlignment(ElementTags.ALIGN_CENTER);
        cell.add(paragraph);
        table.addCell(cell);
    }
}

From source file:org.eclipse.osee.framework.ui.skynet.util.TableWriterAdaptor.java

License:Open Source License

public void writeDocument() throws DocumentException {
    Font font = FontFactory.getFont("Times New Roman", BaseFont.CP1252, BaseFont.EMBEDDED, 9, Font.BOLD,
            WebColors.getRGBColor("#000000"));
    Paragraph paragraph = new Paragraph(title, font);
    paragraph.setAlignment(ElementTags.ALIGN_CENTER);
    document.add(paragraph);/*from w  ww  . j a va2 s .  c  om*/
    if (table != null) {
        document.add(table);
    }
}

From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java

License:Open Source License

protected Font getCaptionFont() {
    return FontFactory.getFont(FontFactory.HELVETICA, 17, Font.BOLD, new Color(0x00, 0x00, 0x00));
}