Class PreloadFont

java.lang.Object
com.helger.pdflayout.spec.PreloadFont
All Implemented Interfaces:
com.helger.commons.id.IHasID<String>, Serializable

@NotThreadSafe public final class PreloadFont extends Object implements com.helger.commons.id.IHasID<String>, Serializable
Represents an abstract font that is potentially not yet loaded and can be used in multiple documents.
Note: PDFont is not Serializable.
Author:
Philip Helger
See Also:
  • Field Details

    • REGULAR

      public static final PreloadFont REGULAR
      PDF built-in font Helvetica regular
    • REGULAR_BOLD

      public static final PreloadFont REGULAR_BOLD
      PDF built-in font Helvetica bold
    • REGULAR_ITALIC

      public static final PreloadFont REGULAR_ITALIC
      PDF built-in font Helvetica italic
    • REGULAR_BOLD_ITALIC

      public static final PreloadFont REGULAR_BOLD_ITALIC
      PDF built-in font Helvetica bold and italic
    • MONOSPACE

      public static final PreloadFont MONOSPACE
      PDF built-in font Courier regular
    • MONOSPACE_BOLD

      public static final PreloadFont MONOSPACE_BOLD
      PDF built-in font Courier bold
    • MONOSPACE_ITALIC

      public static final PreloadFont MONOSPACE_ITALIC
      PDF built-in font Courier italic
    • MONOSPACE_BOLD_ITALIC

      public static final PreloadFont MONOSPACE_BOLD_ITALIC
      PDF built-in font Courier bold and italic
    • TIMES

      public static final PreloadFont TIMES
      PDF built-in font Times Roman regular
    • TIMES_BOLD

      public static final PreloadFont TIMES_BOLD
      PDF built-in font Times Roman bold
    • TIMES_ITALIC

      public static final PreloadFont TIMES_ITALIC
      PDF built-in font Times Roman italic
    • TIMES_BOLD_ITALIC

      public static final PreloadFont TIMES_BOLD_ITALIC
      PDF built-in font Times Roman bold italic
    • SYMBOL

      public static final PreloadFont SYMBOL
      PDF built-in font Symbol
    • ZAPF_DINGBATS

      public static final PreloadFont ZAPF_DINGBATS
      PDF built-in font Zapf Dingbats
  • Method Details

    • getID

      @Nonnull @Nonempty public String getID()
      Specified by:
      getID in interface com.helger.commons.id.IHasID<String>
    • loadPDFont

      @Nonnull public org.apache.pdfbox.pdmodel.font.PDFont loadPDFont(@Nonnull org.apache.pdfbox.pdmodel.PDDocument aDoc) throws IOException
      Load the PDFont associated to this preload font. This class uses no caching!
      Parameters:
      aDoc - The PDDocument to which the font should be attached to. May not be null.
      Returns:
      The loaded font.
      Throws:
      IOException - In case loading the external file fails
    • getFallbackCodePoint

      public int getFallbackCodePoint()
      Returns:
      The fallback code point to be used if a character is not contained in the font. Defaults to '?'.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createNonEmbedding

      @Nonnull public static PreloadFont createNonEmbedding(@Nonnull com.helger.font.api.IFontResource aFontRes)
      Create a new PreloadFont from an existing IFontResource where the subset cannot be embedded into the resulting PDF.
      Parameters:
      aFontRes - The font resource to include. May not be null.
      Returns:
      Never null.
      Throws:
      IllegalArgumentException - If the font could not be loaded.
    • createEmbedding

      @Nonnull public static PreloadFont createEmbedding(@Nonnull com.helger.font.api.IFontResource aFontRes)
      Create a new PreloadFont from an existing IFontResource where the subset can be embedded into the resulting PDF.
      Parameters:
      aFontRes - The font resource to include. May not be null.
      Returns:
      Never null.
      Throws:
      IllegalArgumentException - If the font could not be loaded.
    • getAllStandard14Fonts

      @Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsOrderedMap<String,org.apache.pdfbox.pdmodel.font.PDType1Font> getAllStandard14Fonts()
    • getAllStandard14PreloadFonts

      @Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsOrderedMap<String,PreloadFont> getAllStandard14PreloadFonts()