iText 8.0.2 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 (String fontProgram, String cmap, 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/8]

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/8]

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
fontProgram the byte contents of the font program
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [3/8]

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
fontProgram the byte contents of the font program
cached whether to to cache this font program
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [4/8]

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
ttc the content of a TrueType Collection file (*.ttc)
ttcIndex the index of the font file from the collection to be read
cached 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
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/8]

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
fontProgram the name of the font or its location on file
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [6/8]

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
fontProgram the name of the font or its location on file
cached whether 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/8]

static FontProgram iText.IO.Font.FontProgramFactory.CreateFont ( String  fontProgram,
String  cmap,
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
fontProgram the name of the font or its location on file
cmap CMap to convert Unicode value to CID if CJK font is used
cached whether to cache this font program after it has been loaded
Returns
returns a new FontProgram . This font program may come from the cache

◆ CreateFont() [8/8]

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
ttc location of TrueType Collection file (*.ttc)
ttcIndex the index of the font file from the collection to be read
cached 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
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
fontName either 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
fontName either a font alias, if the font file has been registered with an alias, or just a font name otherwise
style the 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
fontName either a font alias, if the font file has been registered with an alias, or just a font name otherwise
style the 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
cached whether 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
afm the contents of the AFM or PFM metrics file
pfb the 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
afm the contents of the AFM or PFM metrics file
pfb the contents of the PFB file
cached specifies 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
metricsPath path to the AFM or PFM metrics file
binaryPath path 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
metricsPath path to the AFM or PFM metrics file
binaryPath path to the contents of the PFB file
cached specifies whether to cache the created FontProgram or not
Returns
created FontProgram instance

◆ GetRegisteredFontFamilies()

static ICollection iText.IO.Font.FontProgramFactory.GetRegisteredFontFamilies ( )
inlinestatic

Gets a set of registered font names.

Returns
a set of registered font families

◆ GetRegisteredFonts()

static ICollection 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
fontName the 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
path the 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
path the path to a font file
alias the 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
dir the 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
familyName the font family
fullName the font name
path the 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