List of usage examples for com.itextpdf.text Font isBold
public boolean isBold()
From source file:adams.core.io.PdfFont.java
License:Open Source License
/** * Generates a list of font style names from the given font setup. * * @param font the font to analyze//from w ww . j a va2 s .c o m * @return the list of font names */ public static String[] getFontFaces(Font font) { List<String> result; result = new ArrayList<String>(); if (font.isBold()) result.add(BOLD); if (font.isItalic()) result.add(ITALIC); if (font.isStrikethru()) result.add(STRIKETHRU); if (font.isUnderlined()) result.add(UNDERLINE); if (result.size() == 0) result.add(NORMAL); return result.toArray(new String[result.size()]); }
From source file:fenix.planner.pdf.PDFGenerator.java
License:Open Source License
private void parseAndAddBodyTextLineToParagraph(Paragraph paragraph, String line, Font font) { // TODO add support for additional styles // TODO add better error checking and reporting Font currentFont = new Font(font); StringBuilder sb = new StringBuilder(); for (char c : line.toCharArray()) { if (c == '*') { if (sb.length() > 0) { paragraph.add(new Phrase(sb.toString(), currentFont)); sb = new StringBuilder(); }/* www . j av a 2 s . c o m*/ if (currentFont.isBold()) { currentFont = deriveWithStyle(currentFont, currentFont.getStyle() & ~Font.BOLD); } else { currentFont = deriveWithStyle(currentFont, currentFont.getStyle() | Font.BOLD); } } else if (c == '_') { if (sb.length() > 0) { paragraph.add(new Phrase(sb.toString(), currentFont)); sb = new StringBuilder(); } if (currentFont.isItalic()) { currentFont = deriveWithStyle(currentFont, currentFont.getStyle() & ~Font.ITALIC); } else { currentFont = deriveWithStyle(currentFont, currentFont.getStyle() | Font.ITALIC); } } else { sb.append(c); } } paragraph.add(new Phrase(sb.toString(), currentFont)); }