本文整理汇总了Java中com.lowagie.text.Font.BOLDITALIC属性的典型用法代码示例。如果您正苦于以下问题:Java Font.BOLDITALIC属性的具体用法?Java Font.BOLDITALIC怎么用?Java Font.BOLDITALIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.lowagie.text.Font
的用法示例。
在下文中一共展示了Font.BOLDITALIC属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
/**
* Writes the representation of a <CODE>Font</CODE>.
*
* @param font a <CODE>Font</CODE>
* @param styleAttributes the style of the font
* @throws IOException
*/
protected void write(Font font, Properties styleAttributes) throws IOException {
if (font == null || !isOtherFont(font) /* || styleAttributes == null*/) return;
write(" ");
write(HtmlTags.STYLE);
write("=\"");
if (styleAttributes != null) {
String key;
for (Enumeration e = styleAttributes.propertyNames(); e.hasMoreElements(); ) {
key = (String)e.nextElement();
writeCssProperty(key, styleAttributes.getProperty(key));
}
}
if (isOtherFont(font)) {
writeCssProperty(Markup.CSS_KEY_FONTFAMILY, font.getFamilyname());
if (font.getSize() != Font.UNDEFINED) {
writeCssProperty(Markup.CSS_KEY_FONTSIZE, font.getSize() + "pt");
}
if (font.getColor() != null) {
writeCssProperty(Markup.CSS_KEY_COLOR, HtmlEncoder.encode(font.getColor()));
}
int fontstyle = font.getStyle();
BaseFont bf = font.getBaseFont();
if (bf != null) {
String ps = bf.getPostscriptFontName().toLowerCase();
if (ps.indexOf("bold") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.BOLD;
}
if (ps.indexOf("italic") >= 0 || ps.indexOf("oblique") >= 0) {
if (fontstyle == Font.UNDEFINED)
fontstyle = 0;
fontstyle |= Font.ITALIC;
}
}
if (fontstyle != Font.UNDEFINED && fontstyle != Font.NORMAL) {
switch (fontstyle & Font.BOLDITALIC) {
case Font.BOLD:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
break;
case Font.ITALIC:
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
case Font.BOLDITALIC:
writeCssProperty(Markup.CSS_KEY_FONTWEIGHT, Markup.CSS_VALUE_BOLD);
writeCssProperty(Markup.CSS_KEY_FONTSTYLE, Markup.CSS_VALUE_ITALIC);
break;
}
// CSS only supports one decoration tag so if both are specified
// only one of the two will display
if ((fontstyle & Font.UNDERLINE) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_UNDERLINE);
}
if ((fontstyle & Font.STRIKETHRU) > 0) {
writeCssProperty(Markup.CSS_KEY_TEXTDECORATION, Markup.CSS_VALUE_LINETHROUGH);
}
}
}
write("\"");
}
示例2: main
/**
* Generates a PDF file with the 14 standard Type 1 Fonts
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("StandardType1Fonts.pdf"));
// step 3: we open the document
document.open();
// step 4:
// the 14 standard fonts in PDF: do not use this Font constructor!
// this is for demonstration purposes only, use FontFactory!
Font[] fonts = new Font[14];
fonts[0] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
fonts[1] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.ITALIC);
fonts[2] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD);
fonts[3] = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC);
fonts[4] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL);
fonts[5] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC);
fonts[6] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
fonts[7] = new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[8] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL);
fonts[9] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC);
fonts[10] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD);
fonts[11] = new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC);
fonts[12] = new Font(Font.SYMBOL);
fonts[13] = new Font(Font.ZAPFDINGBATS);
// add the content
for (int i = 0; i < 14; i++) {
document.add(new Paragraph("quick brown fox jumps over the lazy dog", fonts[i]));
}
// step 5: we close the document
document.close();
}