Class PdfBoxFontResolver.FontDescription

  • All Implemented Interfaces:
    com.openhtmltopdf.outputdevice.helper.MinimalFontDescription
    Enclosing class:
    PdfBoxFontResolver

    public static class PdfBoxFontResolver.FontDescription
    extends Object
    implements com.openhtmltopdf.outputdevice.helper.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      FontDescription​(org.apache.pdfbox.pdmodel.font.PDFont font, com.openhtmltopdf.css.constants.IdentValue style, int weight)
      Create a font description from one of the PDF built-in fonts.
      FontDescription​(org.apache.pdfbox.pdmodel.PDDocument doc, com.openhtmltopdf.extend.FSSupplier<InputStream> supplier, int weight, com.openhtmltopdf.css.constants.IdentValue style, String family, boolean isFromFontFace, boolean isSubset, com.openhtmltopdf.extend.FSCacheEx<String,​com.openhtmltopdf.extend.FSCacheValue> metricsCache)
      Create a font description from an input stream supplier.
      FontDescription​(org.apache.pdfbox.pdmodel.PDDocument doc, com.openhtmltopdf.extend.FSSupplier<org.apache.pdfbox.pdmodel.font.PDFont> fontSupplier, com.openhtmltopdf.css.constants.IdentValue style, int weight, String family, boolean isFromFontFace, boolean isSubset, com.openhtmltopdf.extend.FSCacheEx<String,​com.openhtmltopdf.extend.FSCacheValue> metricsCache)
      Creates a font description from a PDFont supplier.
    • Constructor Detail

      • FontDescription

        public FontDescription​(org.apache.pdfbox.pdmodel.font.PDFont font,
                               com.openhtmltopdf.css.constants.IdentValue style,
                               int weight)
        Create a font description from one of the PDF built-in fonts.
      • FontDescription

        public FontDescription​(org.apache.pdfbox.pdmodel.PDDocument doc,
                               com.openhtmltopdf.extend.FSSupplier<InputStream> supplier,
                               int weight,
                               com.openhtmltopdf.css.constants.IdentValue style,
                               String family,
                               boolean isFromFontFace,
                               boolean isSubset,
                               com.openhtmltopdf.extend.FSCacheEx<String,​com.openhtmltopdf.extend.FSCacheValue> metricsCache)
        Create a font description from an input stream supplier. The input stream will only be accessed if getFont() or getFontMetrics() (and the font metrics were not available from cache) are called.
      • FontDescription

        public FontDescription​(org.apache.pdfbox.pdmodel.PDDocument doc,
                               com.openhtmltopdf.extend.FSSupplier<org.apache.pdfbox.pdmodel.font.PDFont> fontSupplier,
                               com.openhtmltopdf.css.constants.IdentValue style,
                               int weight,
                               String family,
                               boolean isFromFontFace,
                               boolean isSubset,
                               com.openhtmltopdf.extend.FSCacheEx<String,​com.openhtmltopdf.extend.FSCacheValue> metricsCache)
        Creates a font description from a PDFont supplier. The supplier will only be called upon if getFont() or getFontMetrics() (and the font metrics were not available from cache) are called.
    • Method Detail

      • getFamily

        public String getFamily()
      • realizeFont

        public boolean realizeFont()
      • isFontAvailable

        public boolean isFontAvailable()
        Returns whether the font is available yet.
        See Also:
        getFont()
      • 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:
        getWeight in interface com.openhtmltopdf.outputdevice.helper.MinimalFontDescription
      • getStyle

        public com.openhtmltopdf.css.constants.IdentValue getStyle()
        Specified by:
        getStyle in interface com.openhtmltopdf.outputdevice.helper.MinimalFontDescription
      • isFromFontFace

        public boolean isFromFontFace()
      • isMetricsAvailable

        public boolean isMetricsAvailable()
        If the metrics are available yet.
        See Also:
        getFontMetrics()
      • getFontMetrics

        public PdfBoxRawPDFontMetrics 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:
        isMetricsAvailable()