Class PdfSimpleFontFontProgram>

Direct Known Subclasses:
PdfTrueTypeFont, PdfType1Font, PdfType3Font

public abstract class PdfSimpleFontFontProgram> extends PdfFont
  • Field Details

    • fontEncoding

      protected FontEncoding fontEncoding
    • forceWidthsOutput

      protected boolean forceWidthsOutput
      Forces the output of the width array. Only matters for the 14 built-in fonts.
    • usedGlyphs

      protected byte[] usedGlyphs
      The array used with single byte encodings.
    • toUnicode

      protected CMapToUnicode toUnicode
      Currently only exists for the fonts that are parsed from the document. In the future, we might provide possibility to add custom mappings after a font has been created from a font file.
  • Constructor Details

    • PdfSimpleFont

      protected PdfSimpleFont (PdfDictionary fontDictionary)
    • PdfSimpleFont

      protected PdfSimpleFont()
  • Method Details

    • 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:
    • 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
    • getFontEncoding

      public FontEncoding getFontEncoding()
      Get the font encoding.
      Returns:
      the FontEncoding
    • getToUnicode

      public CMapToUnicode getToUnicode()
      Get the mapping of character codes to unicode values based on /ToUnicode entry of font dictionary.
      Returns:
      the CMapToUnicode built based on /ToUnicode, or null if /ToUnicode is not available
    • 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
    • decode

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

      public GlyphLine decodeIntoGlyphLine (PdfString content)
      Decodes sequence of character codes (e.g. from content stream) into a GlyphLine
      Specified by:
      decodeIntoGlyphLine in class PdfFont
      Parameters:
      content - 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
    • isForceWidthsOutput

      public boolean isForceWidthsOutput()
      Gets the state of the property.
      Returns:
      value of property forceWidthsOutput
    • setForceWidthsOutput

      public void setForceWidthsOutput (boolean forceWidthsOutput)
      Set to true to force the generation of the widths array.
      Parameters:
      forceWidthsOutput - true to force the generation of the widths array
    • flushFontData

      protected void flushFontData (String fontName, PdfName subtype)
    • isBuiltInFont

      protected boolean isBuiltInFont()
      Indicates that the font is built in, i.e. it is one of the 14 Standard fonts
      Returns:
      true in case the font is a Standard font and false otherwise
    • getFontDescriptor

      protected PdfDictionary getFontDescriptor (String fontName)
      Generates the font descriptor for this font or null if it is one of the 14 built in fonts.
      Specified by:
      getFontDescriptor in class PdfFont
      Returns:
      the PdfDictionary containing the font descriptor or null.
    • buildWidthsArray

      protected PdfArray buildWidthsArray (int firstChar, int lastChar)
    • addFontStream

      protected abstract void addFontStream (PdfDictionary fontDescriptor)
    • setFontProgram

      protected void setFontProgram (T fontProgram)