Class FontProvider
public class FontProvider
- Inheritance
-
FontProvider
- Derived
- Inherited Members
Constructors
FontProvider()
Creates a new instance of FontProvider.
public FontProvider()
FontProvider(string)
Creates a new instance of FontProvider.
public FontProvider(string defaultFontFamily)
Parameters
defaultFontFamily
stringdefault font family.
FontProvider(FontSet)
Creates a new instance of FontProvider.
public FontProvider(FontSet fontSet)
Parameters
fontSet
FontSetpredefined set of fonts, could be null.
FontProvider(FontSet, string)
Creates a new instance of FontProvider.
public FontProvider(FontSet fontSet, string defaultFontFamily)
Parameters
fontSet
FontSetpredefined set of fonts, could be null.
defaultFontFamily
stringdefault font family.
Fields
defaultFontFamily
The default font-family is used by FontSelector if it's impossible to select a font for all other set font-families
protected readonly string defaultFontFamily
Field Value
pdfFonts
protected readonly IDictionary<FontInfo, PdfFont> pdfFonts
Field Value
Methods
AddDirectory(string)
Add all the fonts from a directory.
public virtual int AddDirectory(string dir)
Parameters
dir
stringpath to directory.
Returns
- int
number of added fonts.
AddFont(byte[])
Add font to FontSet cache.
public virtual bool AddFont(byte[] fontData)
Parameters
fontData
byte[]byte content of the font program file.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(byte[], string)
Add font to FontSet cache.
public virtual bool AddFont(byte[] fontData, string encoding)
Parameters
fontData
byte[]byte content of the font program file.
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(byte[], string, Range)
Add font to FontSet cache.
public virtual bool AddFont(byte[] fontData, string encoding, Range unicodeRange)
Parameters
fontData
byte[]byte content of the font program file.
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
unicodeRange
Rangesets the specific range of characters to be used from the font.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(string)
Add font to FontSet cache.
public virtual bool AddFont(string fontPath)
Parameters
fontPath
stringpath to the font file to add. Can be a path to file or font name, see CreateFont(string).
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(string, string)
Add font to FontSet cache.
public virtual bool AddFont(string fontPath, string encoding)
Parameters
fontPath
stringpath to the font file to add. Can be a path to file or font name, see CreateFont(string).
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(string, string, Range)
Add font to FontSet cache.
public virtual bool AddFont(string fontPath, string encoding, Range unicodeRange)
Parameters
fontPath
stringpath to the font file to add. Can be a path to file or font name, see CreateFont(string).
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
unicodeRange
Rangesets the specific range of characters to be used from the font.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(FontProgram)
Add font to FontSet cache.
public virtual bool AddFont(FontProgram fontProgram)
Parameters
fontProgram
FontProgramthe font file which will be added to font cache. The FontProgram instances are normally created via FontProgramFactory.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(FontProgram, string)
Add font to FontSet cache.
public virtual bool AddFont(FontProgram fontProgram, string encoding)
Parameters
fontProgram
FontProgramthe font file which will be added to font cache. The FontProgram instances are normally created via FontProgramFactory.
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
Returns
- bool
true, if font was successfully added, otherwise false.
AddFont(FontProgram, string, Range)
Add font to FontSet cache.
public virtual bool AddFont(FontProgram fontProgram, string encoding, Range unicodeRange)
Parameters
fontProgram
FontProgramthe font file which will be added to font cache. The FontProgram instances are normally created via FontProgramFactory.
encoding
stringfont encoding to create PdfFont . Possible values for this argument are the same as for CreateFont() family of methods.
unicodeRange
Rangesets the specific range of characters to be used from the font.
Returns
- bool
true, if font was successfully added, otherwise false.
AddStandardPdfFonts()
Add standard fonts to FontSet cache.
public virtual int AddStandardPdfFonts()
Returns
- int
number of added fonts.
- See Also
AddSystemFonts()
Add all fonts from system directories to FontSet cache.
public virtual int AddSystemFonts()
Returns
- int
number of added fonts.
CreateFontSelector(ICollection<FontInfo>, IList<string>, FontCharacteristics)
Create a new instance of FontSelector.
protected virtual FontSelector CreateFontSelector(ICollection<FontInfo> fonts, IList<string> fontFamilies, FontCharacteristics fc)
Parameters
fonts
ICollection<FontInfo>Set of all available fonts in current context.
fontFamilies
IList<string>target font families.
fc
FontCharacteristicsinstance of FontCharacteristics.
Returns
- FontSelector
an instance of FontSelector.
Remarks
Create a new instance of
FontSelector
. While caching is main responsibility of
CreateFontSelectorStrategy(IList<string>, FontCharacteristics, FontSet)
Creates the IFontSelectorStrategy to split text into sequences of glyphs, already tied to the fonts which contain them.
public virtual IFontSelectorStrategy CreateFontSelectorStrategy(IList<string> fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
Parameters
fontFamilies
IList<string>target font families to create FontSelector for sequences of glyphs.
fc
FontCharacteristicsinstance of FontCharacteristics to create FontSelector for sequences of glyphs.
additionalFonts
FontSetset 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
Remarks
Creates the 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.
GetDefaultCacheFlag()
The method is used to determine whether the font should be cached or not by default.
public virtual bool GetDefaultCacheFlag()
Returns
- bool
the default cache flag
Remarks
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.GetDefaultEmbeddingFlag()
The method is used to determine whether the font should be embedded or not by default.
public virtual bool GetDefaultEmbeddingFlag()
Returns
- bool
the default embedding flag
Remarks
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.GetDefaultEncoding(FontProgram)
Gets the default encoding for specific font.
public virtual string GetDefaultEncoding(FontProgram fontProgram)
Parameters
fontProgram
FontProgramto get default encoding
Returns
- string
the default encoding
- See Also
GetDefaultFontFamily()
Gets the default font-family.
public virtual string GetDefaultFontFamily()
Returns
- string
the default font-family
GetFontSelector(IList<string>, FontCharacteristics)
Create FontSelector or get from cache.
public FontSelector GetFontSelector(IList<string> fontFamilies, FontCharacteristics fc)
Parameters
fontFamilies
IList<string>target font families.
fc
FontCharacteristicsinstance of FontCharacteristics.
Returns
- FontSelector
an instance of FontSelector.
GetFontSelector(IList<string>, FontCharacteristics, FontSet)
Create FontSelector or get from cache.
public FontSelector GetFontSelector(IList<string> fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
Parameters
fontFamilies
IList<string>target font families.
fc
FontCharacteristicsinstance of FontCharacteristics.
additionalFonts
FontSetset 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
- FontSelector
an instance of FontSelector.
GetFontSet()
Gets FontSet.
public virtual FontSet GetFontSet()
Returns
- FontSet
the font set
GetPdfFont(FontInfo)
Get from cache or create a new instance of PdfFont.
public virtual PdfFont GetPdfFont(FontInfo fontInfo)
Parameters
fontInfo
FontInfofont info, to create FontProgram and PdfFont.
Returns
GetPdfFont(FontInfo, FontSet)
Get from cache or create a new instance of PdfFont.
public virtual PdfFont GetPdfFont(FontInfo fontInfo, FontSet additionalFonts)
Parameters
fontInfo
FontInfofont info, to create FontProgram and PdfFont.
additionalFonts
FontSetset of additional fonts to consider.
Returns
GetStrategy(string, IList<string>)
Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.
[Obsolete("use CreateFontSelectorStrategy(System.Collections.Generic.IList{E}, FontCharacteristics, FontSet)")]
public virtual FontSelectorStrategy GetStrategy(string text, IList<string> fontFamilies)
Parameters
text
stringfor splitting into sequences of glyphs.
fontFamilies
IList<string>target font families to create FontSelector for sequences of glyphs.
Returns
- FontSelectorStrategy
FontSelectorStrategy instance.
Remarks
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.
GetStrategy(string, IList<string>, FontCharacteristics)
Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.
[Obsolete("use CreateFontSelectorStrategy(System.Collections.Generic.IList{E}, FontCharacteristics, FontSet)")]
public virtual FontSelectorStrategy GetStrategy(string text, IList<string> fontFamilies, FontCharacteristics fc)
Parameters
text
stringfor splitting into sequences of glyphs.
fontFamilies
IList<string>target font families to create FontSelector for sequences of glyphs.
fc
FontCharacteristicsinstance of FontCharacteristics to create FontSelector for sequences of glyphs.
Returns
- FontSelectorStrategy
FontSelectorStrategy instance.
Remarks
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.
GetStrategy(string, IList<string>, FontCharacteristics, FontSet)
Gets the FontSelectorStrategy to split specified text into sequences of glyphs, already tied to the fonts which contain them.
[Obsolete("use CreateFontSelectorStrategy(System.Collections.Generic.IList{E}, FontCharacteristics, FontSet)")]
public virtual FontSelectorStrategy GetStrategy(string text, IList<string> fontFamilies, FontCharacteristics fc, FontSet additionalFonts)
Parameters
text
stringfor splitting into sequences of glyphs.
fontFamilies
IList<string>target font families to create FontSelector for sequences of glyphs.
fc
FontCharacteristicsinstance of FontCharacteristics to create FontSelector for sequences of glyphs.
additionalFonts
FontSetset 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
FontSelectorStrategy instance.
Remarks
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.
Reset()
Resets PdfFont cache.
public virtual void Reset()
Remarks
Resets PdfFont cache. After calling that method FontProvider can be reused with another PdfDocument
SetFontSelectorStrategyFactory(IFontSelectorStrategyFactory)
public virtual void SetFontSelectorStrategyFactory(IFontSelectorStrategyFactory factory)
Parameters
factory
IFontSelectorStrategyFactory