com.lowagie.text

Class Font

public class Font extends Object implements Comparable

Contains all the specifications of a font: fontfamily, size, style and color.

Example:

 
 Paragraph p = new Paragraph("This is a paragraph", new
 Font(Font.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)) );
 
 
Field Summary
BaseFontbaseFont
the external font
static intBOLD
this is a possible style.
static intBOLDITALIC
this is a possible style.
Colorcolor
the value of the color.
static intCOURIER
a possible value of a font family.
static intDEFAULTSIZE
the value of the default size.
intfamily
the value of the fontfamily.
static intHELVETICA
a possible value of a font family.
static intITALIC
this is a possible style.
static intNORMAL
this is a possible style.
floatsize
the value of the fontsize.
intstyle
the value of the style.
static intSTRIKETHRU
this is a possible style.
static intSYMBOL
a possible value of a font family.
static intTIMES_ROMAN
a possible value of a font family.
static intUNDEFINED
the value of an undefined attribute.
static intUNDERLINE
this is a possible style.
static intZAPFDINGBATS
a possible value of a font family.
Constructor Summary
Font(Font other)
Copy constructor of a Font
Font(int family, float size, int style, Color color)
Constructs a Font.
Font(BaseFont bf, float size, int style, Color color)
Constructs a Font.
Font(BaseFont bf, float size, int style)
Constructs a Font.
Font(BaseFont bf, float size)
Constructs a Font.
Font(BaseFont bf)
Constructs a Font.
Font(int family, float size, int style)
Constructs a Font.
Font(int family, float size)
Constructs a Font.
Font(int family)
Constructs a Font.
Font()
Constructs a Font.
Method Summary
intcompareTo(Object object)
Compares this Font with another
Fontdifference(Font font)
Replaces the attributes that are equal to null with the attributes of a given font.
BaseFontgetBaseFont()
Gets the BaseFont inside this object.
BaseFontgetCalculatedBaseFont(boolean specialEncoding)
Gets the BaseFont this class represents.
floatgetCalculatedLeading(float linespacing)
Gets the leading that can be used with this font.
floatgetCalculatedSize()
Gets the size that can be used with the calculated BaseFont .
intgetCalculatedStyle()
Gets the style that can be used with the calculated BaseFont .
ColorgetColor()
Gets the color of this font.
intgetFamily()
Gets the family of this font.
static intgetFamilyIndex(String family)
Translates a String -value of a certain family into the index that is used for this family in this class.
StringgetFamilyname()
Gets the familyname as a String.
floatgetSize()
Gets the size of this font.
intgetStyle()
Gets the style of this font.
static intgetStyleValue(String style)
Translates a String -value of a certain style into the index value is used for this style in this class.
booleanisBold()
checks if this font is Bold.
booleanisItalic()
checks if this font is Bold.
booleanisStandardFont()
Checks if the properties of this font are undefined or null.
booleanisStrikethru()
checks if the style of this font is STRIKETHRU.
booleanisUnderlined()
checks if this font is underlined.
voidsetColor(Color color)
Sets the color.
voidsetColor(int red, int green, int blue)
Sets the color.
voidsetFamily(String family)
Sets the family using a String ("Courier", "Helvetica", "Times New Roman", "Symbol" or "ZapfDingbats").
voidsetSize(float size)
Sets the size.
voidsetStyle(int style)
Sets the style.
voidsetStyle(String style)
Sets the style using a String containing one of more of the following values: normal, bold, italic, underline, strike.

Field Detail

baseFont

private BaseFont baseFont
the external font

BOLD

public static final int BOLD
this is a possible style.

BOLDITALIC

public static final int BOLDITALIC
this is a possible style.

color

private Color color
the value of the color.

COURIER

public static final int COURIER
a possible value of a font family.

DEFAULTSIZE

public static final int DEFAULTSIZE
the value of the default size.

family

private int family
the value of the fontfamily.

HELVETICA

public static final int HELVETICA
a possible value of a font family.

ITALIC

public static final int ITALIC
this is a possible style.

NORMAL

public static final int NORMAL
this is a possible style.

size

private float size
the value of the fontsize.

style

private int style
the value of the style.

STRIKETHRU

public static final int STRIKETHRU
this is a possible style.

SYMBOL

public static final int SYMBOL
a possible value of a font family.

TIMES_ROMAN

public static final int TIMES_ROMAN
a possible value of a font family.

UNDEFINED

public static final int UNDEFINED
the value of an undefined attribute.

UNDERLINE

public static final int UNDERLINE
this is a possible style.

ZAPFDINGBATS

