Skip to main content
Skip table of contents

FontFactory

FontFactory Public class

Description

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.

Diagram

  flowchart LR
  classDef interfaceStyle stroke-dasharray: 5 5;
  classDef abstractStyle stroke-width:4px
  subgraph iTextSharp.text
  iTextSharp.text.FontFactory[[FontFactory]]
  end

Members

Properties

Public Static properties
TypeNameMethods
boolDefaultEmbeddingget
stringDefaultEncodingget
FontFactoryImpFontImpget, set
ICollection<string>RegisteredFamilies
Gets a set of registered font families.
get
ICollection<string>RegisteredFonts
Gets a set of registered fontnames.
get

Methods

Public Static methods
ReturnsName
boolContains(string fontname)
Checks whether the given font is contained within the object
FontGetFont(...)
Constructs a Font-object.
boolIsRegistered(string fontname)
Checks if a certain font is registered.
voidRegister(...)
intRegisterDirectories()
intRegisterDirectory(...)
voidRegisterFamily(string familyName, string fullName, string path)

Details

Summary

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.

Methods

GetFont [1/14]

Source code

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style, BaseColor color)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
boolembeddedtrue if the font is to be embedded in the PDF
floatsizethe size of this font
intstylethe style of this font
BaseColorcolorthe BaseColor of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [2/14]

Source code

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style, BaseColor color, bool cached)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
boolembeddedtrue if the font is to be embedded in the PDF
floatsizethe size of this font
intstylethe style of this font
BaseColorcolorthe BaseColor of this font
boolcachedtrue if the font comes from the cache or is added to the cache if new, false if the font is always created new
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [3/14]

Source code

public static Font GetFont(string fontname, string encoding, bool embedded, float size, int style)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
boolembeddedtrue if the font is to be embedded in the PDF
floatsizethe size of this font
intstylethe style of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [4/14]

Source code

public static Font GetFont(string fontname, string encoding, bool embedded, float size)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
boolembeddedtrue if the font is to be embedded in the PDF
floatsizethe size of this font
Summary

Constructs a Font-object.

Returns
GetFont [5/14]

Source code

public static Font GetFont(string fontname, string encoding, bool embedded)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
boolembeddedtrue if the font is to be embedded in the PDF
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [6/14]

Source code

public static Font GetFont(string fontname, string encoding, float size, int style, BaseColor color)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
floatsizethe size of this font
intstylethe style of this font
BaseColorcolorthe BaseColor of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [7/14]

Source code

public static Font GetFont(string fontname, string encoding, float size, int style)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
floatsizethe size of this font
intstylethe style of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [8/14]

Source code

public static Font GetFont(string fontname, string encoding, float size)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
floatsizethe size of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [9/14]

Source code

public static Font GetFont(string fontname, string encoding)
Arguments
TypeNameDescription
stringfontnamethe name of the font
stringencodingthe encoding of the font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [10/14]

Source code

public static Font GetFont(string fontname, float size, int style, BaseColor color)
Arguments
TypeNameDescription
stringfontnamethe name of the font
floatsizethe size of this font
intstylethe style of this font
BaseColorcolorthe BaseColor of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [11/14]

Source code

public static Font GetFont(string fontname, float size, BaseColor color)
Arguments
TypeNameDescription
stringfontnamethe name of the font
floatsizethe size of this font
BaseColorcolorthe BaseColor of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [12/14]

Source code

public static Font GetFont(string fontname, float size, int style)
Arguments
TypeNameDescription
stringfontnamethe name of the font
floatsizethe size of this font
intstylethe style of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [13/14]

Source code

public static Font GetFont(string fontname, float size)
Arguments
TypeNameDescription
stringfontnamethe name of the font
floatsizethe size of this font
Summary

Constructs a Font-object.

Returns

a Font object

GetFont [14/14]

Source code

public static Font GetFont(string fontname)
Arguments
TypeNameDescription
stringfontnamethe name of the font
Summary

Constructs a Font-object.

Returns

a Font object

RegisterFamily

Source code

public static void RegisterFamily(string familyName, string fullName, string path)
Arguments
TypeNameDescription
stringfamilyName
stringfullName
stringpath
Register [1/3]

Source code

public static void Register(Properties attributes)
Arguments
TypeNameDescription
Propertiesattributes
Register [2/3]

Source code

public static void Register(string path)
Arguments
TypeNameDescription
stringpaththe path to a ttf- or ttc-file
Summary

Register a ttf- or a ttc-file.

Register [3/3]

Source code

public static void Register(string path, string alias)
Arguments
TypeNameDescription
stringpaththe path to a ttf- or ttc-file
stringaliasthe alias you want to use for the font
Summary

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

RegisterDirectory [1/2]

Source code

public static int RegisterDirectory(string dir)
Arguments
TypeNameDescription
stringdir
RegisterDirectory [2/2]

Source code

public static int RegisterDirectory(string dir, bool scanSubdirectories)
Arguments
TypeNameDescription
stringdir
boolscanSubdirectories
RegisterDirectories

Source code

public static int RegisterDirectories()
Contains

Source code

public static bool Contains(string fontname)
Arguments
TypeNameDescription
stringfontnamethe name of the font
Summary

Checks whether the given font is contained within the object

Returns

true if font is contained within the object

IsRegistered

Source code

public static bool IsRegistered(string fontname)
Arguments
TypeNameDescription
stringfontnamethe name of the font that has to be checked
Summary

Checks if a certain font is registered.

Returns

true if the font is found

Properties

RegisteredFonts
public static ICollection<string> RegisteredFonts { get; }
Summary

Gets a set of registered fontnames.

Value

a set of registered fontnames

RegisteredFamilies
public static ICollection<string> RegisteredFamilies { get; }
Summary

Gets a set of registered font families.

Value

a set of registered font families

DefaultEncoding
public static string DefaultEncoding { get; }
DefaultEmbedding
public static bool DefaultEmbedding { get; }
FontImp
public static FontFactoryImp FontImp { get; set; }

Generated with ModularDoc

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.