Java Code Examples for com.lowagie.text.Font#UNDEFINED
The following examples show how to use
com.lowagie.text.Font#UNDEFINED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Replaces the attributes that are equal to <VAR>null</VAR> with * the attributes of a given font. * * @param font The surrounding font * @return A RtfFont */ public Font difference(Font font) { String dFamilyname = font.getFamilyname(); if(dFamilyname == null || dFamilyname.trim().equals("") || dFamilyname.trim().equalsIgnoreCase("unknown")) { dFamilyname = this.fontName; } float dSize = font.getSize(); if(dSize == Font.UNDEFINED) { dSize = this.getSize(); } int dStyle = Font.UNDEFINED; if(this.getStyle() != Font.UNDEFINED && font.getStyle() != Font.UNDEFINED) { dStyle = this.getStyle() | font.getStyle(); } else if(this.getStyle() != Font.UNDEFINED) { dStyle = this.getStyle(); } else if(font.getStyle() != Font.UNDEFINED) { dStyle = font.getStyle(); } Color dColor = font.getColor(); if(dColor == null) { dColor = this.getColor(); } int dCharset = this.charset; if(font instanceof RtfFont) { dCharset = ((RtfFont) font).getCharset(); } return new RtfFont(dFamilyname, dSize, dStyle, dColor, dCharset); }
Example 2
Source File: HtmlWriter.java From gcs with Mozilla Public License 2.0 | 4 votes |
/** * 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("\""); }
Example 3
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Writes the font beginning * * @param result The <code>OutputStream</code> to write to. * @throws IOException On i/o errors. */ public void writeBegin(final OutputStream result) throws IOException { if(this.fontNumber != Font.UNDEFINED) { result.write(RtfFontList.FONT_NUMBER); result.write(intToByteArray(fontNumber)); } if(this.fontSize != Font.UNDEFINED) { result.write(FONT_SIZE); result.write(intToByteArray(fontSize * 2)); } if(this.fontStyle != UNDEFINED) { if((fontStyle & STYLE_BOLD) == STYLE_BOLD) { result.write(FONT_BOLD); } if((fontStyle & STYLE_ITALIC) == STYLE_ITALIC) { result.write(FONT_ITALIC); } if((fontStyle & STYLE_UNDERLINE) == STYLE_UNDERLINE) { result.write(FONT_UNDERLINE); } if((fontStyle & STYLE_STRIKETHROUGH) == STYLE_STRIKETHROUGH) { result.write(FONT_STRIKETHROUGH); } if((fontStyle & STYLE_HIDDEN) == STYLE_HIDDEN) { result.write(FONT_HIDDEN); } if((fontStyle & STYLE_DOUBLE_STRIKETHROUGH) == STYLE_DOUBLE_STRIKETHROUGH) { result.write(FONT_DOUBLE_STRIKETHROUGH); result.write(intToByteArray(1)); } if((fontStyle & STYLE_SHADOW) == STYLE_SHADOW) { result.write(FONT_SHADOW); } if((fontStyle & STYLE_OUTLINE) == STYLE_OUTLINE) { result.write(FONT_OUTLINE); } if((fontStyle & STYLE_EMBOSSED) == STYLE_EMBOSSED) { result.write(FONT_EMBOSSED); } if((fontStyle & STYLE_ENGRAVED) == STYLE_ENGRAVED) { result.write(FONT_ENGRAVED); } } if(color != null) { color.writeBegin(result); } }
Example 4
Source File: HtmlWriter.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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("\""); }
Example 5
Source File: MarkupParser.java From MesquiteCore with GNU Lesser General Public License v3.0 | 4 votes |
/** * Retrieves a font from the FontFactory based on some style attributes. * Looks for the font-family, font-size, font-weight, font-style and color. * Takes the default encoding and embedded value. * @param styleAttributes a Properties object containing keys and values * @return an iText Font object */ public Font retrieveFont(Properties styleAttributes) { String fontname = null; String encoding = FontFactory.defaultEncoding; boolean embedded = FontFactory.defaultEmbedding; float size = Font.UNDEFINED; int style = Font.NORMAL; Color color = null; String value = (String)styleAttributes.get(MarkupTags.CSS_KEY_FONTFAMILY); if (value != null) { if (value.indexOf(",") == -1) { fontname = value.trim(); } else { String tmp; while (value.indexOf(",") != -1) { tmp = value.substring(0, value.indexOf(",")).trim(); if (FontFactory.isRegistered(tmp)) { fontname = tmp; break; } else { value = value.substring(value.indexOf(",") + 1); } } } } if ((value = (String)styleAttributes.get(MarkupTags.CSS_KEY_FONTSIZE)) != null) { size = MarkupParser.parseLength(value); } if ((value = (String)styleAttributes.get(MarkupTags.CSS_KEY_FONTWEIGHT)) != null) { style |= Font.getStyleValue(value); } if ((value = (String)styleAttributes.get(MarkupTags.CSS_KEY_FONTSTYLE)) != null) { style |= Font.getStyleValue(value); } if ((value = (String)styleAttributes.get(MarkupTags.CSS_KEY_COLOR)) != null) { color = MarkupParser.decodeColor(value); } return FontFactory.getFont(fontname, encoding, embedded, size, style, color); }
Example 6
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs a RtfFont with the given font name and all other properties * at their default values. * * @param fontName The font name to use */ public RtfFont(String fontName) { super(Font.UNDEFINED, Font.UNDEFINED, Font.UNDEFINED, null); this.fontName = fontName; }
Example 7
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs a RtfFont with the given font name and font size and all other * properties at their default values. * * @param fontName The font name to use * @param size The font size to use */ public RtfFont(String fontName, float size) { super(Font.UNDEFINED, size, Font.UNDEFINED, null); this.fontName = fontName; }
Example 8
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs a RtfFont with the given font name, font size and font style and the * default color. * * @param fontName The font name to use * @param size The font size to use * @param style The font style to use */ public RtfFont(String fontName, float size, int style) { super(Font.UNDEFINED, size, style, null); this.fontName = fontName; }
Example 9
Source File: RtfFont.java From itext2 with GNU Lesser General Public License v3.0 | 2 votes |
/** * Constructs a RtfFont with the given font name, font size, font style and * color. * * @param fontName The font name to use * @param size the font size to use * @param style The font style to use * @param color The font color to use */ public RtfFont(String fontName, float size, int style, Color color) { super(Font.UNDEFINED, size, style, color); this.fontName = fontName; }