org.apache.fontbox.cmap

## Class CMap

- java.lang.Object
- - org.apache.fontbox.cmap.CMap

    public class CMap
    extends Object

This class represents a CMap file.

Author:
  Ben Litchfield

### Method Summary

All Methods Instance Methods Concrete Methods
`byte[]` `getCodesFromUnicode(String unicode)` Get the code bytes for an unicode string.
`String` `getName()` Returns the name of the CMap.
`String` `getOrdering()` Returns the ordering of the CIDSystemInfo.
`String` `getRegistry()` Returns the registry of the CIDSystemInfo.
`int` `getSpaceMapping()` Returns the mapping for the space character.
`int` `getSupplement()` Returns the supplement of the CIDSystemInfo.
`int` `getType()` Returns the type of the CMap.
`String` `getVersion()` Returns the version of the CMap.
`int` `getWMode()` Returns the WMode of a CMap.
`boolean` `hasCIDMappings()` This will tell if this cmap has any CID mappings.
`boolean` `hasUnicodeMappings()` This will tell if this cmap has any Unicode mappings.
`int` `readCode(InputStream in)` Reads a character code from a string in the content stream.
`void` `setName(String name)` Sets the name of the CMap.
`void` `setOrdering(String newOrdering)` Sets the ordering of the CIDSystemInfo.
`void` `setRegistry(String newRegistry)` Sets the registry of the CIDSystemInfo.
`void` `setSupplement(int newSupplement)` Sets the supplement of the CIDSystemInfo.
`void` `setType(int type)` Sets the type of the CMap.
`void` `setVersion(String version)` Sets the version of the CMap.
`void` `setWMode(int newWMode)` Sets the WMode of a CMap.
`int` `toCID(byte[] code)` Returns the CID for the given character code.
`int` `toCID(int code)` Returns the CID for the given character code.
`int` `toCID(int code, int length)` Returns the CID for the given character code.
`String` `toString()`
`String` `toUnicode(byte[] code)` Returns the sequence of Unicode characters for the given character code.
`String` `toUnicode(int code)` Returns the sequence of Unicode characters for the given character code.
`String` `toUnicode(int code, int length)` Returns the sequence of Unicode characters for the given character code.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Method Detail

#### hasCIDMappings

    public boolean hasCIDMappings()

This will tell if this cmap has any CID mappings.

Returns:
  true If there are any CID mappings, false otherwise.

#### hasUnicodeMappings

    public boolean hasUnicodeMappings()

This will tell if this cmap has any Unicode mappings.

Returns:
  true If there are any Unicode mappings, false otherwise.

#### toUnicode

    public String toUnicode(int code)

Returns the sequence of Unicode characters for the given character code. This method exists for convenience. It may return false values as the origin byte length of the input value is unknown and the mapping for some input values aren't unique.
Example:
The two byte value 0x00, 0x65 maps to 0x20
An input value of 0x65 always returns 0x20 even if the value has an origin byte length of 1.

Parameters:
  `code` - character code
Returns:
  Unicode characters (may be more than one, e.g "fi" ligature)

#### toUnicode

    public String toUnicode(int code,
                            int length)

Returns the sequence of Unicode characters for the given character code.

Parameters:
  `code` - character code
  `length` - code length
Returns:
  Unicode characters (may be more than one, e.g "fi" ligature)

#### toUnicode

    public String toUnicode(byte[] code)

Returns the sequence of Unicode characters for the given character code.

Parameters:
  `code` - bytes of the character code
Returns:
  Unicode characters (may be more than one, e.g "fi" ligature)

#### readCode

    public int readCode(InputStream in)
                 throws IOException

Reads a character code from a string in the content stream.

See "CMap Mapping" and "Handling Undefined Characters" in PDF32000 for more details.

Parameters:
  `in` - string stream
Returns:
  character code
Throws:
  `IOException` - if there was an error reading the stream or CMap

#### toCID

    public int toCID(byte[] code)

Returns the CID for the given character code.

Parameters:
  `code` - character code as byte array
Returns:
  CID

#### toCID

    public int toCID(int code)

Returns the CID for the given character code. This method exists for convenience. It may return false values as the origin byte length of the input value is unknown and the mapping for some input values aren't unique.
Example:
The two byte value 0x00, 0x65 maps to 0x20
An input value of 0x65 always returns 0x20 even if the value has an origin byte length of 1.

Parameters:
  `code` - character code
Returns:
  CID

#### toCID

    public int toCID(int code,
                     int length)

Returns the CID for the given character code.

Parameters:
  `code` - character code
  `length` - the origin byte length of the code
Returns:
  CID

#### getCodesFromUnicode

    public byte[] getCodesFromUnicode(String unicode)

Get the code bytes for an unicode string.

Parameters:
  `unicode` - The unicode string.
Returns:
  the code bytes or null if there is none.

#### getWMode

    public int getWMode()

Returns the WMode of a CMap. 0 represents a horizontal and 1 represents a vertical orientation.

Returns:
  the wmode

#### setWMode

    public void setWMode(int newWMode)

Sets the WMode of a CMap.

Parameters:
  `newWMode` - the new WMode.

#### getName

    public String getName()

Returns the name of the CMap.

Returns:
  the CMap name.

#### setName

    public void setName(String name)

Sets the name of the CMap.

Parameters:
  `name` - the CMap name.

#### getVersion

    public String getVersion()

Returns the version of the CMap.

Returns:
  the CMap version.

#### setVersion

    public void setVersion(String version)

Sets the version of the CMap.

Parameters:
  `version` - the CMap version.

#### getType

    public int getType()

Returns the type of the CMap.

Returns:
  the CMap type.

#### setType

    public void setType(int type)

Sets the type of the CMap.

Parameters:
  `type` - the CMap type.

#### getRegistry

    public String getRegistry()

Returns the registry of the CIDSystemInfo.

Returns:
  the registry.

#### setRegistry

    public void setRegistry(String newRegistry)

Sets the registry of the CIDSystemInfo.

Parameters:
  `newRegistry` - the registry.

#### getOrdering

    public String getOrdering()

Returns the ordering of the CIDSystemInfo.

Returns:
  the ordering.

#### setOrdering

    public void setOrdering(String newOrdering)

Sets the ordering of the CIDSystemInfo.

Parameters:
  `newOrdering` - the ordering.

#### getSupplement

    public int getSupplement()

Returns the supplement of the CIDSystemInfo.

Returns:
  the supplement.

#### setSupplement

    public void setSupplement(int newSupplement)

Sets the supplement of the CIDSystemInfo.

Parameters:
  `newSupplement` - the supplement.

#### getSpaceMapping

    public int getSpaceMapping()

Returns the mapping for the space character.

Returns:
  the mapped code for the space character

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`