Package com.itextpdf.layout.font
Class FontSelector.PdfFontComparator
java.lang.Object
com.itextpdf.layout.font.FontSelector.PdfFontComparator
- All Implemented Interfaces:
Comparator<FontInfo>
- Enclosing class:
FontSelector
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
characteristicsSimilarity
(String fontFamily, FontCharacteristics fc, FontInfo fontInfo, boolean isLastFontFamilyToBeProcessed) This method is used to compare two fonts (the required one which is described by fontInfo and the one to be examined which is described by fc and fontFamily) and measure their similarity.int
private static int
family2Similarity
(String fontFamily, FontCharacteristics fc, FontInfo fontInfo) This method is a fallback to compare family2 field if the main method wasn't able to prioritize the fonts.private static FontCharacteristics
parseFontStyle
(String fontFamily, FontCharacteristics fc) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
fontFamilies
-
fontStyles
List<FontCharacteristics> fontStyles
-
-
Constructor Details
-
PdfFontComparator
PdfFontComparator(List<String> fontFamilies, FontCharacteristics fc)
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<FontInfo>
-
parseFontStyle
-
characteristicsSimilarity
private static int characteristicsSimilarity(String fontFamily, FontCharacteristics fc, FontInfo fontInfo, boolean isLastFontFamilyToBeProcessed) This method is used to compare two fonts (the required one which is described by fontInfo and the one to be examined which is described by fc and fontFamily) and measure their similarity. The more the fonts are similar the higher the score is.Firstly we check if the font-family described by fontInfo equals to the required one. If it's not true the examination fails, it continues otherwise. If the required font-family is monospace, serif or sans serif we check whether the font under examination is monospace, serif or sans serif resp. Its font-family is not taking into considerations.
If font-family is respected, we consider the next font-style characteristics to select the required font of the respected font-family: a) bold b) italic
-
family2Similarity
This method is a fallback to compare family2 field if the main method wasn't able to prioritize the fonts.
-