public class FontProvider extends Object
FontSet
and collection of PdfFont
s.
FontProvider depends on PdfDocument
due to 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 PdfFont
.
It is allowed 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 String |
defaultFontFamily
The default font-family is used by
FontSelector if it's impossible to select a font for all other set font-families |
protected Map<FontInfo,PdfFont> |
pdfFonts |
Constructor and Description |
---|
FontProvider()
Creates a new instance of FontProvider.
|
FontProvider(FontSet fontSet)
Creates a new instance of FontProvider
|
FontProvider(FontSet fontSet,
String defaultFontFamily)
Creates a new instance of FontProvider
|
FontProvider(String defaultFontFamily)
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(com.itextpdf.io.font.FontProgram fontProgram) |
boolean |
addFont(com.itextpdf.io.font.FontProgram fontProgram,
String encoding) |
boolean |
addFont(com.itextpdf.io.font.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(com.itextpdf.io.font.FontProgram fontProgram) |
String |
getDefaultFontFamily()
Gets the default font-family
|
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) |
void |
reset()
Resets
PdfFont cache . |
protected final String defaultFontFamily
FontSelector
if it's impossible to select a font for all other set font-familiespublic FontProvider(FontSet fontSet)
fontSet
- predefined set of fonts, could be null.public FontProvider()
public FontProvider(String defaultFontFamily)
defaultFontFamily
- default font family.public boolean addFont(com.itextpdf.io.font.FontProgram fontProgram, String encoding, Range unicodeRange)
public boolean addFont(com.itextpdf.io.font.FontProgram fontProgram, String encoding)
public boolean addFont(com.itextpdf.io.font.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 getDefaultFontFamily()
public String getDefaultEncoding(com.itextpdf.io.font.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 familiesfc
- 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 familiesfc
- 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 familiesfc
- instance of FontCharacteristics
.FontSelector
.public PdfFont getPdfFont(FontInfo fontInfo)
PdfFont
.public PdfFont getPdfFont(FontInfo fontInfo, FontSet tempFonts)
PdfFont
.public void reset()
Copyright © 1998–2019 iText Group NV. All rights reserved.