Class PdfBoxFontResolver.FontDescription
java.lang.Object
com.openhtmltopdf.pdfboxout.PdfBoxFontResolver.FontDescription
- All Implemented Interfaces:
MinimalFontDescription
- Enclosing class:
PdfBoxFontResolver
public static class PdfBoxFontResolver.FontDescription
extends Object
implements MinimalFontDescription
A
FontDescription can exist in multiple states. Firstly the font may
or may not be realized. Fonts are automatically realized upon calling getFont()
Secondly, the metrics may or may not be available. If not available, you can attempt
to retrieve them by realizing the font.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.pdfbox.pdmodel.PDDocumentprivate final Stringprivate org.apache.pdfbox.pdmodel.font.PDFontprivate FSSupplier<org.apache.pdfbox.pdmodel.font.PDFont> private final booleanprivate final booleanprivate PdfBoxRawPDFontMetricsprivate final FSCacheEx<String, FSCacheValue> private final IdentValueprivate FSSupplier<InputStream> private final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionFontDescription(org.apache.pdfbox.pdmodel.font.PDFont font, IdentValue style, int weight) Create a font description from one of the PDF built-in fonts.FontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, FSSupplier<InputStream> supplier, int weight, IdentValue style, String family, boolean isFromFontFace, boolean isSubset, FSCacheEx<String, FSCacheValue> metricsCache) Create a font description from an input stream supplier.FontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, FSSupplier<org.apache.pdfbox.pdmodel.font.PDFont> fontSupplier, IdentValue style, int weight, String family, boolean isFromFontFace, boolean isSubset, FSCacheEx<String, FSCacheValue> metricsCache) Creates a font description from a PDFont supplier.privateFontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.font.PDFont font, IdentValue style, int weight) Create a font description when a PDFont is definitely available to begin with. -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcreateFontMetricsCacheKey(String family, int weight, IdentValue style) org.apache.pdfbox.pdmodel.font.PDFontgetFont()Downloads and parses the font if required.Downloads and parses the font if required (metrics were not available from cache).private PdfBoxRawPDFontMetricsgetFontMetricsFromCache(String family, int weight, IdentValue style) getStyle()intbooleanReturns whether the font is available yet.booleanbooleanIf the metrics are available yet.private booleanprivate voidputFontMetricsInCache(String family, int weight, IdentValue style, PdfBoxRawPDFontMetrics metrics) booleantoString()
-
Field Details
-
_style
-
_weight
private final int _weight -
_family
-
_doc
private final org.apache.pdfbox.pdmodel.PDDocument _doc -
_supplier
-
_fontSupplier
-
_font
private org.apache.pdfbox.pdmodel.font.PDFont _font -
_isFromFontFace
private final boolean _isFromFontFace -
_isSubset
private final boolean _isSubset -
_metrics
-
_metricsCache
-
-
Constructor Details
-
FontDescription
Create a font description from one of the PDF built-in fonts. -
FontDescription
public FontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, FSSupplier<InputStream> supplier, int weight, IdentValue style, String family, boolean isFromFontFace, boolean isSubset, FSCacheEx<String, FSCacheValue> metricsCache) Create a font description from an input stream supplier. The input stream will only be accessed ifgetFont()orgetFontMetrics()(and the font metrics were not available from cache) are called. -
FontDescription
private FontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, org.apache.pdfbox.pdmodel.font.PDFont font, IdentValue style, int weight) Create a font description when a PDFont is definitely available to begin with. Currently only used for PDF built-in fonts. -
FontDescription
public FontDescription(org.apache.pdfbox.pdmodel.PDDocument doc, FSSupplier<org.apache.pdfbox.pdmodel.font.PDFont> fontSupplier, IdentValue style, int weight, String family, boolean isFromFontFace, boolean isSubset, FSCacheEx<String, FSCacheValue> metricsCache) Creates a font description from a PDFont supplier. The supplier will only be called upon ifgetFont()orgetFontMetrics()(and the font metrics were not available from cache) are called.
-
-
Method Details
-
toString
-
getFamily
-
createFontMetricsCacheKey
-
getFontMetricsFromCache
-
putFontMetricsInCache
private void putFontMetricsInCache(String family, int weight, IdentValue style, PdfBoxRawPDFontMetrics metrics) -
loadMetrics
private boolean loadMetrics() -
realizeFont
public boolean realizeFont() -
isFontAvailable
public boolean isFontAvailable()Returns whether the font is available yet.- See Also:
-
getFont
public org.apache.pdfbox.pdmodel.font.PDFont getFont()Downloads and parses the font if required. Should only be called when the font is definitely needed.- Returns:
- the font or null if there was a problem.
-
getWeight
public int getWeight()- Specified by:
getWeightin interfaceMinimalFontDescription
-
getStyle
- Specified by:
getStylein interfaceMinimalFontDescription
-
isFromFontFace
public boolean isFromFontFace() -
isMetricsAvailable
public boolean isMetricsAvailable()If the metrics are available yet.- See Also:
-
getFontMetrics
Downloads and parses the font if required (metrics were not available from cache). Should only be called when the font metrics are definitely needed.- Returns:
- the font metrics or null if there was a problem.
- See Also:
-