iText 7 7.1.9 API
iText.IO.Font.FontProgramFactory Class Reference

Provides methods for creating various types of fonts. More...

Static Public Member Functions

static FontProgram CreateFont ()
 Creates a new standard Helvetica font program file. More...
 
static FontProgram CreateFont (String fontProgram)
 Creates a new font program. More...
 
static FontProgram CreateFont (String fontProgram, bool cached)
 Creates a new font program. More...
 
static FontProgram CreateFont (byte[] fontProgram)
 Creates a new font program. More...
 
static FontProgram CreateFont (byte[] fontProgram, bool cached)
 Creates a new font program. More...
 
static FontProgram CreateType1Font (byte[] afm, byte[] pfb)
 Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files More...
 
static FontProgram CreateType1Font (byte[] afm, byte[] pfb, bool cached)
 Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files More...
 
static FontProgram CreateType1Font (String metricsPath, String binaryPath)
 Creates a new Type 1 font by the corresponding AFM/PFM and PFB files More...
 
static FontProgram CreateType1Font (String metricsPath, String binaryPath, bool cached)
 Creates a new Type 1 font by the corresponding AFM/PFM and PFB files More...
 
static FontProgram CreateFont (String ttc, int ttcIndex, bool cached)
 Creates a new TrueType font program from ttc (TrueType Collection) file. More...
 
static FontProgram CreateFont (byte[] ttc, int ttcIndex, bool cached)
 Creates a new TrueType font program from ttc (TrueType Collection) file bytes. More...
 
static FontProgram CreateRegisteredFont (String fontName, int style, bool cached)
 Creates a FontProgram from the font file that has been previously registered. More...
 
static FontProgram CreateRegisteredFont (String fontName, int style)
 Creates a FontProgram from the font file that has been previously registered. More...
 
static FontProgram CreateRegisteredFont (String fontName)
 Creates a FontProgram from the font file that has been previously registered. More...
 
static void RegisterFontFamily (String familyName, String fullName, String path)
 Register a font by giving explicitly the font family and name. More...
 
static void RegisterFont (String path)
 Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file. More...
 
static void RegisterFont (String path, String alias)
 Register a font file and use an alias for the font contained in it. More...
 
static int RegisterFontDirectory (String dir)
 Register all the fonts in a directory. More...
 
static int RegisterSystemFontDirectories ()
 Register fonts in some probable directories. More...
 
static ICollection< String > GetRegisteredFonts ()
 Gets a set of registered font names. More...
 
static ICollection< String > GetRegisteredFontFamilies ()
 Gets a set of registered font names. More...
 
static bool IsRegisteredFont (String fontName)
 Checks if a certain font is registered. More...
 
static void ClearRegisteredFonts ()
 
static void ClearRegisteredFontFamilies ()
 Clears registered font cache More...
 

Detailed Description

Provides methods for creating various types of fonts.

Member Function Documentation

◆ ClearRegisteredFontFamilies()

static void iText.IO.Font.FontProgramFactory.ClearRegisteredFontFamilies ( )
inlinestatic

Clears registered font cache

