Table of Contents

Class FontFactory

Namespace
iTextSharp.text
Assembly
iTextSharp.LGPLv2.Core.dll

If you are using True Type fonts, you can declare the paths of the different ttf- and ttc-files to this static class first and then create fonts in your code using one of the static getFont-method without having to enter a path as parameter.

public static class FontFactory
Inheritance
FontFactory
Inherited Members

Fields

COURIER

This is a possible value of a base 14 type 1 font

public const string COURIER = "Courier"

Field Value

string

COURIER_BOLD

This is a possible value of a base 14 type 1 font

public const string COURIER_BOLD = "Courier-Bold"

Field Value

string

COURIER_BOLDOBLIQUE

This is a possible value of a base 14 type 1 font

public const string COURIER_BOLDOBLIQUE = "Courier-BoldOblique"

Field Value

string

COURIER_OBLIQUE

This is a possible value of a base 14 type 1 font

public const string COURIER_OBLIQUE = "Courier-Oblique"

Field Value

string

HELVETICA

This is a possible value of a base 14 type 1 font

public const string HELVETICA = "Helvetica"

Field Value

string

HELVETICA_BOLD

This is a possible value of a base 14 type 1 font

public const string HELVETICA_BOLD = "Helvetica-Bold"

Field Value

string

HELVETICA_BOLDOBLIQUE

This is a possible value of a base 14 type 1 font

public const string HELVETICA_BOLDOBLIQUE = "Helvetica-BoldOblique"

Field Value

string

HELVETICA_OBLIQUE

This is a possible value of a base 14 type 1 font

public const string HELVETICA_OBLIQUE = "Helvetica-Oblique"

Field Value

string

SYMBOL

This is a possible value of a base 14 type 1 font

public const string SYMBOL = "Symbol"

Field Value

string

TIMES

This is a possible value of a base 14 type 1 font

public const string TIMES = "Times"

Field Value

string

TIMES_BOLD

This is a possible value of a base 14 type 1 font

public const string TIMES_BOLD = "Times-Bold"

Field Value

string

TIMES_BOLDITALIC

This is a possible value of a base 14 type 1 font

public const string TIMES_BOLDITALIC = "Times-BoldItalic"

Field Value

string

TIMES_ITALIC

This is a possible value of a base 14 type 1 font

public const string TIMES_ITALIC = "Times-Italic"

Field Value

string

TIMES_ROMAN

This is a possible value of a base 14 type 1 font

public const string TIMES_ROMAN = "Times-Roman"

Field Value

string

ZAPFDINGBATS

This is a possible value of a base 14 type 1 font

public const string ZAPFDINGBATS = "ZapfDingbats"

Field Value

string

Properties

DefaultEmbedding

This is the default value of the embedded variable.

public static bool DefaultEmbedding { get; }

Property Value

bool

DefaultEncoding

This is the default encoding to use.

public static string DefaultEncoding { get; }

Property Value

string

FontImp

public static FontFactoryImp FontImp { get; set; }

Property Value

FontFactoryImp

RegisteredFamilies

Gets a set of registered font families.

public static ICollection<string> RegisteredFamilies { get; }

Property Value

ICollection<string>

a set of registered font families

RegisteredFonts

Gets a set of registered fontnames.

public static ICollection<string> RegisteredFonts { get; }

Property Value

ICollection<string>

a set of registered fontnames

Methods

Contains(string)

Checks whether the given font is contained within the object

public static bool Contains(string fontname)

Parameters

fontname string

the name of the font

Returns

bool

true if font is contained within the object

GetFont(string)

Constructs a Font-object.

public static Font GetFont(string fontname)

Parameters

fontname string

the name of the font

Returns

Font

a Font object

GetFont(string, float)

Constructs a Font-object.

public static Font GetFont(string fontname, float size)

Parameters

fontname string

the name of the font

size float

the size of this font

Returns

Font

a Font object

GetFont(string, float, int)

Constructs a Font-object.

