Class AbstractFontSelectorStrategy
java.lang.Object
com.itextpdf.layout.font.selectorstrategy.AbstractFontSelectorStrategy
- All Implemented Interfaces:
-
IFontSelectorStrategy
- Direct Known Subclasses:
-
BestMatchFontSelectorStrategy
,FirstMatchFontSelectorStrategy
The class defines complex implementation of
IFontSelectorStrategy
which based on the following algorithm: 1. Find first significant symbol (not whitespace or special). 2. Find font which matches symbol according to passed FontSelector
. 3. Try to append as many symbols as possible using the current font. 4. If symbol is not matched to the current font, go to step 1.
Algorithm takes care of the case when there is no matched font for symbol or when diacritic from another font is used (previous symbol will be processed by diacritic's font).
-
Constructor Summary
ConstructorDescriptionAbstractFontSelectorStrategy
(FontProvider fontProvider, FontSelector fontSelector, FontSet additionalFonts) Creates a new instance ofAbstractFontSelectorStrategy
. -
Method Summary
Modifier and TypeMethodDescriptiongetGlyphLines
(String text) Converts text into glyphs with the best matching font.protected abstract boolean
If it is necessary to provide a check that the best font for passed symbol equals to the current font.protected PdfFont
matchFont
(int codePoint, FontSelector fontSelector, FontProvider fontProvider, FontSet additionalFonts) Finds the best font which matches passed symbol.
-
Constructor Details
-
AbstractFontSelectorStrategy
public AbstractFontSelectorStrategy(FontProvider fontProvider, FontSelector fontSelector, FontSet additionalFonts) Creates a new instance ofAbstractFontSelectorStrategy
.- Parameters:
-
fontProvider
- the font provider -
fontSelector
- the font selector -
additionalFonts
- the set of fonts to be used additionally to the fonts added to font provider.
-
-
Method Details
-
isCurrentFontCheckRequired
protected abstract boolean isCurrentFontCheckRequired()If it is necessary to provide a check that the best font for passed symbol equals to the current font. Result of checking is used to split text into parts in case if inequality.- Returns:
-
true
if check is needed, otherwisefalse
-
getGlyphLines
Converts text into glyphs with the best matching font.- Specified by:
-
getGlyphLines
in interfaceIFontSelectorStrategy
- Parameters:
-
text
- the text to split - Returns:
- the glyphs with the matching font attached
-
matchFont
protected PdfFont matchFont(int codePoint, FontSelector fontSelector, FontProvider fontProvider, FontSet additionalFonts) Finds the best font which matches passed symbol.- Parameters:
-
codePoint
- the symbol to match -
fontSelector
- the font selector -
fontProvider
- the font provider -
additionalFonts
- the addition fonts - Returns:
- font which matches the symbol
-