Class RtfFont
java.lang.Object
com.lowagie.text.Font
com.lowagie.text.rtf.style.RtfFont
- All Implemented Interfaces:
RtfBasicElement, RtfExtendedElement, Comparable
- Direct Known Subclasses:
RtfParagraphStyle
The RtfFont class stores one font for an rtf document. It extends Font,
so can be set as a font, to allow adding of fonts with arbitrary names.
BaseFont fontname handling contributed by Craig Fleming. Various fixes
Renaud Michel, Werner Daehn.
Version: $Id: RtfFont.java 4008 2009-07-07 09:56:52Z blowagie $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe character set to use for this fontprivate RtfColorThe color of this fontstatic final StringDefault fontprotected RtfDocumentThe RtfDocument this RtfFont belongs to.private static final byte[]Constant for the bold flagprivate static final byte[]Constant for the charsetprivate static final byte[]Constant for the double strikethrough flagprivate static final byte[]Constant for the embossed flagprivate static final byte[]Constant for the engraved flagprivate static final byte[]Constant for the font family to use ("froman")private static final byte[]Constant for hidden text flagprivate static final byte[]Constant for the italic flagprivate static final byte[]Constant for the outline flagprivate static final byte[]Constant for the shadow flagstatic final byte[]Constant for the font sizeprivate static final byte[]Constant for the strikethrough flagprivate static final byte[]Constant for the underline flagprivate StringThe font name.private intThe number of this fontprivate intThe font size.private intThe font style.static final intConstant for a bold fontstatic final intConstant for a double strikethrough fontstatic final intConstant for an embossed fontstatic final intConstant for an engraved fontstatic final intConstant for a font that hides the actual text.static final intConstant for an italic fontstatic final intConstant for a plain fontstatic final intConstant for an outlined fontstatic final intConstant for a shadowed fontstatic final intConstant for a strikethrough fontstatic final intConstant for an underlined fontFields inherited from class com.lowagie.text.Font
BOLD, BOLDITALIC, COURIER, DEFAULTSIZE, HELVETICA, ITALIC, NORMAL, STRIKETHRU, SYMBOL, TIMES_ROMAN, UNDEFINED, UNDERLINE, ZAPFDINGBATSFields inherited from interface RtfBasicElement
CLOSE_GROUP, COMMA_DELIMITER, DELIMITER, OPEN_GROUP, TWIPS_FACTOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRtfFont(RtfDocument doc, int fontNumber) Special constructor for the default fontRtfFont(RtfDocument doc, com.lowagie.text.Font font) Constructs a RtfFont from a com.lowagie.text.FontConstructs a RtfFont with the given font name and all other properties at their default values.Constructs a RtfFont with the given font name and font size and all other properties at their default values.Constructs a RtfFont with the given font name, font size and font style and the default color.Constructs a RtfFont with the given font name, font size, font style and color.Constructs a RtfFont with the given font name, font size, font style, color and charset. -
Method Summary
Modifier and TypeMethodDescriptionintCompares thisRtfFontto either aFontor anRtfFont.com.lowagie.text.Fontdifference(com.lowagie.text.Font font) Replaces the attributes that are equal to null with the attributes of a given font.booleanTests for equality of RtfFonts.intGets the charset used for constructing this RtfFont.Gets the font name of this RtfFontintGets the font number of this RtfFontintGets the font size of this RtfFontintGets the font style of this RtfFontinthashCode()Returns the hash code of this RtfFont.protected byte[]intToByteArray(int i) Transforms an integer into its String representation and then returns the bytes of that string.booleanTheRtfFontis never a standard font.voidsetCharset(int charset) Sets the charset used for constructing this RtfFont.voidsetColor(int red, int green, int blue) voidvoidprotected voidsetFontName(String fontName) Sets the font name of this RtfFont.voidsetInHeader(boolean inHeader) UnusedvoidsetInTable(boolean inTable) UnusedvoidSets the RtfDocument this RtfFont belongs tovoidsetSize(float size) voidsetStyle(int style) voidprivate voidsetToDefaultFamily(String familyname) Sets the correct font name from the family name.voidwriteBegin(OutputStream result) Writes the font beginningvoidwriteContent(OutputStream out) unusedvoidwriteDefinition(OutputStream result) Writes the font definitionvoidwriteEnd(OutputStream result) Write the font endMethods inherited from class com.lowagie.text.Font
getBaseFont, getBaseFontStyle, getCalculatedBaseFont, getCalculatedLeading, getCalculatedSize, getCalculatedStyle, getColor, getCombinedStyle, getFamily, getFamilyIndex, getFontStyleFromName, getSize, getStyle, getStyleValue, isBold, isItalic, isStrikethru, isUnderlined
-
Field Details
-
FONT_FAMILY
private static final byte[] FONT_FAMILYConstant for the font family to use ("froman") -
FONT_CHARSET
private static final byte[] FONT_CHARSETConstant for the charset -
FONT_SIZE
public static final byte[] FONT_SIZEConstant for the font size -
FONT_BOLD
private static final byte[] FONT_BOLDConstant for the bold flag -
FONT_ITALIC
private static final byte[] FONT_ITALICConstant for the italic flag -
FONT_UNDERLINE
private static final byte[] FONT_UNDERLINEConstant for the underline flag -
FONT_STRIKETHROUGH
private static final byte[] FONT_STRIKETHROUGHConstant for the strikethrough flag -
FONT_DOUBLE_STRIKETHROUGH
private static final byte[] FONT_DOUBLE_STRIKETHROUGHConstant for the double strikethrough flag -
FONT_SHADOW
private static final byte[] FONT_SHADOWConstant for the shadow flag -
FONT_OUTLINE
private static final byte[] FONT_OUTLINEConstant for the outline flag -
FONT_EMBOSSED
private static final byte[] FONT_EMBOSSEDConstant for the embossed flag -
FONT_ENGRAVED
private static final byte[] FONT_ENGRAVEDConstant for the engraved flag -
FONT_HIDDEN
private static final byte[] FONT_HIDDENConstant for hidden text flag -
STYLE_NONE
public static final int STYLE_NONEConstant for a plain font- See Also:
-
STYLE_BOLD
public static final int STYLE_BOLDConstant for a bold font- See Also:
-
STYLE_ITALIC
public static final int STYLE_ITALICConstant for an italic font- See Also:
-
STYLE_UNDERLINE
public static final int STYLE_UNDERLINEConstant for an underlined font- See Also:
-
STYLE_STRIKETHROUGH
public static final int STYLE_STRIKETHROUGHConstant for a strikethrough font- See Also:
-
STYLE_DOUBLE_STRIKETHROUGH
public static final int STYLE_DOUBLE_STRIKETHROUGHConstant for a double strikethrough font- See Also:
-
STYLE_SHADOW
public static final int STYLE_SHADOWConstant for a shadowed font- See Also:
-
STYLE_OUTLINE
public static final int STYLE_OUTLINEConstant for an outlined font- See Also:
-
STYLE_EMBOSSED
public static final int STYLE_EMBOSSEDConstant for an embossed font- See Also:
-
STYLE_ENGRAVED
public static final int STYLE_ENGRAVEDConstant for an engraved font- See Also:
-
STYLE_HIDDEN
public static final int STYLE_HIDDENConstant for a font that hides the actual text.- See Also:
-
DEFAULT_FONT
-
fontName
The font name. Defaults to "Times New Roman" -
fontSize
private int fontSizeThe font size. Defaults to 10 -
fontStyle
private int fontStyleThe font style. Defaults to STYLE_NONE -
fontNumber
private int fontNumberThe number of this font -
color
The color of this font -
charset
private int charsetThe character set to use for this font -
document
The RtfDocument this RtfFont belongs to.
-
-
Constructor Details
-
RtfFont
Constructs a RtfFont with the given font name and all other properties at their default values.- Parameters:
fontName- The font name to use
-
RtfFont
Constructs a RtfFont with the given font name and font size and all other properties at their default values.- Parameters:
fontName- The font name to usesize- The font size to use
-
RtfFont
Constructs a RtfFont with the given font name, font size and font style and the default color.- Parameters:
fontName- The font name to usesize- The font size to usestyle- The font style to use
-
RtfFont
-
RtfFont
Constructs a RtfFont with the given font name, font size, font style, color and charset. This can be used when generating non latin-1 text.- Parameters:
fontName- The font name to usesize- the font size to usestyle- The font style to usecolor- The font color to usecharset- The charset of the font content
-
RtfFont
Special constructor for the default font- Parameters:
doc- The RtfDocument this font appears infontNumber- The id of this font
-
RtfFont
Constructs a RtfFont from a com.lowagie.text.Font- Parameters:
doc- The RtfDocument this font appears infont- The Font to use as a base
-
-
Method Details
-
writeDefinition
Writes the font definition- Specified by:
writeDefinitionin interfaceRtfExtendedElement- Parameters:
result- TheOutputStreamto write the element definition to- Throws:
IOException
-
writeBegin
Writes the font beginning- Parameters:
result- TheOutputStreamto write to.- Throws:
IOException- On i/o errors.
-
writeEnd
Write the font end- Parameters:
result- TheOutputStreamto write to.- Throws:
IOException- On i/o errors.
-
writeContent
unused- Specified by:
writeContentin interfaceRtfBasicElement- Parameters:
out- TheOutputStreamto write the content to- Throws:
IOException
-
equals
Tests for equality of RtfFonts. RtfFonts are equal if their fontName, fontSize, fontStyle and fontSuperSubscript are equal -
hashCode
-
getFontName
-
setFontName
Sets the font name of this RtfFont.- Parameters:
fontName- The font name to use
-
getFamilyname
- Overrides:
getFamilynamein classcom.lowagie.text.Font- See Also:
-
setFamily
- Overrides:
setFamilyin classcom.lowagie.text.Font- See Also:
-
setToDefaultFamily
Sets the correct font name from the family name.- Parameters:
familyname- The family name to set the name to.
-
getFontSize
public int getFontSize()Gets the font size of this RtfFont- Returns:
- The font size
-
setSize
public void setSize(float size) - Overrides:
setSizein classcom.lowagie.text.Font- See Also:
-
getFontStyle
public int getFontStyle()Gets the font style of this RtfFont- Returns:
- The font style
-
setStyle
public void setStyle(int style) - Overrides:
setStylein classcom.lowagie.text.Font- See Also:
-
setStyle
- Overrides:
setStylein classcom.lowagie.text.Font- See Also:
-
getCharset
public int getCharset()Gets the charset used for constructing this RtfFont.- Returns:
- The charset of this RtfFont.
-
setCharset
public void setCharset(int charset) Sets the charset used for constructing this RtfFont.- Parameters:
charset- The charset to use.
-
getFontNumber
public int getFontNumber()Gets the font number of this RtfFont- Returns:
- The font number
-
setRtfDocument
Sets the RtfDocument this RtfFont belongs to- Specified by:
setRtfDocumentin interfaceRtfBasicElement- Parameters:
doc- The RtfDocument to use
-
setInTable
public void setInTable(boolean inTable) Unused- Specified by:
setInTablein interfaceRtfBasicElement- Parameters:
inTable-
-
setInHeader
public void setInHeader(boolean inHeader) Unused- Specified by:
setInHeaderin interfaceRtfBasicElement- Parameters:
inHeader-
-
setColor
- Overrides:
setColorin classcom.lowagie.text.Font- See Also:
-
setColor
public void setColor(int red, int green, int blue) - Overrides:
setColorin classcom.lowagie.text.Font- See Also:
-
intToByteArray
protected byte[] intToByteArray(int i) Transforms an integer into its String representation and then returns the bytes of that string.- Parameters:
i- The integer to convert- Returns:
- A byte array representing the integer
-
difference
public com.lowagie.text.Font difference(com.lowagie.text.Font font) Replaces the attributes that are equal to null with the attributes of a given font.- Overrides:
differencein classcom.lowagie.text.Font- Parameters:
font- The surrounding font- Returns:
- A RtfFont
-
isStandardFont
public boolean isStandardFont()TheRtfFontis never a standard font.- Overrides:
isStandardFontin classcom.lowagie.text.Font- Since:
- 2.1.0
-
compareTo
Compares thisRtfFontto either aFontor anRtfFont.- Specified by:
compareToin interfaceComparable- Overrides:
compareToin classcom.lowagie.text.Font- Since:
- 2.1.0
-