public class Font extends Object implements Comparable<Font>
Example:
Paragraph p = new Paragraph("This is a paragraph", new Font(FontFamily.HELVETICA, 18, Font.BOLDITALIC, new BaseColor(0, 0, 255)) );
Modifier and Type | Class and Description |
---|---|
static class |
Font.FontFamily
Enum describing the font family
|
static class |
Font.FontStyle
FontStyle.
|
Modifier and Type | Field and Description |
---|---|
static int |
BOLD
this is a possible style.
|
static int |
BOLDITALIC
this is a possible style.
|
static int |
DEFAULTSIZE
the value of the default size.
|
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 |
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)
Constructs a Font.
|
Font(BaseFont bf, float size, int style)
Constructs a Font.
|
Font(BaseFont bf, float size, int style, BaseColor color)
Constructs a Font.
|
Font(Font.FontFamily family)
Constructs a Font.
|
Font(Font.FontFamily family, float size)
Constructs a Font.
|
Font(Font.FontFamily family, float size, int style)
Constructs a Font.
|
Font(Font.FontFamily family, float size, int style, BaseColor color)
Constructs a Font.
|
Font(Font other)
Copy constructor of a Font
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Font font)
Compares this Font with another
|
Font |
difference(Font font)
Replaces the attributes that are equal to null with the attributes of a given font.
|
BaseFont |
getBaseFont()
Gets the BaseFont inside this object.
|
BaseFont |
getCalculatedBaseFont(boolean specialEncoding)
Gets the BaseFont this class represents.
|
float |
getCalculatedLeading(float multipliedLeading)
Gets the leading that can be used with this font.
|
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 .
|
BaseColor |
getColor()
Gets the color of this font.
|
Font.FontFamily |
getFamily()
Gets the family of this font.
|
static Font.FontFamily |
getFamily(String family)
Translates a String -value of a certain family into the FontFamily enum that is used for this family in this class.
|
String |
getFamilyname()
Gets the familyname as a String.
|
float |
getSize()
Gets the size of this font.
|
int |
getStyle()
Gets the style of this font.
|
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.
|
boolean |
isBold()
checks if this font is Bold.
|
boolean |
isItalic()
checks if this font is italic.
|
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(BaseColor color)
Sets the color.
|
void |
setColor(int red, int green, int blue)
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 or more of the following values: normal, bold, italic, oblique, underline, line-through
|
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 BOLDITALIC
public static final int UNDEFINED
public static final int DEFAULTSIZE
public Font(Font other)
other
- the font that has to be copied
public Font(Font.FontFamily family, float size, int style, BaseColor color)
family
- the family to which this font belongs
size
- the size of this font
style
- the style of this font
color
- the BaseColor
of this font.
public Font(BaseFont bf, float size, int style, BaseColor color)
bf
- the external font
size
- the size of this font
style
- the style of this font
color
- the BaseColor
of this font.
public Font(BaseFont bf, float size, int style)
bf
- the external font
size
- the size of this font
style
- the style of this font
public Font(BaseFont bf, float size)
bf
- the external font
size
- the size of this font
public Font(BaseFont bf)
bf
- the external font
public Font(Font.FontFamily family, float size, int style)
family
- the family to which this font belongs
size
- the size of this font
style
- the style of this font
public Font(Font.FontFamily family, float size)
family
- the family to which this font belongs
size
- the size of this font
public Font(Font.FontFamily family)
family
- the family to which this font belongs
public Font()
public int compareTo(Font font)
Font
with another
compareTo
in interface Comparable<Font>
font
- the other Font
public Font.FontFamily 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 static Font.FontFamily getFamily(String family)
String
-value of a certain family into the FontFamily enum that is used for this family in this class.
family
- A String
representing a certain font-family
public float getSize()
public float getCalculatedSize()
BaseFont
.
BaseFont
public float getCalculatedLeading(float multipliedLeading)
multipliedLeading
- a certain multipliedLeading
public void setSize(float size)
size
- The new size of the font.
public int getStyle()
public int getCalculatedStyle()
BaseFont
.
BaseFont
public boolean isBold()
boolean
public boolean isItalic()
boolean
public boolean isUnderlined()
boolean
public boolean isStrikethru()
boolean
public void setStyle(int style)
style
- the style.
public void setStyle(String style)
String
containing one or more of the following values: normal, bold, italic, oblique, underline, line-through
style
- A String
representing a certain style.
public static int getStyleValue(String style)
String
-value of a certain style into the index value is used for this style in this class. Supported styles are in Font.FontStyle
values are checked on Font.FontStyle.getValue()
style
- A String
public BaseColor getColor()
public void setColor(BaseColor color)
color
- the new color of the font
public void setColor(int red, int green, int blue)
red
- the red-value of the new color
green
- the green-value of the new color
blue
- the blue-value of the new color
public BaseFont getBaseFont()
BaseFont
inside this object.
BaseFont
public 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 represents
public boolean isStandardFont()
If so, the standard should be used.
boolean
Copyright © 1998–2024. All rights reserved.