Class BasicFontProvider
- java.lang.Object
-
- com.itextpdf.layout.font.FontProvider
-
- com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider
-
public class BasicFontProvider extends FontProvider
A basicFontProviderthat allows configuring in the constructor which fonts are loaded by default.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<byte[]>calligraphyFontsTempListprivate static java.lang.StringDEFAULT_FONT_FAMILYprivate static RangeFREE_FONT_RANGEprivate static java.lang.String[]HTML_TO_PDF_SHIPPED_FONT_NAMESThe file names of the html2pdf shipped fonts.private static java.lang.StringHTML_TO_PDF_SHIPPED_FONT_RESOURCE_PATHThe path to the html2pdf shipped fonts.private static org.slf4j.LoggerLOGGERprotected java.util.List<java.lang.String>shippedFontNamesThe file names of the shipped fonts.protected java.lang.StringshippedFontResourcePathThe path to the shipped fonts.-
Fields inherited from class com.itextpdf.layout.font.FontProvider
defaultFontFamily, pdfFonts
-
-
Constructor Summary
Constructors Constructor Description BasicFontProvider()Creates a newBasicFontProviderinstance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts)Creates a newBasicFontProviderinstance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts)Creates a newBasicFontProviderinstance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)Creates a newBasicFontProviderinstance.BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts, java.lang.String defaultFontFamily)Creates a newBasicFontProviderinstance.BasicFontProvider(FontSet fontSet, java.lang.String defaultFontFamily)Creates a newBasicFontProviderinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddAllAvailableFonts(Range rangeToLoad)protected RangeaddCalligraphFonts()This method loads a list of noto fonts from pdfCalligraph (if it is present in the classpath) into FontProvider.protected voidaddShippedFonts(Range rangeToLoad)Adds fonts shipped with the font provider.protected voidinitShippedFontsResourcePath()Initialize path to shipped fonts and list of font files.private booleanisResourcePathAvailable()-
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 newBasicFontProviderinstance.
-
BasicFontProvider
public BasicFontProvider(boolean registerStandardPdfFonts, boolean registerSystemFonts)Creates a newBasicFontProviderinstance.- 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 newBasicFontProviderinstance.- 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 newBasicFontProviderinstance.- 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 newBasicFontProviderinstance.- 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 newBasicFontProviderinstance.- 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
Rangethat 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. ForBasicFontProviderthis method does nothing but can be overridden to load additional fonts.- Parameters:
rangeToLoad- a unicodeRangeto 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)
-
-