Class PdfType0Font


public class PdfType0Font extends PdfFont
  • Field Details

    • CID_FONT_TYPE_0

      protected static final int CID_FONT_TYPE_0
      CIDFont Type0 (Type1 outlines).
      See Also:
    • CID_FONT_TYPE_2

      protected static final int CID_FONT_TYPE_2
      CIDFont Type2 (TrueType outlines).
      See Also:
    • vertical

      protected boolean vertical
    • cmapEncoding

      protected CMapEncoding cmapEncoding
    • usedGlyphs

      protected Set<Integer> usedGlyphs
    • cidFontType

      protected int cidFontType
    • specificUnicodeDifferences

      protected char[] specificUnicodeDifferences
  • Method Details

    • getUniMapFromOrdering

      public static String getUniMapFromOrdering (String ordering, boolean horizontal)
      Get Unicode mapping name from ordering.
      Parameters:
      ordering - the text ordering to base to unicode mapping on
      horizontal - identifies whether the encoding is horizontal or vertical
      Returns:
      Unicode mapping name
    • getUniMapFromOrdering

      @Deprecated public static String getUniMapFromOrdering (String ordering)
      Deprecated.
      Replaced by getUniMapFromOrdering(String, boolean) for proper handling of IDENTITY_V encoding.
      Get Unicode mapping name from ordering.
      Parameters:
      ordering - the text ordering to base to unicode mapping on
      Returns:
      Unicode mapping name
    • getGlyph

      public Glyph getGlyph (int unicode)
      Description copied from class: PdfFont
      Get glyph by unicode
      Specified by:
      getGlyph in class PdfFont
      Parameters:
      unicode - a unicode code point
      Returns:
      Glyph if it exists or .NOTDEF if supported, otherwise null.
    • containsGlyph

      public boolean containsGlyph (int unicode)
      Description copied from class: PdfFont
      Check whether font contains glyph with specified unicode.
      Overrides:
      containsGlyph in class PdfFont
      Parameters:
      unicode - a unicode code point
      Returns:
      true if font contains glyph, represented with the unicode code point, otherwise false.
    • convertToBytes

      public byte[] convertToBytes (String text)
      Description copied from class: PdfFont
      Converts the text into bytes to be placed in the document. The conversion is done according to the font and the encoding and the characters used are stored.
      Specified by:
      convertToBytes in class PdfFont
      Parameters:
      text - the text to convert
      Returns:
      the conversion
    • convertToBytes

      public byte[] convertToBytes (GlyphLine glyphLine)
      Specified by:
      convertToBytes in class PdfFont
    • convertToBytes

      public byte[] convertToBytes (Glyph glyph)
      Specified by:
      convertToBytes in class PdfFont
    • writeText

      public void writeText (GlyphLine text, int from, int to, PdfOutputStream stream)
      Specified by:
      writeText in class PdfFont
    • writeText

      public void writeText (String text, PdfOutputStream stream)
      Specified by:
      writeText in class PdfFont
    • createGlyphLine

      public GlyphLine createGlyphLine (String content)
      Specified by:
      createGlyphLine in class PdfFont
    • appendGlyphs

      public int appendGlyphs (String text, int from, int to, List<Glyph> glyphs)
      Description copied from class: PdfFont
      Append all supported glyphs and return number of processed chars. Composite font supports surrogate pairs.
      Specified by:
      appendGlyphs in class PdfFont
      Parameters:
      text - String to convert to glyphs.
      from - from index of the text.
      to - to index of the text.
      glyphs - array for a new glyphs, shall not be null.
      Returns:
      number of processed chars from text.
    • appendAnyGlyph

      public int appendAnyGlyph (String text, int from, List<Glyph> glyphs)
      Description copied from class: PdfFont
      Append any single glyph, even notdef. Returns number of processed chars: 2 in case surrogate pair, otherwise 1.
      Specified by:
      appendAnyGlyph in class PdfFont
      Parameters:
      text - String to convert to glyphs.
      from - from index of the text.
      glyphs - array for a new glyph, shall not be null.
      Returns:
      number of processed chars: 2 in case surrogate pair, otherwise 1
    • decode

      public String decode (PdfString content)
      Specified by:
      decode in class PdfFont
    • decodeIntoGlyphLine

      public GlyphLine decodeIntoGlyphLine (PdfString characterCodes)
      Decodes sequence of character codes (e.g. from content stream) into a GlyphLine
      Specified by:
      decodeIntoGlyphLine in class PdfFont
      Parameters:
      characterCodes - the string which is interpreted as a sequence of character codes. Note, that PdfString acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding
      Returns:
      the GlyphLine containing the glyphs encoded by the passed string
    • appendDecodedCodesToGlyphsList

      public boolean appendDecodedCodesToGlyphsList (List<Glyph> list, PdfString characterCodes)
      Decodes sequence of character codes (e.g. from content stream) to sequence of glyphs and appends them to the passed list.
      Overrides:
      appendDecodedCodesToGlyphsList in class PdfFont
      Parameters:
      list - the list to the end of which decoded glyphs are to be added
      characterCodes - the string which is interpreted as a sequence of character codes. Note, that PdfString acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding
      Returns:
      true if all codes where successfully decoded, false otherwise
    • getContentWidth

      public float getContentWidth (PdfString content)
      Specified by:
      getContentWidth in class PdfFont
    • isBuiltWith

      public boolean isBuiltWith (String fontProgram, String encoding)
      Description copied from class: PdfFont
      Checks whether the PdfFont was built with corresponding fontProgram and encoding or CMAP. Default value is false unless overridden.
      Overrides:
      isBuiltWith in class PdfFont
      Parameters:
      fontProgram - a font name or path to a font program
      encoding - an encoding or CMAP
      Returns:
      true, if the PdfFont was built with the fontProgram and encoding. Otherwise false.
      See Also:
    • flush

      public void flush()
      Description copied from class: PdfFont
      To manually flush a PdfObject behind this wrapper, you have to ensure that this object is added to the document, i.e. it has an indirect reference. Basically this means that before flushing you need to explicitly call PdfObjectWrapper.makeIndirect(PdfDocument). For example: wrapperInstance.makeIndirect(document).flush(); Note that not every wrapper require this, only those that have such warning in documentation.
      Overrides:
      flush in class PdfFont
    • getCmap

      public CMapEncoding getCmap()
      Gets CMAP associated with the Pdf Font.
      Returns:
      CMAP
      See Also:
    • getFontDescriptor

      protected PdfDictionary getFontDescriptor (String fontName)
      Specified by:
      getFontDescriptor in class PdfFont
    • getCidFont

      protected PdfDictionary getCidFont (PdfDictionary fontDescriptor, String fontName, boolean isType2)
      Generates the CIDFontType2 dictionary.
      Parameters:
      fontDescriptor - the font descriptor dictionary
      fontName - a name of the font
      isType2 - true, if the font is CIDFontType2 (TrueType glyphs), otherwise false, i.e. CIDFontType0 (Type1/CFF glyphs)
      Returns:
      fully initialized CIDFont
    • getToUnicode

      public PdfStream getToUnicode()
      Creates a ToUnicode CMap to allow copy and paste from Acrobat.
      Returns:
      the stream representing this CMap or null