Package org.apache.fontbox.cmap
Class CMap
java.lang.Object
org.apache.fontbox.cmap.CMap
This class represents a CMap file.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidaddCharMapping(byte[] codes, String unicode) This will add a character code to Unicode character sequence mapping.(package private) voidaddCIDMapping(int code, int cid) This will add a CID mapping.(package private) voidaddCIDRange(char from, char to, int cid) This will add a CID Range.(package private) voidaddCodespaceRange(CodespaceRange range) This will add a codespace range.private intgetCodeFromArray(byte[] data, int offset, int length) Convert the given part of a byte array to an integer.byte[]getCodesFromUnicode(String unicode) Get the code bytes for an unicode string.getName()Returns the name of the CMap.Returns the ordering of the CIDSystemInfo.Returns the registry of the CIDSystemInfo.intReturns the mapping for the space character.intReturns the supplement of the CIDSystemInfo.intgetType()Returns the type of the CMap.Returns the version of the CMap.intgetWMode()Returns the WMode of a CMap.booleanThis will tell if this cmap has any CID mappings.booleanThis will tell if this cmap has any Unicode mappings.intreadCode(InputStream in) Reads a character code from a string in the content stream.voidSets the name of the CMap.voidsetOrdering(String newOrdering) Sets the ordering of the CIDSystemInfo.voidsetRegistry(String newRegistry) Sets the registry of the CIDSystemInfo.voidsetSupplement(int newSupplement) Sets the supplement of the CIDSystemInfo.voidsetType(int type) Sets the type of the CMap.voidsetVersion(String version) Sets the version of the CMap.voidsetWMode(int newWMode) Sets the WMode of a CMap.inttoCID(int code) Returns the CID for the given character code.(package private) static inttoInt(byte[] data, int dataLen) Returns an int for the given byte arraytoString()toUnicode(int code) Returns the sequence of Unicode characters for the given character code.(package private) voidImplementation of the usecmap operator.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
wmode
private int wmode -
cmapName
-
cmapVersion
-
cmapType
private int cmapType -
registry
-
ordering
-
supplement
private int supplement -
minCodeLength
private int minCodeLength -
maxCodeLength
private int maxCodeLength -
codespaceRanges
-
charToUnicode
-
unicodeToByteCodes
-
codeToCid
-
codeToCidRanges
-
SPACE
- See Also:
-
spaceMapping
private int spaceMapping
-
-
Constructor Details
-
CMap
CMap()Creates a new instance of CMap.
-
-
Method Details
-
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
Returns the sequence of Unicode characters for the given character code.- Parameters:
code- character code- Returns:
- Unicode characters (may be more than one, e.g "fi" ligature)
-
readCode
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
-
toInt
static int toInt(byte[] data, int dataLen) Returns an int for the given byte array -
toCID
public int toCID(int code) Returns the CID for the given character code.- Parameters:
code- character code- Returns:
- CID
-
getCodeFromArray
private int getCodeFromArray(byte[] data, int offset, int length) Convert the given part of a byte array to an integer.- Parameters:
data- the byte arrayoffset- The offset into the byte array.length- The length of the data we are getting.- Returns:
- the resulting integer
-
addCharMapping
This will add a character code to Unicode character sequence mapping.- Parameters:
codes- The character codes to map from.unicode- The Unicode characters to map to.
-
getCodesFromUnicode
Get the code bytes for an unicode string.- Parameters:
unicode- The unicode string.- Returns:
- the code bytes or null if there is none.
-
addCIDMapping
void addCIDMapping(int code, int cid) This will add a CID mapping.- Parameters:
code- character codecid- CID
-
addCIDRange
void addCIDRange(char from, char to, int cid) This will add a CID Range.- Parameters:
from- starting character of the CID range.to- ending character of the CID range.cid- the cid to be started with.
-
addCodespaceRange
This will add a codespace range.- Parameters:
range- A single codespace range.
-
useCmap
Implementation of the usecmap operator. This will copy all of the mappings from one cmap to another.- Parameters:
cmap- The cmap to load mappings from.
-
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
Returns the name of the CMap.- Returns:
- the CMap name.
-
setName
Sets the name of the CMap.- Parameters:
name- the CMap name.
-
getVersion
Returns the version of the CMap.- Returns:
- the CMap version.
-
setVersion
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
Returns the registry of the CIDSystemInfo.- Returns:
- the registry.
-
setRegistry
Sets the registry of the CIDSystemInfo.- Parameters:
newRegistry- the registry.
-
getOrdering
Returns the ordering of the CIDSystemInfo.- Returns:
- the ordering.
-
setOrdering
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
-