iText 8.0.5 API
iText.Layout.Font.FontProvider Class Reference

Main entry point of font selector logic. More...

Inheritance diagram for iText.Layout.Font.FontProvider:
iText.StyledXmlParser.Resolver.Font.BasicFontProvider

Public Member Functions

  FontProvider (FontSet fontSet)
  Creates a new instance of FontProvider. More...
 
  FontProvider ()
  Creates a new instance of FontProvider. More...
 
  FontProvider (String defaultFontFamily)
  Creates a new instance of FontProvider. More...
 
  FontProvider (FontSet fontSet, String defaultFontFamily)
  Creates a new instance of FontProvider. More...
 
virtual bool  AddFont (FontProgram fontProgram, String encoding, Range unicodeRange)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (FontProgram fontProgram, String encoding)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (FontProgram fontProgram)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (String fontPath, String encoding, Range unicodeRange)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (String fontPath, String encoding)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (String fontPath)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (byte[] fontData, String encoding, Range unicodeRange)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (byte[] fontData, String encoding)
  Add font to FontSet cache. More...
 
virtual bool  AddFont (byte[] fontData)
  Add font to FontSet cache. More...
 
virtual int  AddDirectory (String dir)
  Add all the fonts from a directory. More...
 
virtual int  AddSystemFonts ()
  Add all fonts from system directories to FontSet cache. More...
 
virtual int  AddStandardPdfFonts ()
  Add standard fonts to FontSet cache. More...
 
virtual FontSet  GetFontSet ()
  Gets FontSet. More...
 
virtual String  GetDefaultFontFamily ()
  Gets the default font-family. More...
 
virtual String  GetDefaultEncoding (FontProgram fontProgram)
  Gets the default encoding for specific font. More...
 
virtual bool  GetDefaultCacheFlag ()
  The method is used to determine whether the font should be cached or not by default. More...
 
virtual bool  GetDefaultEmbeddingFlag ()
  The method is used to determine whether the font should be embedded or not by default. More...
 
