Table of Contents

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 int

the family to which this font belongs

Font(int, float)

Constructs a Font.

public Font(int family, float size)

Parameters

family int

the family to which this font belongs

size float

the size of this font

Font(int, float, int)

Constructs a Font.

public Font(int family, float size, int style)

Parameters

family int

the family to which this font belongs

size float

the size of this font

style int

the style of this font

Font(int, float, int, BaseColor)

Constructs a Font.

public Font(int family, float size, int style, BaseColor color)

Parameters

family int

the family to which this font belongs

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font.

Font(Font)

constructors

public Font(Font other)

Parameters

other Font

the font that has to be copied

Font(BaseFont)

Constructs a Font.

public Font(BaseFont bf)

Parameters

bf BaseFont

the external font

Font(BaseFont, float)

Constructs a Font.

public Font(BaseFont bf, float size)

Parameters

bf BaseFont

the external font

size float

the size of this font

Font(BaseFont, float, int)

Constructs a Font.

public Font(BaseFont bf, float size, int style)

Parameters

bf BaseFont

the external font

size float

the size of this font

style int

the style of this font

Font(BaseFont, float, int, BaseColor)

Constructs a Font.

public Font(BaseFont bf, float size, int style, BaseColor color)

Parameters

bf BaseFont

the external font

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font.

Fields

BOLD

this is a possible style.

public const int BOLD = 1

Field Value

int

BOLDITALIC

this is a possible style.

public const int BOLDITALIC = 3

Field Value

int

COURIER

a possible value of a font family.

public const int COURIER = 0

Field Value

int

DEFAULTSIZE

the value of the default size.

public const int DEFAULTSIZE = 12

Field Value

int

HELVETICA

a possible value of a font family.

public const int HELVETICA = 1

Field Value

int

ITALIC

this is a possible style.

public const int ITALIC = 2

Field Value

int

NORMAL

this is a possible style.

public const int NORMAL = 0

Field Value

int

STRIKETHRU

this is a possible style.

public const int STRIKETHRU = 8

Field Value

int

SYMBOL

a possible value of a font family.

public const int SYMBOL = 3

Field Value

int

TIMES_ROMAN

a possible value of a font family.

public const int TIMES_ROMAN = 2

Field Value

int

UNDEFINED

the value of an undefined attribute.

public const int UNDEFINED = -1

Field Value

int

UNDERLINE

static membervariables for the different styles

public const int UNDERLINE = 4

Field Value

int

ZAPFDINGBATS

a possible value of a font family.

public const int ZAPFDINGBATS = 4

Field Value

int

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 object

the 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 Font

the font of a bigger element class

Returns

Font

a Font

GetCalculatedBaseFont(bool)

BASEFONT

public BaseFont GetCalculatedBaseFont(bool specialEncoding)

Parameters

specialEncoding bool

true 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 string

A 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 string

a 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 int

the red-value of the new color

green int

the green-value of the new color

blue int

the 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 string

A String representing a certain font-family.

SetStyle(int)

Sets the style.

public virtual void SetStyle(int style)

Parameters

style int

the 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 string

A String representing a certain style.