List of usage examples for com.lowagie.text FontFactory COURIER_OBLIQUE
String COURIER_OBLIQUE
To view the source code for com.lowagie.text FontFactory COURIER_OBLIQUE.
Click Source Link
From source file:org.areasy.common.doclet.document.Fonts.java
License:Open Source License
public static Font getFont(int faceType, int style, int size) { Font font = null;/*from w w w . j a va 2 s . co m*/ String lookup = String.valueOf(faceType); String fontFile = fontTable.getProperty(lookup); int fontStyle = Font.NORMAL; Color color = COLOR_BLACK; if ((style & LINK) != 0) { fontStyle += Font.UNDERLINE; color = COLOR_LINK; } else if ((style & UNDERLINE) != 0) fontStyle += Font.UNDERLINE; if ((style & STRIKETHROUGH) != 0) fontStyle += Font.STRIKETHRU; if (fontFile != null) { File file = new File(DefaultConfiguration.getWorkDir(), fontFile); if (file.exists() && file.isFile()) { try { String encoding = encTable.getProperty(lookup, BaseFont.CP1252); BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED); if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLDITALIC; else fontStyle += Font.ITALIC; } else if ((style & AbstractConfiguration.BOLD) > 0) fontStyle += Font.BOLD; if (fontStyle != Font.NORMAL) font = new Font(bfComic, size, fontStyle, color); else font = new Font(bfComic, size); if (font == null) throw new IllegalArgumentException("Font null: " + fontFile); } catch (Exception e) { e.printStackTrace(); throw new IllegalArgumentException("Font unusable"); } } else DocletUtility.error("Font file not found: " + fontFile); } else { // Use predefined font String face = ""; if (faceType == TEXT_FONT) { face = FontFactory.HELVETICA; if ((style & AbstractConfiguration.ITALIC) > 0) { if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLDOBLIQUE; else face = FontFactory.HELVETICA_OBLIQUE; } else if ((style & AbstractConfiguration.BOLD) > 0) face = FontFactory.HELVETICA_BOLD; } else { face = FontFactory.COURIER; if ((style & ITALIC) > 0) { if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLDOBLIQUE; else face = FontFactory.COURIER_OBLIQUE; } else if ((style & BOLD) > 0) face = FontFactory.COURIER_BOLD; } if (fontStyle != Font.NORMAL) font = FontFactory.getFont(face, size, fontStyle, color); else font = FontFactory.getFont(face, size); } return font; }
From source file:org.unitime.timetable.util.PdfFont.java
License:Open Source License
private static Font createFont(float size, boolean fixed, boolean bold, boolean italic) { String font = null;/*from w w w . ja va 2 s .c o m*/ if (fixed) font = ApplicationProperty.PdfFontFixed.value(); else if (bold) { if (italic) font = ApplicationProperty.PdfFontBoldItalic.value(); else font = ApplicationProperty.PdfFontBold.value(); } else if (italic) font = ApplicationProperty.PdfFontItalic.value(); else font = ApplicationProperty.PdfFontNormal.value(); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size); } catch (Throwable t) { } } font = (fixed ? ApplicationProperty.PdfFontFixed.value() : ApplicationProperty.PdfFontNormal.value()); if (font != null && !font.isEmpty()) { try { BaseFont base = BaseFont.createFont(font, BaseFont.IDENTITY_H, true); if (base != null) return new Font(base, size, italic && bold ? Font.BOLDITALIC : italic ? Font.ITALIC : bold ? Font.BOLD : Font.NORMAL); } catch (Throwable t) { } } if (fixed) return FontFactory.getFont(bold ? italic ? FontFactory.COURIER_BOLDOBLIQUE : FontFactory.COURIER_BOLD : italic ? FontFactory.COURIER_OBLIQUE : FontFactory.COURIER, size); else return FontFactory .getFont(bold ? italic ? FontFactory.HELVETICA_BOLDOBLIQUE : FontFactory.HELVETICA_BOLD : italic ? FontFactory.HELVETICA_OBLIQUE : FontFactory.HELVETICA, size); }