Class Encoding

java.lang.Object
org.apache.pdfbox.pdmodel.font.encoding.Encoding
All Implemented Interfaces:
COSObjectable
Direct Known Subclasses:
BuiltInEncoding, DictionaryEncoding, MacExpertEncoding, MacRomanEncoding, StandardEncoding, SymbolEncoding, Type1Encoding, WinAnsiEncoding, ZapfDingbatsEncoding

public abstract class Encoding extends Object implements COSObjectable
A PostScript encoding vector, maps character codes to glyph names.
Author:
Ben Litchfield
  • Field Details

    • CHAR_CODE

      protected static final int CHAR_CODE
      See Also:
    • CHAR_NAME

      protected static final int CHAR_NAME
      See Also:
    • codeToName

      protected final Map<Integer,String> codeToName
      code-to-name map. Derived classes should not modify the map after class construction.
    • inverted

      protected final Map<String,Integer> inverted
      name-to-code map. Derived classes should not modify the map after class construction.
  • Constructor Details

    • Encoding

      public Encoding()
  • Method Details

    • getInstance

      public static Encoding getInstance(COSName name)
      This will get an encoding by name. May return null.
      Parameters:
      name - The name of the encoding to get.
      Returns:
      The encoding that matches the name.
    • getCodeToNameMap

      public Map<Integer,String> getCodeToNameMap()
      Returns an unmodifiable view of the code -> name mapping.
      Returns:
      the code -> name map
    • getNameToCodeMap

      public Map<String,Integer> getNameToCodeMap()
      Returns an unmodifiable view of the name -> code mapping. More than one name may map to the same code.
      Returns:
      the name -> code map
    • add

      protected void add(int code, String name)
      This will add a character encoding. An already existing mapping is preserved when creating the reverse mapping. Should only be used during construction of the class.
      Parameters:
      code - character code
      name - PostScript glyph name
      See Also:
    • overwrite

      protected void overwrite(int code, String name)
      This will add a character encoding. An already existing mapping is overwritten when creating the reverse mapping.
      Parameters:
      code - character code
      name - PostScript glyph name
      See Also:
    • contains

      public boolean contains(String name)
      Determines if the encoding has a mapping for the given name value.
      Parameters:
      name - PostScript glyph name
    • contains

      public boolean contains(int code)
      Determines if the encoding has a mapping for the given code value.
      Parameters:
      code - character code
    • getName

      public String getName(int code)
      This will take a character code and get the name from the code.
      Parameters:
      code - character code
      Returns:
      PostScript glyph name
    • getEncodingName

      public abstract String getEncodingName()
      Returns the name of this encoding.