本文整理匯總了Java中com.lowagie.text.Font.STRIKETHRU屬性的典型用法代碼示例。如果您正苦於以下問題:Java Font.STRIKETHRU屬性的具體用法?Java Font.STRIKETHRU怎麽用?Java Font.STRIKETHRU使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類com.lowagie.text.Font
的用法示例。
在下文中一共展示了Font.STRIKETHRU屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFont
public Font getFont(ChainedProperties props) {
String face = props.getProperty(ElementTags.FACE);
if (face != null) {
StringTokenizer tok = new StringTokenizer(face, ",");
while (tok.hasMoreTokens()) {
face = tok.nextToken().trim();
if (face.startsWith("\""))
face = face.substring(1);
if (face.endsWith("\""))
face = face.substring(0, face.length() - 1);
if (fontImp.isRegistered(face))
break;
}
}
int style = 0;
if (props.hasProperty(HtmlTags.I))
style |= Font.ITALIC;
if (props.hasProperty(HtmlTags.B))
style |= Font.BOLD;
if (props.hasProperty(HtmlTags.U))
style |= Font.UNDERLINE;
if (props.hasProperty(HtmlTags.S))
style |= Font.STRIKETHRU;
String value = props.getProperty(ElementTags.SIZE);
float size = 12;
if (value != null)
size = Float.parseFloat(value);
Color color = Markup.decodeColor(props.getProperty("color"));
String encoding = props.getProperty("encoding");
if (encoding == null)
encoding = BaseFont.WINANSI;
return fontImp.getFont(face, encoding, true, size, style, color);
}
示例2: 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("\"");
}