Class BasicFontProvider
- java.lang.Object
-
- com.itextpdf.layout.font.FontProvider
-
- com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider
-
public class BasicFontProvider extends FontProvider
A basicFontProvider
that allows configuring in the constructor which fonts are loaded by default.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<byte[]>
calligraphyFontsTempList
private static java.lang.String
DEFAULT_FONT_FAMILY
private static Range
FREE_FONT_RANGE
private static java.lang.String[]
HTML_TO_PDF_SHIPPED_FONT_NAMES
The file names of the html2pdf shipped fonts.private static java.lang.String
HTML_TO_PDF_SHIPPED_FONT_RESOURCE_PATH
The path to the html2pdf shipped fonts.private static org.slf4j.Logger
LOGGER
protected java.util.List<java.lang.String>
shippedFontNames
The file names of the shipped fonts.protected java.lang.String
shippedFontResourcePath
The path to the shipped fonts.-
Fields inherited from class com.itextpdf.layout.font.FontProvider
defaultFontFamily, pdfFonts
-
-
Constructor Summary
Constructors Constructor Description BasicFontProvider()
Creates a newBasicFontProvider
instance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts)
Creates a newBasicFontProvider
instance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts)
Creates a newBasicFontProvider
instance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.BasicFontProvider(FontSet fontSet, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAllAvailableFonts(Range rangeToLoad)
protected Range
addCalligraphFonts()
This method loads a list of noto fonts from pdfCalligraph (if it is present in the classpath) into FontProvider.protected void
addShippedFonts(Range rangeToLoad)
Adds fonts shipped with the font provider.protected void
initShippedFontsResourcePath()
Initialize path to shipped fonts and list of font files.private boolean
isResourcePathAvailable()
-
Methods inherited from class com.itextpdf.layout.font.FontProvider
addDirectory, addFont, addFont, addFont, addFont, addFont, addFont, addFont, addFont, addFont, addStandardPdfFonts, addSystemFonts, createFontSelector, createFontSelectorStrategy, getDefaultCacheFlag, getDefaultEmbeddingFlag, getDefaultEncoding, getDefaultFontFamily, getFontSelector, getFontSelector, getFontSet, getPdfFont, getPdfFont, reset, setFontSelectorStrategyFactory
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
DEFAULT_FONT_FAMILY
private static final java.lang.String DEFAULT_FONT_FAMILY
- See Also:
- Constant Field Values
-
FREE_FONT_RANGE
private static final Range FREE_FONT_RANGE
-
HTML_TO_PDF_SHIPPED_FONT_RESOURCE_PATH
private static final java.lang.String HTML_TO_PDF_SHIPPED_FONT_RESOURCE_PATH
The path to the html2pdf shipped fonts.- See Also:
- Constant Field Values
-
HTML_TO_PDF_SHIPPED_FONT_NAMES
private static final java.lang.String[] HTML_TO_PDF_SHIPPED_FONT_NAMES
The file names of the html2pdf shipped fonts.
-
calligraphyFontsTempList
private final java.util.List<byte[]> calligraphyFontsTempList
-
shippedFontResourcePath
protected java.lang.String shippedFontResourcePath
The path to the shipped fonts.
-
shippedFontNames
protected java.util.List<java.lang.String> shippedFontNames
The file names of the shipped fonts.
-
-
Constructor Detail
-
BasicFontProvider
public BasicFontProvider()
Creates a newBasicFontProvider
instance.
-
BasicFontProvider
public BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts)
Creates a newBasicFontProvider
instance.- Parameters:
registerStandardPdfFonts
- use true if you want to register the standard Type 1 fonts (can't be embedded)registerSystemFonts
- use true if you want to register the system fonts (can require quite some resources)
-
BasicFontProvider
public BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts)
Creates a newBasicFontProvider
instance.- Parameters:
registerStandardPdfFonts
- use true if you want to register the standard Type 1 fonts (can't be embedded)registerShippedFonts
- use true if you want to register the shipped fonts (can be embedded)registerSystemFonts
- use true if you want to register the system fonts (can require quite some resources)
-
BasicFontProvider
public BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.- Parameters:
registerStandardPdfFonts
- use true if you want to register the standard Type 1 fonts (can't be embedded)registerSystemFonts
- use true if you want to register the system fonts (can require quite some resources)defaultFontFamily
- default font family
-
BasicFontProvider
public BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.- Parameters:
registerStandardPdfFonts
- use true if you want to register the standard Type 1 fonts (can't be embedded)registerShippedFonts
- use true if you want to register the shipped fonts (can be embedded)registerSystemFonts
- use true if you want to register the system fonts (can require quite some resources)defaultFontFamily
- default font family
-
BasicFontProvider
public BasicFontProvider(FontSet fontSet, java.lang.String defaultFontFamily)
Creates a newBasicFontProvider
instance.- Parameters:
fontSet
- predefined set of fonts, could be null.defaultFontFamily
- default font family.
-
-
Method Detail
-
addCalligraphFonts
protected Range addCalligraphFonts()
This method loads a list of noto fonts from pdfCalligraph (if it is present in the classpath) into FontProvider. The list is the following (each font is represented in regular and bold types): NotoSansArabic, NotoSansGurmukhi, NotoSansOriya, NotoSerifBengali, NotoSerifDevanagari, NotoSerifGujarati, NotoSerifHebrew, NotoSerifKannada, NotoSerifKhmer, NotoSerifMalayalam, NotoSerifTamil, NotoSerifTelugu, NotoSerifThai. If it's needed to have a BasicFontProvider without typography fonts loaded, create an extension of BasicFontProvider and override this method, so it does nothing and only returns null.- Returns:
- a unicode
Range
that excludes the loaded from pdfCalligraph fonts, i.e. the unicode range that is to be rendered with any other font contained in this FontProvider
-
addShippedFonts
protected void addShippedFonts(Range rangeToLoad)
Adds fonts shipped with the font provider. ForBasicFontProvider
this method does nothing but can be overridden to load additional fonts.- Parameters:
rangeToLoad
- a unicodeRange
to load characters
-
initShippedFontsResourcePath
protected void initShippedFontsResourcePath()
Initialize path to shipped fonts and list of font files.
-
isResourcePathAvailable
private boolean isResourcePathAvailable()
-
addAllAvailableFonts
private void addAllAvailableFonts(Range rangeToLoad)
-
-