Class TrueTypeEmbedder

java.lang.Object
org.sejda.sambox.pdmodel.font.TrueTypeEmbedder
All Implemented Interfaces:
Subsetter
Direct Known Subclasses:
PDCIDFontType2Embedder, PDTrueTypeFontEmbedder

abstract class TrueTypeEmbedder extends Object implements Subsetter
Common functionality for embedding TrueType fonts.
  • Field Details

    • ITALIC

      private static final int ITALIC
      See Also:
    • OBLIQUE

      private static final int OBLIQUE
      See Also:
    • ttf

      protected org.apache.fontbox.ttf.TrueTypeFont ttf
    • fontDescriptor

      protected PDFontDescriptor fontDescriptor
    • cmapLookup

      protected final org.apache.fontbox.ttf.CmapLookup cmapLookup
    • subsetCodePoints

      private final Set<Integer> subsetCodePoints
    • embedSubset

      private final boolean embedSubset
  • Constructor Details

    • TrueTypeEmbedder

      TrueTypeEmbedder(COSDictionary dict, org.apache.fontbox.ttf.TrueTypeFont ttf, boolean embedSubset) throws IOException
      Creates a new TrueType font for embedding.
      Throws:
      IOException
  • Method Details

    • buildFontFile2

      public void buildFontFile2(InputStream ttfStream) throws IOException
      Throws:
      IOException
    • createFontDescriptor

      private PDFontDescriptor createFontDescriptor(org.apache.fontbox.ttf.TrueTypeFont ttf) throws IOException
      Creates a new font descriptor dictionary for the given TTF.
      Throws:
      IOException
    • getTrueTypeFont

      @Deprecated public org.apache.fontbox.ttf.TrueTypeFont getTrueTypeFont()
      Deprecated.
      Returns the FontBox font.
    • getFontDescriptor

      public PDFontDescriptor getFontDescriptor()
      Returns the font descriptor.
    • addToSubset

      public void addToSubset(int codePoint)
      Description copied from interface: Subsetter
      Adds the given Unicode code point to this subset.
      Specified by:
      addToSubset in interface Subsetter
      Parameters:
      codePoint - Unicode code point
    • subset

      public void subset() throws IOException
      Description copied from interface: Subsetter
      Subset this font now.
      Specified by:
      subset in interface Subsetter
      Throws:
      IOException - if the font could not be read
    • needsSubset

      public boolean needsSubset()
      Returns:
      true if the font needs to be subset.
    • buildSubset

      protected abstract void buildSubset(InputStream ttfSubset, String tag, Map<Integer,Integer> gidToCid) throws IOException
      Throws:
      IOException