◆ CreateFont() [1/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( )
inlinestatic

Creates a new standard Helvetica font program file.

Returns
a FontProgram object with Helvetica font description

◆ CreateFont() [2/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( byte[]  fontProgram)
inlinestatic

Creates a new font program.

Creates a new font program. This font program can be one of the 14 built in fonts, a Type1 font referred to by an AFM or PFM file, a TrueType font or a CJK font from the Adobe Asian Font Pack. Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts are cached and if they already exist they are extracted from the cache, not parsed again.

Parameters
fontProgramthe byte contents of the font program
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [3/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( byte[]  fontProgram,
bool  cached 
)
inlinestatic

Creates a new font program.

Creates a new font program. This font program can be one of the 14 built in fonts, a Type 1 font referred to by an AFM or PFM file, a TrueType font or a CJK font from the Adobe Asian Font Pack. Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts are cached and if they already exist they are extracted from the cache, not parsed again.

Parameters
fontProgramthe byte contents of the font program
cachedwhether to to cache this font program
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [4/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( byte[]  ttc,
int  ttcIndex,
bool  cached 
)
inlinestatic

Creates a new TrueType font program from ttc (TrueType Collection) file bytes.

Parameters
ttcthe content of a TrueType Collection file (*.ttc)
ttcIndexthe index of the font file from the collection to be read
cachedtrue if the font comes from the cache or is added to the cache if new, false if the font is always created new
Returns
returns a new FontProgram instance. This font may come from the cache but only if cached is true, otherwise it will always be created new

◆ CreateFont() [5/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( String  fontProgram)
inlinestatic

Creates a new font program.

Creates a new font program. This font program can be one of the 14 built in fonts, a Type1 font referred to by an AFM or PFM file, a TrueType font or a CJK font from the Adobe Asian Font Pack. Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts are cached and if they already exist they are extracted from the cache, not parsed again.

Parameters
fontProgramthe name of the font or its location on file
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [6/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( String  fontProgram,
bool  cached 
)
inlinestatic

Creates a new font program.

Creates a new font program. This font program can be one of the 14 built in fonts, a Type1 font referred to by an AFM or PFM file, a TrueType font or a CJK font from the Adobe Asian Font Pack. Fonts in TrueType Collections are addressed by index such as "msgothic.ttc,1". This would get the second font (indexes start at 0), in this case "MS PGothic".

The fonts are cached and if they already exist they are extracted from the cache, not parsed again.

Parameters
fontProgramthe name of the font or its location on file
cachedwhether to to cache this font program after it has been loaded
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [7/7]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( String  ttc,
int  ttcIndex,
bool  cached 
)
inlinestatic

Creates a new TrueType font program from ttc (TrueType Collection) file.

Parameters
ttclocation of TrueType Collection file (*.ttc)
ttcIndexthe index of the font file from the collection to be read
cachedtrue if the font comes from the cache or is added to the cache if new, false if the font is always created new
Returns
returns a new FontProgram instance. This font may come from the cache but only if cached is true, otherwise it will always be created new

◆ CreateRegisteredFont() [1/3]

static FontProgram iText.IO.Font.FontProgramFactory.CreateRegisteredFont ( String  fontName)
inlinestatic

Creates a FontProgram from the font file that has been previously registered.

Parameters
fontNameeither a font alias, if the font file has been registered with an alias, or just a font name otherwise
Returns
created FontProgram

◆ CreateRegisteredFont() [2/3]

static FontProgram iText.IO.Font.FontProgramFactory.CreateRegisteredFont ( String  fontName,
int  style 
)
inlinestatic

Creates a FontProgram from the font file that has been previously registered.

Parameters
fontNameeither a font alias, if the font file has been registered with an alias, or just a font name otherwise
stylethe style of the font to look for. Possible values are listed in iText.IO.Font.Constants.FontStyles. See iText.IO.Font.Constants.FontStyles.BOLD , iText.IO.Font.Constants.FontStyles.ITALIC , iText.IO.Font.Constants.FontStyles.NORMAL , iText.IO.Font.Constants.FontStyles.BOLDITALIC , iText.IO.Font.Constants.FontStyles.UNDEFINED
Returns
created FontProgram

◆ CreateRegisteredFont() [3/3]

static FontProgram iText.IO.Font.FontProgramFactory.CreateRegisteredFont ( String  fontName,
int  style,
bool  cached 
)
inlinestatic

Creates a FontProgram from the font file that has been previously registered.

Parameters
fontNameeither a font alias, if the font file has been registered with an alias, or just a font name otherwise
stylethe style of the font to look for. Possible values are listed in iText.IO.Font.Constants.FontStyles. See iText.IO.Font.Constants.FontStyles.BOLD , iText.IO.Font.Constants.FontStyles.ITALIC , iText.IO.Font.Constants.FontStyles.NORMAL , iText.IO.Font.Constants.FontStyles.BOLDITALIC , iText.IO.Font.Constants.FontStyles.UNDEFINED
cachedwhether to try to get the font program from cache
Returns
created FontProgram

◆ CreateType1Font() [1/4]

static FontProgram iText.IO.Font.FontProgramFactory.CreateType1Font ( byte[]  afm,
byte[]  pfb 
)
inlinestatic

Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files

Parameters
afmthe contents of the AFM or PFM metrics file
pfbthe contents of the PFB file
Returns
created FontProgram instance

◆ CreateType1Font() [2/4]

static FontProgram iText.IO.Font.FontProgramFactory.CreateType1Font ( byte[]  afm,
byte[]  pfb,
bool  cached 
)
inlinestatic

Creates a new Type 1 font by the byte contents of the corresponding AFM/PFM and PFB files

Parameters
afmthe contents of the AFM or PFM metrics file
pfbthe contents of the PFB file
cachedspecifies whether to cache the created FontProgram or not
Returns
created FontProgram instance

◆ CreateType1Font() [3/4]

static FontProgram iText.IO.Font.FontProgramFactory.CreateType1Font ( String  metricsPath,
String  binaryPath 
)
inlinestatic

Creates a new Type 1 font by the corresponding AFM/PFM and PFB files

Parameters
metricsPathpath to the AFM or PFM metrics file
binaryPathpath to the contents of the PFB file
Returns
created FontProgram instance

◆ CreateType1Font() [4/4]

static FontProgram iText.IO.Font.FontProgramFactory.CreateType1Font ( String  metricsPath,
String  binaryPath,
bool  cached 
)
inlinestatic

Creates a new Type 1 font by the corresponding AFM/PFM and PFB files

Parameters
metricsPathpath to the AFM or PFM metrics file
binaryPathpath to the contents of the PFB file
cachedspecifies whether to cache the created FontProgram or not
Returns
created FontProgram instance

◆ GetRegisteredFontFamilies()

static ICollection<String> iText.IO.Font.FontProgramFactory.GetRegisteredFontFamilies ( )
inlinestatic

Gets a set of registered font names.

Returns
a set of registered font families

◆ GetRegisteredFonts()

static ICollection<String> iText.IO.Font.FontProgramFactory.GetRegisteredFonts ( )
inlinestatic

Gets a set of registered font names.

Returns
a set of registered fonts

◆ IsRegisteredFont()

static bool iText.IO.Font.FontProgramFactory.IsRegisteredFont ( String  fontName)
inlinestatic

Checks if a certain font is registered.

Parameters
fontNamethe name of the font that has to be checked.
Returns
true if the font is found

◆ RegisterFont() [1/2]

static void iText.IO.Font.FontProgramFactory.RegisterFont ( String  path)
inlinestatic

Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file.

Registers a .ttf, .otf, .afm, .pfm, or a .ttc font file. In case if TrueType Collection (.ttc), an additional parameter may be specified defining the index of the font to be registered, e.g. "path/to/font/collection.ttc,0". The index is zero-based.

Parameters
paththe path to a font file

◆ RegisterFont() [2/2]

static void iText.IO.Font.FontProgramFactory.RegisterFont ( String  path,
String  alias 
)
inlinestatic

Register a font file and use an alias for the font contained in it.

Parameters
paththe path to a font file
aliasthe alias you want to use for the font

◆ RegisterFontDirectory()

static int iText.IO.Font.FontProgramFactory.RegisterFontDirectory ( String  dir)
inlinestatic

Register all the fonts in a directory.

Parameters
dirthe directory
Returns
the number of fonts registered

◆ RegisterFontFamily()

static void iText.IO.Font.FontProgramFactory.RegisterFontFamily ( String  familyName,
String  fullName,
String  path 
)
inlinestatic

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

Parameters
familyNamethe font family
fullNamethe font name
paththe font path

◆ RegisterSystemFontDirectories()

static int iText.IO.Font.FontProgramFactory.RegisterSystemFontDirectories ( )
inlinestatic

Register fonts in some probable directories.

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

Returns
the number of fonts registered