public class Font extends Object implements Comparable
Example:
Paragraph p = new Paragraph("This is a paragraph", new
Font(Font.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)) );
| Modifier and Type | Field and Description |
|---|---|
static int |
BOLD
this is a possible style.
|
static int |
ITALIC
this is a possible style.
|
static int |
NORMAL
this is a possible style.
|
static int |
STRIKETHRU
this is a possible style.
|
static int |
SYMBOL
a possible value of a font family.
|
static int |
UNDEFINED
the value of an undefined attribute.
|
static int |
UNDERLINE
this is a possible style.
|
| Constructor and Description |
|---|
Font()
Constructs a Font.
|
Font(BaseFont bf)
Constructs a Font.
|
Font(BaseFont bf,
float size,
int style,
Color color)
Constructs a Font.
|
Font(Font other)
Copy constructor of a Font
|
Font(int family,
float size,
int style,
Color color)
Constructs a Font.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Object object)
Compares this
Font with another |
BaseFont |
getBaseFont()
Gets the
BaseFont inside this object. |
BaseFont |
getCalculatedBaseFont(boolean specialEncoding)
Gets the
BaseFont this class represents. |
float |
getCalculatedSize()
Gets the size that can be used with the calculated
BaseFont
. |
int |
getCalculatedStyle()
Gets the style that can be used with the calculated
BaseFont
. |
Color |
getColor()
Gets the color of this font.
|
int |
getFamily()
Gets the family of this font.
|
String |
getFamilyname()
Gets the familyname as a String.
|
float |
getSize()
Gets the size of this font.
|
int |
getStyle()
Gets the style of this font.
|
boolean |
isBold()
checks if this font is Bold.
|
boolean |
isItalic()
checks if this font is Bold.
|
boolean |
isStandardFont()
Checks if the properties of this font are undefined or null.
|
boolean |
isStrikethru()
checks if the style of this font is STRIKETHRU.
|
boolean |
isUnderlined()
checks if this font is underlined.
|
void |
setColor(Color color)
Sets the color.
|
void |
setFamily(String family)
Sets the family using a
String ("Courier", "Helvetica",
"Times New Roman", "Symbol" or "ZapfDingbats"). |
void |
setSize(float size)
Sets the size.
|
void |
setStyle(int style)
Sets the style.
|
void |
setStyle(String style)
Sets the style using a
String containing one of more of
the following values: normal, bold, italic, underline, strike. |
public static final int SYMBOL
public static final int NORMAL
public static final int BOLD
public static final int ITALIC
public static final int UNDERLINE
public static final int STRIKETHRU
public static final int UNDEFINED
public Font(Font other)
other - the font that has to be copiedpublic Font(int family,
float size,
int style,
Color color)
family - the family to which this font belongssize - the size of this fontstyle - the style of this fontcolor - the Color of this font.public Font(BaseFont bf, float size, int style, Color color)
bf - the external fontsize - the size of this fontstyle - the style of this fontcolor - the Color of this font.public Font(BaseFont bf)
bf - the external fontpublic Font()
public int compareTo(Object object)
Font with anothercompareTo in interface Comparableobject - the other Fontpublic int getFamily()
public String getFamilyname()
public void setFamily(String family)
String ("Courier", "Helvetica",
"Times New Roman", "Symbol" or "ZapfDingbats").family - A String representing a certain font-family.public float getSize()
public float getCalculatedSize()
BaseFont
.BaseFont
public void setSize(float size)
size - The new size of the font.public int getStyle()
public int getCalculatedStyle()
BaseFont
.BaseFont
public boolean isBold()
booleanpublic boolean isItalic()
booleanpublic boolean isUnderlined()
booleanpublic boolean isStrikethru()
booleanpublic void setStyle(int style)
style - the style.public void setStyle(String style)
String containing one of more of
the following values: normal, bold, italic, underline, strike.style - A String representing a certain style.public Color getColor()
public void setColor(Color color)
color - the new color of the fontpublic BaseFont getBaseFont()
BaseFont inside this object.BaseFontpublic BaseFont getCalculatedBaseFont(boolean specialEncoding)
BaseFont this class represents. For the built-in
fonts a BaseFont is calculated.specialEncoding - true to use the special encoding for Symbol and
ZapfDingbats, false to always use Cp1252
BaseFont this class representspublic boolean isStandardFont()
If so, the standard should be used.
booleanCopyright © 2021. All rights reserved.