public static Font GetFont(string fontname, float size, int style)

Parameters

fontname string

the name of the font

size float

the size of this font

style int

the style of this font

Returns

Font

a Font object

GetFont(string, float, int, BaseColor)

Constructs a Font-object.

public static Font GetFont(string fontname, float size, int style, BaseColor color)

Parameters

fontname string

the name of the font

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font

Returns

Font

a Font object

GetFont(string, float, BaseColor)

Constructs a Font-object.

public static Font GetFont(string fontname, float size, BaseColor color)

Parameters

fontname string

the name of the font

size float

the size of this font

color BaseColor

the Color of this font

Returns

Font

a Font object

GetFont(string, string)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

Returns

Font

a Font object

GetFont(string, string, bool)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, bool embedded)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

embedded bool

true if the font is to be embedded in the PDF

Returns

Font

a Font object

GetFont(string, string, bool, float)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, bool embedded, float size)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

embedded bool

true if the font is to be embedded in the PDF

size float

the size of this font

Returns

Font

GetFont(string, string, bool, float, int)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

embedded bool

true if the font is to be embedded in the PDF

size float

the size of this font

style int

the style of this font

Returns

Font

a Font object

GetFont(string, string, bool, float, int, BaseColor)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style, BaseColor color)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

embedded bool

true if the font is to be embedded in the PDF

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font

Returns

Font

a Font object

GetFont(string, string, bool, float, int, BaseColor, bool)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style, BaseColor color, bool cached)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

embedded bool

true if the font is to be embedded in the PDF

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font

cached bool

true if the font comes from the cache or is added to the cache if new, false if the font is always created new

Returns

Font

a Font object

GetFont(string, string, float)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, float size)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

size float

the size of this font

Returns

Font

a Font object

GetFont(string, string, float, int)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, float size, int style)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

size float

the size of this font

style int

the style of this font

Returns

Font

a Font object

GetFont(string, string, float, int, BaseColor)

Constructs a Font-object.

public static Font GetFont(string fontname, string encoding, float size, int style, BaseColor color)

Parameters

fontname string

the name of the font

encoding string

the encoding of the font

size float

the size of this font

style int

the style of this font

color BaseColor

the Color of this font

Returns

Font

a Font object

GetFont(Properties)

Constructs a Font-object.

public static Font GetFont(Properties attributes)

Parameters

attributes Properties

the attributes of a Font object

Returns

Font

a Font object

IsRegistered(string)

Checks if a certain font is registered.

public static bool IsRegistered(string fontname)

Parameters

fontname string

the name of the font that has to be checked

Returns

bool

true if the font is found

Register(string)

Register a ttf- or a ttc-file.

public static void Register(string path)

Parameters

path string

the path to a ttf- or ttc-file

Register(string, string)

Register a ttf- or a ttc-file and use an alias for the font contained in the ttf-file.

public static void Register(string path, string alias)

Parameters

path string

the path to a ttf- or ttc-file

alias string

the alias you want to use for the font

Register(Properties)

public static void Register(Properties attributes)

Parameters

attributes Properties

RegisterDirectories()

Register fonts in some probable directories. It usually works in Windows, Linux and Solaris.

public static int RegisterDirectories()

Returns

int

the number of fonts registered

RegisterDirectory(string)

Register all the fonts in a directory.

public static int RegisterDirectory(string dir)

Parameters

dir string

the directory

Returns

int

the number of fonts registered

RegisterDirectory(string, bool)

Register all the fonts in a directory and possibly its subdirectories. @since 2.1.2

public static int RegisterDirectory(string dir, bool scanSubdirectories)

Parameters

dir string

the directory

scanSubdirectories bool

recursively scan subdirectories if true

Returns

int

the number of fonts registered

RegisterFamily(string, string, string)

Register a font by giving explicitly the font family and name.

public static void RegisterFamily(string familyName, string fullName, string path)

Parameters

familyName string

the font family

fullName string

the font name

path string

the font path