public class FontProvider extends Object
FontSet
and collection of PdfFont
s. FontProvider depends from PdfDocument
, due to PdfFont
, it cannot be reused for different documents, but a new instance of FontProvider could be created with getFontSet()
. FontProvider the only end point for creating PdfFont
.
It is recommended to use only one FontProvider
per document. If temporary fonts per element needed, additional FontSet
can be used. For more details see Property.FONT_SET
, getPdfFont(FontInfo, FontSet)
, getStrategy(String, List, FontCharacteristics, FontSet)
.
Note, FontProvider does not close created FontProgram
s, because of possible conflicts with FontCache
.
Modifier and Type | Field and Description |
---|---|
protected Map<FontInfo,PdfFont> |
pdfFonts |
Constructor and Description |
---|
FontProvider()
Creates a new instance of FontProvider.
|
FontProvider(FontSet fontSet)
Creates a new instance of FontProvider
|
Modifier and Type | Method and Description |
---|---|
int |
addDirectory(String dir) |
boolean |
addFont(byte[] fontData) |
boolean |
addFont(byte[] fontData, String encoding) |
boolean |
addFont(byte[] fontData, String encoding, Range unicodeRange) |
boolean |
addFont(FontProgram fontProgram) |
boolean |
addFont(FontProgram fontProgram, String encoding) |
boolean |
addFont(FontProgram fontProgram, String encoding, Range unicodeRange) |
boolean |
addFont(String fontPath) |
boolean |
addFont(String fontPath, String encoding) |
boolean |
addFont(String fontPath, String encoding, Range unicodeRange) |
int |
addStandardPdfFonts() |
int |
addSystemFonts() |
protected FontSelector |
createFontSelector(Collection<FontInfo> fonts, List<String> fontFamilies, FontCharacteristics fc)
Create a new instance of FontSelector .
|
boolean |
getDefaultCacheFlag() |
boolean |
getDefaultEmbeddingFlag() |
String |
getDefaultEncoding(FontProgram fontProgram) |
FontSelector |
getFontSelector(List<String> fontFamilies, FontCharacteristics fc)
Create FontSelector or get from cache.
|
FontSelector |
getFontSelector(List<String> fontFamilies, FontCharacteristics fc, FontSet tempFonts)
Create FontSelector or get from cache.
|
FontSet |
getFontSet()
Gets FontSet .
|
PdfFont |
getPdfFont(FontInfo fontInfo)
Get from cache or create a new instance of PdfFont .
|
PdfFont |
getPdfFont(FontInfo fontInfo, FontSet tempFonts)
Get from cache or create a new instance of PdfFont .
|
FontSelectorStrategy |
getStrategy(String text, List<String> fontFamilies) |
FontSelectorStrategy |
getStrategy(String text, List<String> fontFamilies, FontCharacteristics fc) |
FontSelectorStrategy |
getStrategy(String text, List<String> fontFamilies, FontCharacteristics fc, FontSet additonalFonts) |
public FontProvider(FontSet fontSet)
fontSet
- predefined set of fonts, could be null.
public FontProvider()
public boolean addFont(FontProgram fontProgram, String encoding, Range unicodeRange)
public boolean addFont(FontProgram fontProgram, String encoding)
public boolean addFont(FontProgram fontProgram)
public boolean addFont(String fontPath)
public boolean addFont(byte[] fontData, String encoding)
public boolean addFont(byte[] fontData)
public int addDirectory(String dir)
public int addSystemFonts()
public int addStandardPdfFonts()
public String getDefaultEncoding(FontProgram fontProgram)
public boolean getDefaultCacheFlag()
public boolean getDefaultEmbeddingFlag()
public FontSelectorStrategy getStrategy(String text, List<String> fontFamilies, FontCharacteristics fc, FontSet additonalFonts)
public FontSelectorStrategy getStrategy(String text, List<String> fontFamilies, FontCharacteristics fc)
public FontSelectorStrategy getStrategy(String text, List<String> fontFamilies)
public final FontSelector getFontSelector(List<String> fontFamilies, FontCharacteristics fc)
FontSelector
or get from cache.
fontFamilies
- target font families
fc
- instance of FontCharacteristics
.
FontSelector
.
createFontSelector(Collection, List, FontCharacteristics)
, getFontSelector(List, FontCharacteristics, FontSet)
public final FontSelector getFontSelector(List<String> fontFamilies, FontCharacteristics fc, FontSet tempFonts)
FontSelector
or get from cache.
fontFamilies
- target font families
fc
- instance of FontCharacteristics
.
tempFonts
- set of temporary fonts.
FontSelector
.
}
protected FontSelector createFontSelector(Collection<FontInfo> fonts, List<String> fontFamilies, FontCharacteristics fc)
FontSelector
. While caching is main responsibility of getFontSelector(List, FontCharacteristics, FontSet)
. This method just create a new instance of FontSelector
.
fonts
- Set of all available fonts in current context.
fontFamilies
- target font families
fc
- instance of FontCharacteristics
.
FontSelector
.
public PdfFont getPdfFont(FontInfo fontInfo)
PdfFont
.
fontInfo
- font info, to create FontProgram
and PdfFont
.
PdfFont
.
Copyright © 1998–2018 iText Group NV. All rights reserved.