Table of Contents

Class FontFactoryImp

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 class first and then create fonts in your code using one of the getFont method without having to enter a path as parameter. It's a registry class and defined as a singleton to prevent misusing it.

public sealed class FontFactoryImp
Inheritance
FontFactoryImp
Inherited Members

Properties

DefaultEmbedding

Gets or set DefaultEmbedding

public bool DefaultEmbedding { get; set; }

Property Value

bool

DefaultEncoding

Gets or set DefaultEncoding

public string DefaultEncoding { get; set; }

Property Value

string

Instance

Gets an Instance of FontFactoryImp

public static FontFactoryImp Instance { get; }

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

GetFont(string)

Constructs a Font-object.

public 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 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 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 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 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 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 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 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 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 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 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 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 void Register(Properties attributes)

Parameters

attributes Properties

RegisterDirectories()

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

public int RegisterDirectories()

Returns

int

the number of fonts registered

RegisterDirectory(string)

Register all the fonts in a directory.

public 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 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