public static final int ZAPFDINGBATS
a possible value of a font family.

Constructor Detail

Font

public Font(Font other)
Copy constructor of a Font

Parameters: other the font that has to be copied

Font

public Font(int family, float size, int style, Color color)
Constructs a Font.

Parameters: family the family to which this font belongs size the size of this font style the style of this font color the Color of this font.

Font

public Font(BaseFont bf, float size, int style, Color color)
Constructs a Font.

Parameters: bf the external font size the size of this font style the style of this font color the Color of this font.

Font

public Font(BaseFont bf, float size, int style)
Constructs a Font.

Parameters: bf the external font size the size of this font style the style of this font

Font

public Font(BaseFont bf, float size)
Constructs a Font.

Parameters: bf the external font size the size of this font

Font

public Font(BaseFont bf)
Constructs a Font.

Parameters: bf the external font

Font

public Font(int family, float size, int style)
Constructs a Font.

Parameters: family the family to which this font belongs size the size of this font style the style of this font

Font

public Font(int family, float size)
Constructs a Font.

Parameters: family the family to which this font belongs size the size of this font

Font

public Font(int family)
Constructs a Font.

Parameters: family the family to which this font belongs

Font

public Font()
Constructs a Font.

Method Detail

compareTo

public int compareTo(Object object)
Compares this Font with another

Parameters: object the other Font

Returns: a value

difference

public Font difference(Font font)
Replaces the attributes that are equal to null with the attributes of a given font.

Parameters: font the font of a bigger element class

Returns: a Font

getBaseFont

public BaseFont getBaseFont()
Gets the BaseFont inside this object.

Returns: the BaseFont

getCalculatedBaseFont

public BaseFont getCalculatedBaseFont(boolean specialEncoding)
Gets the BaseFont this class represents. For the built-in fonts a BaseFont is calculated.

Parameters: specialEncoding true to use the special encoding for Symbol and ZapfDingbats, false to always use Cp1252

Returns: the BaseFont this class represents

getCalculatedLeading

public float getCalculatedLeading(float linespacing)
Gets the leading that can be used with this font.

Parameters: linespacing a certain linespacing

Returns: the height of a line

getCalculatedSize

public float getCalculatedSize()
Gets the size that can be used with the calculated BaseFont .

Returns: the size that can be used with the calculated BaseFont

getCalculatedStyle

public int getCalculatedStyle()
Gets the style that can be used with the calculated BaseFont .

Returns: the style that can be used with the calculated BaseFont

getColor

public Color getColor()
Gets the color of this font.

Returns: a color

getFamily

public int getFamily()
Gets the family of this font.

Returns: the value of the family

getFamilyIndex

public static int getFamilyIndex(String family)
Translates a String -value of a certain family into the index that is used for this family in this class.

Parameters: family A String representing a certain font-family

Returns: the corresponding index

getFamilyname

public String getFamilyname()
Gets the familyname as a String.

Returns: the familyname

getSize

public float getSize()
Gets the size of this font.

Returns: a size

getStyle

public int getStyle()
Gets the style of this font.

Returns: a size

getStyleValue

public static int getStyleValue(String style)
Translates a String -value of a certain style into the index value is used for this style in this class.

Parameters: style A String

Returns: the corresponding value

isBold

public boolean isBold()
checks if this font is Bold.

Returns: a boolean

isItalic

public boolean isItalic()
checks if this font is Bold.

Returns: a boolean

isStandardFont

public boolean isStandardFont()
Checks if the properties of this font are undefined or null.

If so, the standard should be used.

Returns: a boolean

isStrikethru

public boolean isStrikethru()
checks if the style of this font is STRIKETHRU.

Returns: a boolean

isUnderlined

public boolean isUnderlined()
checks if this font is underlined.

Returns: a boolean

setColor

public void setColor(Color color)
Sets the color.

Parameters: color the new color of the font

setColor

public void setColor(int red, int green, int blue)
Sets the color.

Parameters: red the red-value of the new color green the green-value of the new color blue the blue-value of the new color

setFamily

public void setFamily(String family)
Sets the family using a String ("Courier", "Helvetica", "Times New Roman", "Symbol" or "ZapfDingbats").

Parameters: family A String representing a certain font-family.

setSize

public void setSize(float size)
Sets the size.

Parameters: size The new size of the font.

setStyle

public void setStyle(int style)
Sets the style.

Parameters: style the style.

setStyle

public void setStyle(String style)
Sets the style using a String containing one of more of the following values: normal, bold, italic, underline, strike.

Parameters: style A String representing a certain style.