Package com.aowagie.text
Class Font
java.lang.Object
com.aowagie.text.Font
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprivate BaseFont
the external fontstatic final int
this is a possible style.(package private) static final int
this is a possible style.private Color
the value of the color.static final int
a possible value of a font family.(package private) static final int
the value of the default size.private int
the value of the fontfamily.static final int
a possible value of a font family.static final int
this is a possible style.static final int
this is a possible style.private float
the value of the fontsize.static final int
this is a possible style.private int
the value of the style.static final int
a possible value of a font family.static final int
a possible value of a font family.static final int
the value of an undefined attribute.static final int
this is a possible style.static final int
a possible value of a font family. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compares thisFont
with another(package private) Font
difference
(Font font) Replaces the attributes that are equal to null with the attributes of a given font.Gets theBaseFont
inside this object.getCalculatedBaseFont
(boolean specialEncoding) Gets theBaseFont
this class represents.(package private) float
getCalculatedLeading
(float linespacing) Gets the leading that can be used with this font.float
Gets the size that can be used with the calculatedBaseFont
.int
Gets the style that can be used with the calculatedBaseFont
.getColor()
Gets the color of this font.int
Gets the family of this font.private static int
getFamilyIndex
(String family) Translates aString
-value of a certain family into the index that is used for this family in this class.Gets the familyname as a String.float
getSize()
Gets the size of this font.int
getStyle()
Gets the style of this font.(package private) static int
getStyleValue
(String style) Translates aString
-value of a certain style into the index value is used for this style in this class.boolean
isBold()
checks if this font is Bold.boolean
isItalic()
checks if this font is Bold.boolean
Checks if the properties of this font are undefined or null.boolean
checks if the style of this font is STRIKETHRU.boolean
checks if this font is underlined.void
Sets the color.void
Sets the family using aString
("Courier", "Helvetica", "Times New Roman", "Symbol" or "ZapfDingbats").void
setSize
(float size) Sets the size.void
setStyle
(int style) Sets the style.void
Sets the style using aString
containing one of more of the following values: normal, bold, italic, underline, strike.
-
Field Details
-
COURIER
public static final int COURIERa possible value of a font family.- See Also:
-
HELVETICA
public static final int HELVETICAa possible value of a font family.- See Also:
-
TIMES_ROMAN
public static final int TIMES_ROMANa possible value of a font family.- See Also:
-
SYMBOL
public static final int SYMBOLa possible value of a font family.- See Also:
-
ZAPFDINGBATS
public static final int ZAPFDINGBATSa possible value of a font family.- See Also:
-
NORMAL
public static final int NORMALthis is a possible style.- See Also:
-
BOLD
public static final int BOLDthis is a possible style.- See Also:
-
ITALIC
public static final int ITALICthis is a possible style.- See Also:
-
UNDERLINE
public static final int UNDERLINEthis is a possible style.- See Also:
-
STRIKETHRU
public static final int STRIKETHRUthis is a possible style.- See Also:
-
BOLDITALIC
static final int BOLDITALICthis is a possible style.- See Also:
-
UNDEFINED
public static final int UNDEFINEDthe value of an undefined attribute.- See Also:
-
DEFAULTSIZE
static final int DEFAULTSIZEthe value of the default size.- See Also:
-
family
private int familythe value of the fontfamily. -
size
private float sizethe value of the fontsize. -
style
private int stylethe value of the style. -
color
the value of the color. -
baseFont
the external font
-
-
Constructor Details
-
Font
Copy constructor of a Font- Parameters:
other
- the font that has to be copied
-
Font
Constructs a Font.- Parameters:
family
- the family to which this font belongssize
- the size of this fontstyle
- the style of this fontcolor
- theColor
of this font.
-
Font
Constructs a Font.- Parameters:
bf
- the external fontsize
- the size of this fontstyle
- the style of this fontcolor
- theColor
of this font.
-
Font
Constructs a Font.- Parameters:
bf
- the external font
-
Font
public Font()Constructs a Font.
-
-
Method Details
-
compareTo
Compares thisFont
with another- Specified by:
compareTo
in interfaceComparable
- Parameters:
object
- the otherFont
- Returns:
- a value
-
getFamily
public int getFamily()Gets the family of this font.- Returns:
- the value of the family
-
getFamilyname
Gets the familyname as a String.- Returns:
- the familyname
-
setFamily
Sets the family using aString
("Courier", "Helvetica", "Times New Roman", "Symbol" or "ZapfDingbats").- Parameters:
family
- AString
representing a certain font-family.
-
getFamilyIndex
Translates aString
-value of a certain family into the index that is used for this family in this class.- Parameters:
family
- AString
representing a certain font-family- Returns:
- the corresponding index
-
getSize
public float getSize()Gets the size of this font.- Returns:
- a size
-
getCalculatedSize
public float getCalculatedSize()Gets the size that can be used with the calculatedBaseFont
.- Returns:
- the size that can be used with the calculated
BaseFont
-
getCalculatedLeading
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
-
setSize
public void setSize(float size) Sets the size.- Parameters:
size
- The new size of the font.
-
getStyle
public int getStyle()Gets the style of this font.- Returns:
- a size
-
getCalculatedStyle
public int getCalculatedStyle()Gets the style that can be used with the calculatedBaseFont
.- Returns:
- the style that can be used with the calculated
BaseFont
-
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
-
isUnderlined
public boolean isUnderlined()checks if this font is underlined.- Returns:
- a
boolean
-
isStrikethru
public boolean isStrikethru()checks if the style of this font is STRIKETHRU.- Returns:
- a
boolean
-
setStyle
public void setStyle(int style) Sets the style.- Parameters:
style
- the style.
-
setStyle
Sets the style using aString
containing one of more of the following values: normal, bold, italic, underline, strike.- Parameters:
style
- AString
representing a certain style.
-
getStyleValue
Translates aString
-value of a certain style into the index value is used for this style in this class.- Parameters:
style
- AString
- Returns:
- the corresponding value
-
getColor
Gets the color of this font.- Returns:
- a color
-
setColor
Sets the color.- Parameters:
color
- the new color of the font
-
getBaseFont
Gets theBaseFont
inside this object.- Returns:
- the
BaseFont
-
getCalculatedBaseFont
Gets theBaseFont
this class represents. For the built-in fonts aBaseFont
is calculated.- Parameters:
specialEncoding
-true
to use the special encoding for Symbol and ZapfDingbats,false
to always useCp1252
- Returns:
- the
BaseFont
this class represents
-
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
-
difference
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
-