Class Font
- Namespace
- iTextSharp.text
- Assembly
- iTextSharp.LGPLv2.Core.dll
Contains all the specifications of a font: fontfamily, size, style and color.
public class Font : IComparable
- Inheritance
-
Font
- Implements
- Derived
- Inherited Members
Examples
Paragraph p = new Paragraph("This is a paragraph", new Font(Font.HELVETICA, 18, Font.BOLDITALIC, new Color(0, 0, 255)) );
Constructors
Font()
Constructs a Font.
public Font()
Font(int)
Constructs a Font.
public Font(int family)
Parameters
family
intthe family to which this font belongs
Font(int, float)
Constructs a Font.
public Font(int family, float size)
Parameters
Font(int, float, int)
Constructs a Font.
public Font(int family, float size, int style)
Parameters
family
intthe family to which this font belongs
size
floatthe size of this font
style
intthe style of this font
Font(int, float, int, BaseColor)
Constructs a Font.
public Font(int family, float size, int style, BaseColor color)
Parameters
family
intthe family to which this font belongs
size
floatthe size of this font
style
intthe style of this font
color
BaseColorthe Color of this font.
Font(Font)
constructors
public Font(Font other)
Parameters
other
Fontthe font that has to be copied
Font(BaseFont)
Constructs a Font.
public Font(BaseFont bf)
Parameters
bf
BaseFontthe external font
Font(BaseFont, float)
Constructs a Font.
public Font(BaseFont bf, float size)
Parameters
Font(BaseFont, float, int)
Constructs a Font.
public Font(BaseFont bf, float size, int style)
Parameters
Font(BaseFont, float, int, BaseColor)
Constructs a Font.
public Font(BaseFont bf, float size, int style, BaseColor color)
Parameters
bf
BaseFontthe external font
size
floatthe size of this font
style
intthe style of this font
color
BaseColorthe Color of this font.
Fields
BOLD
this is a possible style.
public const int BOLD = 1
Field Value
BOLDITALIC
this is a possible style.
public const int BOLDITALIC = 3
Field Value
COURIER
a possible value of a font family.
public const int COURIER = 0
Field Value
DEFAULTSIZE
the value of the default size.
public const int DEFAULTSIZE = 12
Field Value
HELVETICA
a possible value of a font family.
public const int HELVETICA = 1
Field Value
ITALIC
this is a possible style.
public const int ITALIC = 2
Field Value
NORMAL
this is a possible style.
public const int NORMAL = 0
Field Value
STRIKETHRU
this is a possible style.
public const int STRIKETHRU = 8
Field Value
SYMBOL
a possible value of a font family.
public const int SYMBOL = 3
Field Value
TIMES_ROMAN
a possible value of a font family.
public const int TIMES_ROMAN = 2
Field Value
UNDEFINED
the value of an undefined attribute.
public const int UNDEFINED = -1
Field Value
UNDERLINE
static membervariables for the different styles
public const int UNDERLINE = 4
Field Value
ZAPFDINGBATS
a possible value of a font family.
public const int ZAPFDINGBATS = 4
Field Value
Properties
BaseFont
implementation of the Comparable interface
public BaseFont BaseFont { get; }
Property Value
- BaseFont
the BaseFont
CalculatedSize
Gets the size that can be used with the calculated BaseFont .
public float CalculatedSize { get; }
Property Value
- float
the size that can be used with the calculated BaseFont
CalculatedStyle
Gets the style that can be used with the calculated BaseFont .
public int CalculatedStyle { get; }
Property Value
- int
the style that can be used with the calculated BaseFont
Color
Get/set the color of this font.
public virtual BaseColor Color { get; set; }
Property Value
- BaseColor
the color of this font
Family
Gets the family of this font.
public int Family { get; }
Property Value
- int
the value of the family
Familyname
FAMILY
public virtual string Familyname { get; }
Property Value
- string
the familyname
Size
Get/set the size of this font.
public virtual float Size { get; set; }
Property Value
- float
the size of this font
Style
Gets the style of this font.
public int Style { get; }
Property Value
- int
the style of this font
Methods
CompareTo(object)
Compares this Font with another
public virtual int CompareTo(object obj)
Parameters
obj
objectthe other Font
Returns
- int
a value
Difference(Font)
Replaces the attributes that are equal to null with the attributes of a given font.
public virtual Font Difference(Font font)
Parameters
font
Fontthe font of a bigger element class
Returns
- Font
a Font
GetCalculatedBaseFont(bool)
BASEFONT
public BaseFont GetCalculatedBaseFont(bool specialEncoding)
Parameters
specialEncoding
booltrue to use the special encoding for Symbol and ZapfDingbats,
Returns
- BaseFont
the BaseFont this class represents
GetCalculatedLeading(float)
SIZE
public float GetCalculatedLeading(float linespacing)
Parameters
linespacing
float
Returns
- float
the height of a line
GetFamilyIndex(string)
Translates a string-value of a certain family into the index that is used for this family in this class.
public static int GetFamilyIndex(string family)
Parameters
family
stringA string representing a certain font-family
Returns
- int
the corresponding index
GetStyleValue(string)
Translates a string-value of a certain style into the index value is used for this style in this class.
public static int GetStyleValue(string style)
Parameters
style
stringa string
Returns
- int
the corresponding value
IsBold()
STYLE
public bool IsBold()
Returns
- bool
a boolean
IsItalic()
checks if this font is Bold.
public bool IsItalic()
Returns
- bool
a boolean
IsStandardFont()
Checks if the properties of this font are undefined or null. If so, the standard should be used.
public virtual bool IsStandardFont()
Returns
- bool
a boolean
IsStrikethru()
checks if the style of this font is STRIKETHRU.
public bool IsStrikethru()
Returns
- bool
a boolean
IsUnderlined()
checks if this font is underlined.
public bool IsUnderlined()
Returns
- bool
a boolean
SetColor(int, int, int)
COLOR
public virtual void SetColor(int red, int green, int blue)
Parameters
red
intthe red-value of the new color
green
intthe green-value of the new color
blue
intthe blue-value of the new color
SetFamily(string)
Sets the family using a String ("Courier", "Helvetica", "Times New Roman", "Symbol" or "ZapfDingbats").
public virtual void SetFamily(string family)
Parameters
family
stringA String representing a certain font-family.
SetStyle(int)
Sets the style.
public virtual void SetStyle(int style)
Parameters
style
intthe style.
SetStyle(string)
Sets the style using a String containing one of more of the following values: normal, bold, italic, underline, strike.
public virtual void SetStyle(string style)
Parameters
style
stringA String representing a certain style.