virtual FontSelectorStrategy  GetStrategy (String text, IList< String > fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
  Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. More...
 
virtual FontSelectorStrategy  GetStrategy (String text, IList< String > fontFamilies, FontCharacteristics fc)
  Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. More...
 
virtual FontSelectorStrategy  GetStrategy (String text, IList< String > fontFamilies)
  Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. More...
 
virtual void  SetFontSelectorStrategyFactory (IFontSelectorStrategyFactory factory)
  Sets factory which will be used in method. More...
 
virtual IFontSelectorStrategy  CreateFontSelectorStrategy (IList< String > fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
  Creates the iText.Layout.Font.Selectorstrategy.IFontSelectorStrategy to split text into sequences of glyphs, already tied to the fonts which contain them. More...
 
FontSelector  GetFontSelector (IList< String > fontFamilies, FontCharacteristics fc)
  Create FontSelector or get from cache. More...
 
FontSelector  GetFontSelector (IList< String > fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
  Create FontSelector or get from cache. More...
 
virtual PdfFont  GetPdfFont (FontInfo fontInfo)
  Get from cache or create a new instance of iText.Kernel.Font.PdfFont. More...
 
virtual PdfFont  GetPdfFont (FontInfo fontInfo, FontSet additionalFonts)
  Get from cache or create a new instance of iText.Kernel.Font.PdfFont. More...
 
virtual void  Reset ()
  Resets PdfFont cache. More...
 

Package Functions

virtual FontSelector  CreateFontSelector (ICollection< FontInfo > fonts, IList< String > fontFamilies, FontCharacteristics fc)
  Create a new instance of FontSelector. More...
 

Package Attributes

readonly String  defaultFontFamily
  The default font-family is used by FontSelector if it's impossible to select a font for all other set font-families More...
 
readonly IDictionary< FontInfo, PdfFont pdfFonts
 

Detailed Description

Main entry point of font selector logic.

Main entry point of font selector logic. Contains reusable FontSet and collection of iText.Kernel.Font.PdfFont s. FontProvider depends on iText.Kernel.Pdf.PdfDocument due to iText.Kernel.Font.PdfFont , so it cannot be reused for different documents unless reset with Reset() or recreated with GetFontSet(). In the former case the FontSelectorCache is reused and in the latter it's reinitialised. FontProvider the only end point for creating iText.Kernel.Font.PdfFont.

It is allowed to use only one FontProvider per document. If additional fonts per element needed, another instance of FontSet can be used. For more details see iText.Layout.Properties.Property.FONT_SET , GetPdfFont(FontInfo, FontSet) , .

Note, FontProvider does not close created iText.IO.Font.FontProgram s, because of possible conflicts with iText.IO.Font.FontCache.

Constructor & Destructor Documentation

◆ FontProvider() [1/4]

iText.Layout.Font.FontProvider.FontProvider ( FontSet  fontSet )
inline

Creates a new instance of FontProvider.

Parameters
fontSet predefined set of fonts, could be null.

◆ FontProvider() [2/4]

iText.Layout.Font.FontProvider.FontProvider ( )
inline

Creates a new instance of FontProvider.

◆ FontProvider() [3/4]

iText.Layout.Font.FontProvider.FontProvider ( String  defaultFontFamily )
inline

Creates a new instance of FontProvider.

Parameters
defaultFontFamily default font family.

◆ FontProvider() [4/4]

iText.Layout.Font.FontProvider.FontProvider ( FontSet  fontSet,
String  defaultFontFamily 
)
inline

Creates a new instance of FontProvider.

Parameters
fontSet predefined set of fonts, could be null.
defaultFontFamily default font family.

Member Function Documentation

◆ AddDirectory()

virtual int iText.Layout.Font.FontProvider.AddDirectory ( String  dir )
inlinevirtual

Add all the fonts from a directory.

Parameters
dir path to directory.
Returns
number of added fonts.

◆ AddFont() [1/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( byte[]  fontData )
inlinevirtual

Add font to FontSet cache.

Parameters
fontData byte content of the font program file.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [2/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( byte[]  fontData,
String  encoding 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontData byte content of the font program file.
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [3/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( byte[]  fontData,
String  encoding,
Range  unicodeRange 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontData byte content of the font program file.
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
unicodeRange sets the specific range of characters to be used from the font.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [4/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( FontProgram  fontProgram )
inlinevirtual

Add font to FontSet cache.

Parameters
fontProgram the font file which will be added to font cache. The iText.IO.Font.FontProgram instances are normally created via iText.IO.Font.FontProgramFactory.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [5/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( FontProgram  fontProgram,
String  encoding 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontProgram the font file which will be added to font cache. The iText.IO.Font.FontProgram instances are normally created via iText.IO.Font.FontProgramFactory.
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [6/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( FontProgram  fontProgram,
String  encoding,
Range  unicodeRange 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontProgram the font file which will be added to font cache. The iText.IO.Font.FontProgram instances are normally created via iText.IO.Font.FontProgramFactory.
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
unicodeRange sets the specific range of characters to be used from the font.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [7/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( String  fontPath )
inlinevirtual

Add font to FontSet cache.

Parameters
fontPath path to the font file to add. Can be a path to file or font name, see iText.IO.Font.FontProgramFactory.CreateFont(System.String).
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [8/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( String  fontPath,
String  encoding 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontPath path to the font file to add. Can be a path to file or font name, see iText.IO.Font.FontProgramFactory.CreateFont(System.String).
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
Returns
true, if font was successfully added, otherwise false.

◆ AddFont() [9/9]

virtual bool iText.Layout.Font.FontProvider.AddFont ( String  fontPath,
String  encoding,
Range  unicodeRange 
)
inlinevirtual

Add font to FontSet cache.

Parameters
fontPath path to the font file to add. Can be a path to file or font name, see iText.IO.Font.FontProgramFactory.CreateFont(System.String).
encoding font encoding to create iText.Kernel.Font.PdfFont . Possible values for this argument are the same as for iText.Kernel.Font.PdfFontFactory.CreateFont() family of methods.
unicodeRange sets the specific range of characters to be used from the font.
Returns
true, if font was successfully added, otherwise false.

◆ AddStandardPdfFonts()

virtual int iText.Layout.Font.FontProvider.AddStandardPdfFonts ( )
inlinevirtual

Add standard fonts to FontSet cache.

Returns
number of added fonts.
See also
iText.IO.Font.Constants.StandardFonts

◆ AddSystemFonts()

virtual int iText.Layout.Font.FontProvider.AddSystemFonts ( )
inlinevirtual

Add all fonts from system directories to FontSet cache.

Returns
number of added fonts.

◆ CreateFontSelector()

virtual FontSelector iText.Layout.Font.FontProvider.CreateFontSelector ( ICollection< FontInfo fonts,
IList< String >  fontFamilies,
FontCharacteristics  fc 
)
inlinepackagevirtual

Create a new instance of FontSelector.

Create a new instance of FontSelector . While caching is main responsibility of GetFontSelector(System.Collections.Generic.IList, FontCharacteristics, FontSet). This method just create a new instance of FontSelector.

Parameters
fonts Set of all available fonts in current context.
fontFamilies target font families.
fc instance of FontCharacteristics.
Returns
an instance of FontSelector.

◆ CreateFontSelectorStrategy()

virtual IFontSelectorStrategy iText.Layout.Font.FontProvider.CreateFontSelectorStrategy ( IList< String >  fontFamilies,
FontCharacteristics  fc,
FontSet  additionalFonts 
)
inlinevirtual

Creates the iText.Layout.Font.Selectorstrategy.IFontSelectorStrategy to split text into sequences of glyphs, already tied to the fonts which contain them.

Creates the iText.Layout.Font.Selectorstrategy.IFontSelectorStrategy to split text into sequences of glyphs, already tied to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and are chosen based on font-families list and desired font characteristics.

Parameters
fontFamilies target font families to create FontSelector for sequences of glyphs.
fc instance of FontCharacteristics to create FontSelector for sequences of glyphs.
additionalFonts set which provides fonts additionally to the fonts added to font provider. Combined set of font provider fonts and additional fonts is used when choosing a single font for a sequence of glyphs. Additional fonts will only be used for the given font selector strategy instance and will not be otherwise preserved in font provider.
Returns

iText.Layout.Font.Selectorstrategy.IFontSelectorStrategy instance

◆ GetDefaultCacheFlag()

virtual bool iText.Layout.Font.FontProvider.GetDefaultCacheFlag ( )
inlinevirtual

The method is used to determine whether the font should be cached or not by default.

The method is used to determine whether the font should be cached or not by default.

NOTE: This method can be overridden to customize behaviour.

Returns
the default cache flag

◆ GetDefaultEmbeddingFlag()

virtual bool iText.Layout.Font.FontProvider.GetDefaultEmbeddingFlag ( )
inlinevirtual

The method is used to determine whether the font should be embedded or not by default.

The method is used to determine whether the font should be embedded or not by default.

NOTE: This method can be overridden to customize behaviour.

Returns
the default embedding flag

◆ GetDefaultEncoding()

virtual String iText.Layout.Font.FontProvider.GetDefaultEncoding ( FontProgram  fontProgram )
inlinevirtual

Gets the default encoding for specific font.

Parameters
fontProgram to get default encoding
Returns
the default encoding
See also
iText.IO.Font.PdfEncodings

◆ GetDefaultFontFamily()

virtual String iText.Layout.Font.FontProvider.GetDefaultFontFamily ( )
inlinevirtual

Gets the default font-family.

Returns
the default font-family

◆ GetFontSelector() [1/2]

FontSelector iText.Layout.Font.FontProvider.GetFontSelector ( IList< String >  fontFamilies,
FontCharacteristics  fc 
)
inline

Create FontSelector or get from cache.

Parameters
fontFamilies target font families.
fc instance of FontCharacteristics.
Returns
an instance of FontSelector.
See also
CreateFontSelector(System.Collections.Generic.ICollection, System.Collections.Generic.IList, FontCharacteristics) , GetFontSelector(System.Collections.Generic.IList, FontCharacteristics, FontSet)

◆ GetFontSelector() [2/2]

FontSelector iText.Layout.Font.FontProvider.GetFontSelector ( IList< String >  fontFamilies,
FontCharacteristics  fc,
FontSet  additionalFonts 
)
inline

Create FontSelector or get from cache.

Parameters
fontFamilies target font families.
fc instance of FontCharacteristics.
additionalFonts set which provides fonts additionally to the fonts added to font provider. Combined set of font provider fonts and additional fonts is used when choosing a single font for FontSelector . Additional fonts will only be used for the given font selector strategy instance and will not be otherwise preserved in font provider.
Returns
an instance of FontSelector.
See also
CreateFontSelector(System.Collections.Generic.ICollection, System.Collections.Generic.IList, FontCharacteristics)

}

◆ GetFontSet()

virtual FontSet iText.Layout.Font.FontProvider.GetFontSet ( )
inlinevirtual

Gets FontSet.

Returns
the font set

◆ GetPdfFont() [1/2]

virtual PdfFont iText.Layout.Font.FontProvider.GetPdfFont ( FontInfo  fontInfo )
inlinevirtual

Get from cache or create a new instance of iText.Kernel.Font.PdfFont.

Parameters
fontInfo font info, to create iText.IO.Font.FontProgram and iText.Kernel.Font.PdfFont.
Returns
cached or new instance of iText.Kernel.Font.PdfFont.

◆ GetPdfFont() [2/2]

virtual PdfFont iText.Layout.Font.FontProvider.GetPdfFont ( FontInfo  fontInfo,
FontSet  additionalFonts 
)
inlinevirtual

Get from cache or create a new instance of iText.Kernel.Font.PdfFont.

Parameters
fontInfo font info, to create iText.IO.Font.FontProgram and iText.Kernel.Font.PdfFont.
additionalFonts set of additional fonts to consider.
Returns
cached or new instance of iText.Kernel.Font.PdfFont.

◆ GetStrategy() [1/3]

virtual FontSelectorStrategy iText.Layout.Font.FontProvider.GetStrategy ( String  text,
IList< String >  fontFamilies 
)
inlinevirtual

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and are chosen based on font-families list and desired font characteristics.

Parameters
text for splitting into sequences of glyphs.
fontFamilies target font families to create FontSelector for sequences of glyphs.
Returns

FontSelectorStrategy instance.

◆ GetStrategy() [2/3]

virtual FontSelectorStrategy iText.Layout.Font.FontProvider.GetStrategy ( String  text,
IList< String >  fontFamilies,
FontCharacteristics  fc 
)
inlinevirtual

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and are chosen based on font-families list and desired font characteristics.

Parameters
text for splitting into sequences of glyphs.
fontFamilies target font families to create FontSelector for sequences of glyphs.
fc instance of FontCharacteristics to create FontSelector for sequences of glyphs.
Returns

FontSelectorStrategy instance.

◆ GetStrategy() [3/3]

virtual FontSelectorStrategy iText.Layout.Font.FontProvider.GetStrategy ( String  text,
IList< String >  fontFamilies,
FontCharacteristics  fc,
FontSet  additionalFonts 
)
inlinevirtual

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.

Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them. The fonts can be taken from the added fonts to the font provider and are chosen based on font-families list and desired font characteristics.

Parameters
text for splitting into sequences of glyphs.
fontFamilies target font families to create FontSelector for sequences of glyphs.
fc instance of FontCharacteristics to create FontSelector for sequences of glyphs.
additionalFonts set which provides fonts additionally to the fonts added to font provider. Combined set of font provider fonts and additional fonts is used when choosing a single font for a sequence of glyphs. Additional fonts will only be used for the given font selector strategy instance and will not be otherwise preserved in font provider.
Returns

FontSelectorStrategy instance.

◆ Reset()

virtual void iText.Layout.Font.FontProvider.Reset ( )
inlinevirtual

Resets PdfFont cache.

Resets PdfFont cache. After calling that method FontProvider can be reused with another iText.Kernel.Pdf.PdfDocument

◆ SetFontSelectorStrategyFactory()

virtual void iText.Layout.Font.FontProvider.SetFontSelectorStrategyFactory ( IFontSelectorStrategyFactory  factory )
inlinevirtual

Sets factory which will be used in method.

Parameters
factory the factory which will be used to create font selector strategies

Member Data Documentation

◆ defaultFontFamily

readonly String iText.Layout.Font.FontProvider.defaultFontFamily
package

The default font-family is used by FontSelector if it's impossible to select a font for all other set font-families