Table of Contents

Class FontSet

Namespace
iText.Layout.Font
Assembly
itext.layout.dll

Reusable font set for FontProgram related data.

public sealed class FontSet
Inheritance
FontSet
Inherited Members

Remarks

Reusable font set for FontProgram related data. Add and search fonts.

A FontSet instance could be shared for multiple threads. However FontSet filling is not thread safe operation.

Constructors

FontSet()

Creates a new instance of FontSet.

public FontSet()
See Also

Methods

AddDirectory(string)

Add all the fonts in a directory.

public int AddDirectory(string dir)

Parameters

dir string

path to directory.

Returns

int

number of added fonts.

See Also

AddDirectory(string, bool)

Add all the fonts in a directory and possibly its subdirectories.

public int AddDirectory(string dir, bool scanSubdirectories)

Parameters

dir string

path to directory.

scanSubdirectories bool

recursively scan subdirectories if true.

Returns

int

number of added fonts.

See Also

AddFont(byte[])

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(byte[] fontData)

Parameters

fontData byte[]

font data.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet. GetDefaultEncoding(FontProgram) will be used to determine encoding.

See Also

AddFont(byte[], string)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(byte[] fontData, string encoding)

Parameters

fontData byte[]

font data.

encoding string

preferred font encoding.

Returns

bool

true, if font was successfully added, otherwise false.

See Also

AddFont(byte[], string, string)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(byte[] fontData, string encoding, string alias)

Parameters

fontData byte[]

font data.

encoding string

preferred font encoding.

alias string

font alias.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(byte[], string, string, Range)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(byte[] fontData, string encoding, string alias, Range unicodeRange)

Parameters

fontData byte[]

font data.

encoding string

preferred font encoding.

alias string

font alias.

unicodeRange Range

sets the specific range of characters to be used from the font

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(string)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(string fontPath)

Parameters

fontPath string

path to font data.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet. GetDefaultEncoding(FontProgram) will be used to determine encoding.

See Also

AddFont(string, string)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(string fontPath, string encoding)

Parameters

fontPath string

path to font data.

encoding string

preferred font encoding.

Returns

bool

true, if font was successfully added, otherwise false.

See Also

AddFont(string, string, string)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(string fontPath, string encoding, string alias)

Parameters

fontPath string

path to font data.

encoding string

preferred font encoding.

alias string

font alias.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(string, string, string, Range)

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

public bool AddFont(string fontPath, string encoding, string alias, Range unicodeRange)

Parameters

fontPath string

path to font data.

encoding string

preferred font encoding.

alias string

font alias, will replace original font family.

unicodeRange Range

sets the specific range of characters to be used from the font

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Creates FontInfo , fetches FontProgramDescriptor and adds just created FontInfo to FontSet.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(FontProgram, string)

Add not supported for auto creating FontPrograms.

public bool AddFont(FontProgram fontProgram, string encoding)

Parameters

fontProgram FontProgram

FontProgram

encoding string

FontEncoding for creating PdfFont.

Returns

bool

true, if font was successfully added, otherwise false.

See Also

AddFont(FontProgram, string, string)

Add not supported for auto creating FontPrograms.

public bool AddFont(FontProgram fontProgram, string encoding, string alias)

Parameters

fontProgram FontProgram

FontProgram

encoding string

FontEncoding for creating PdfFont

alias string

font alias.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Add not supported for auto creating FontPrograms.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(FontProgram, string, string, Range)

Add not supported for auto creating FontPrograms.

public bool AddFont(FontProgram fontProgram, string encoding, string alias, Range unicodeRange)

Parameters

fontProgram FontProgram

FontProgram

encoding string

FontEncoding for creating PdfFont

alias string

font alias.

unicodeRange Range

sets the specific range of characters to be used from the font

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Add not supported for auto creating FontPrograms.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(FontInfo)

Adds FontInfo.

public bool AddFont(FontInfo fontInfo)

Parameters

fontInfo FontInfo

font info.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Adds FontInfo . Could be used to fill temporary font set.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced.
See Also

AddFont(FontInfo, string)

Adds FontInfo with alias.

public bool AddFont(FontInfo fontInfo, string alias)

Parameters

fontInfo FontInfo

font info.

alias string

font alias.

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Adds FontInfo with alias. Could be used to fill temporary font set.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

AddFont(FontInfo, string, Range)

Adds FontInfo with alias.

public bool AddFont(FontInfo fontInfo, string alias, Range unicodeRange)

Parameters

fontInfo FontInfo

font info.

alias string

font alias.

unicodeRange Range

sets the specific range of characters to be used from the font

Returns

bool

true, if font was successfully added, otherwise false.

Remarks

Adds FontInfo with alias. Could be used to fill temporary font set.

Note, GetAlias() do not taken into account in Equals(object). The same font with different alias will not be replaced. Alias will replace original font family in font selector algorithm.
See Also

Contains(string)

Search in existed fonts for PostScript name or full font name.

public bool Contains(string fontName)

Parameters

fontName string

PostScript or full name.

Returns

bool

true, if FontSet contains font with given name.

Remarks

Search in existed fonts for PostScript name or full font name.

Note, this method has O(n) complexity.
See Also

Get(string)

Search in existed fonts for PostScript name or full font name.

public ICollection<FontInfo> Get(string fontName)

Parameters

fontName string

PostScript or full name.

Returns

ICollection<FontInfo>

Collection of FontInfo from set of fonts with given PostScript or full name.

Remarks

Search in existed fonts for PostScript name or full font name.

Note, this method has O(n) complexity.
See Also

GetFonts()

Gets available fonts.

public ICollection<FontInfo> GetFonts()

Returns

ICollection<FontInfo>

set of all available fonts

Remarks

Gets available fonts.

Note, the collection is unmodifiable.
See Also

GetFonts(FontSet)

Gets union of available and temporary fonts.

public ICollection<FontInfo> GetFonts(FontSet additionalFonts)

Parameters

additionalFonts FontSet

set of temporary fonts

Returns

ICollection<FontInfo>

set of all available and temporary fonts

Remarks

Gets union of available and temporary fonts.

Note, the collection is unmodifiable.
See Also

IsEmpty()

Returns true if this set contains no elements.

public bool IsEmpty()

Returns

bool

true if this set contains no elements

See Also

Size()

Returns the number of elements in this set.

public int Size()

Returns

int

the number of elements in this set

See Also

See Also