Top Description Inners Fields Constructors Methods
org.apache.fontbox.ttf

public Class CmapSubtable

extends Object
implements CmapLookup
Class Inheritance
All Implemented Interfaces
org.apache.fontbox.ttf.CmapLookup
Imports
java.io.IOException, java.util.ArrayList, .Arrays, .Collections, .HashMap, .HashSet, .List, .Map, .Set, org.apache.commons.logging.Log, .LogFactory

A "cmap" subtable.
Author
Ben Litchfield

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
CmapSubtable.SubHeader

Class used to manage CMap - Format 2.

Field Summary

Modifier and TypeField and Description
private Map<Integer, Integer>
private int[]
private final Map<Integer, List<Integer>>
private static final long
private static final Log
private int
private int
private long
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
private int
getCharCode(int gid)

public List<Integer>

Returns:

a list with all character codes the given gid maps to
getCharCodes
(int
glyph id
gid
)

Implements org.apache.fontbox.ttf.CmapLookup.getCharCodes.

Returns all possible character codes for the given gid, or null if there is none.

public int

Returns:

glyphId the corresponding glyph id for the given character code
getGlyphId
(int
the given character code to be mapped
characterCode
)

Implements org.apache.fontbox.ttf.CmapLookup.getGlyphId.

Returns the GlyphId linked with the given character code.

public int

Returns:

Returns the platformEncodingId.
getPlatformEncodingId
()

public int

Returns:

Returns the platformId.
getPlatformId
()

pack-priv void
initData(TTFDataStream
The stream to read the data from.
data
)

This will read the required data from the stream.

pack-priv void
initSubtable(CmapTable
the CMAP this encoding belongs to.
cmap
,
int
number of glyphs.
numGlyphs
,
TTFDataStream
The stream to read the data from.
data
)

This will read the required data from the stream.

private int[]
newGlyphIdToCharacterCode(int size)

Workaround for the fact that glyphIdToCharacterCode doesn't distinguish between missing character codes and code 0.

pack-priv void
processSubtype0(TTFDataStream
the data stream of the to be parsed ttf font
data
)

Initialize the CMapEntry when it is a subtype 0.

pack-priv void
processSubtype10(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 10 subtable.

pack-priv void
processSubtype12(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 12 subtable.

pack-priv void
processSubtype13(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 13 subtable.

pack-priv void
processSubtype14(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 14 subtable.

pack-priv void
processSubtype2(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Read a format 2 subtable.

pack-priv void
processSubtype4(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 4 subtable.

pack-priv void
processSubtype6(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 6 subtable.

pack-priv void
processSubtype8(TTFDataStream
the data stream of the to be parsed ttf font
data
,
int
number of glyphs to be read
numGlyphs
)

Reads a format 8 subtable.

public void
setPlatformEncodingId(int
The platformEncodingId to set.
platformEncodingIdValue
)

public void
setPlatformId(int
The platformId to set.
platformIdValue
)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

characterCodeToGlyphIdback to summary
private Map<Integer, Integer> characterCodeToGlyphId
glyphIdToCharacterCodeback to summary
private int[] glyphIdToCharacterCode
glyphIdToCharacterCodeMultipleback to summary
private final Map<Integer, List<Integer>> glyphIdToCharacterCodeMultiple
LEAD_OFFSETback to summary
private static final long LEAD_OFFSET
LOGback to summary
private static final Log LOG
platformEncodingIdback to summary
private int platformEncodingId
platformIdback to summary
private int platformId
subTableOffsetback to summary
private long subTableOffset
SURROGATE_OFFSETback to summary
private static final long SURROGATE_OFFSET

Constructor Detail

CmapSubtableback to summary
public CmapSubtable()

Method Detail

buildGlyphIdToCharacterCodeLookupback to summary
private void buildGlyphIdToCharacterCodeLookup(int maxGlyphId)
getCharCodeback to summary
private int getCharCode(int gid)
getCharCodesback to summary
public List<Integer> getCharCodes(int gid)

Implements org.apache.fontbox.ttf.CmapLookup.getCharCodes.

Returns all possible character codes for the given gid, or null if there is none.

Parameters
gid:int

glyph id

Returns:List<Integer>

a list with all character codes the given gid maps to

Annotations
@Override
getGlyphIdback to summary
public int getGlyphId(int characterCode)

Implements org.apache.fontbox.ttf.CmapLookup.getGlyphId.

Returns the GlyphId linked with the given character code.

Parameters
characterCode:int

the given character code to be mapped

Returns:int

glyphId the corresponding glyph id for the given character code

Annotations
@Override
getPlatformEncodingIdback to summary
public int getPlatformEncodingId()
Returns:int

Returns the platformEncodingId.

getPlatformIdback to summary
public int getPlatformId()
Returns:int

Returns the platformId.

initDataback to summary
pack-priv void initData(TTFDataStream data) throws IOException

This will read the required data from the stream.

Parameters
data:TTFDataStream

The stream to read the data from.

Exceptions
IOException:
If there is an error reading the data.
initSubtableback to summary
pack-priv void initSubtable(CmapTable cmap, int numGlyphs, TTFDataStream data) throws IOException

This will read the required data from the stream.

Parameters
cmap:CmapTable

the CMAP this encoding belongs to.

numGlyphs:int

number of glyphs.

data:TTFDataStream

The stream to read the data from.

Exceptions
IOException:
If there is an error reading the data.
newGlyphIdToCharacterCodeback to summary
private int[] newGlyphIdToCharacterCode(int size)

Workaround for the fact that glyphIdToCharacterCode doesn't distinguish between missing character codes and code 0.

processSubtype0back to summary
pack-priv void processSubtype0(TTFDataStream data) throws IOException

Initialize the CMapEntry when it is a subtype 0.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype10back to summary
pack-priv void processSubtype10(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 10 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype12back to summary
pack-priv void processSubtype12(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 12 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype13back to summary
pack-priv void processSubtype13(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 13 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype14back to summary
pack-priv void processSubtype14(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 14 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype2back to summary
pack-priv void processSubtype2(TTFDataStream data, int numGlyphs) throws IOException

Read a format 2 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype4back to summary
pack-priv void processSubtype4(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 4 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype6back to summary
pack-priv void processSubtype6(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 6 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
processSubtype8back to summary
pack-priv void processSubtype8(TTFDataStream data, int numGlyphs) throws IOException

Reads a format 8 subtable.

Parameters
data:TTFDataStream

the data stream of the to be parsed ttf font

numGlyphs:int

number of glyphs to be read

Exceptions
IOException:
If there is an error parsing the true type font.
setPlatformEncodingIdback to summary
public void setPlatformEncodingId(int platformEncodingIdValue)
Parameters
platformEncodingIdValue:int

The platformEncodingId to set.

setPlatformIdback to summary
public void setPlatformId(int platformIdValue)
Parameters
platformIdValue:int

The platformId to set.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.apache.fontbox.ttf back to summary

private Class CmapSubtable.SubHeader

extends Object
Class Inheritance

Class used to manage CMap - Format 2.

Field Summary

Modifier and TypeField and Description
private final int
private final int
private final short
idDelta

used to compute the GlyphIndex : P = glyphIndexArray.SubArray[pos] GlyphIndex = P + idDelta % 65536.

private final int
idRangeOffset

Number of bytes to skip to reach the firstCode in the glyphIndexArray.

Constructor Summary

AccessConstructor and Description
private
SubHeader(int firstCodeValue, int entryCountValue, short idDeltaValue, int idRangeOffsetValue)

Method Summary

Modifier and TypeMethod and Description
private int

Returns:

the entryCount
getEntryCount
()

private int

Returns:

the firstCode
getFirstCode
()

private short

Returns:

the idDelta
getIdDelta
()

private int

Returns:

the idRangeOffset
getIdRangeOffset
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entryCountback to summary
private final int entryCount
firstCodeback to summary
private final int firstCode
idDeltaback to summary
private final short idDelta

used to compute the GlyphIndex : P = glyphIndexArray.SubArray[pos] GlyphIndex = P + idDelta % 65536.

idRangeOffsetback to summary
private final int idRangeOffset

Number of bytes to skip to reach the firstCode in the glyphIndexArray.

Constructor Detail

SubHeaderback to summary
private SubHeader(int firstCodeValue, int entryCountValue, short idDeltaValue, int idRangeOffsetValue)

Method Detail

getEntryCountback to summary
private int getEntryCount()
Returns:int

the entryCount

getFirstCodeback to summary
private int getFirstCode()
Returns:int

the firstCode

getIdDeltaback to summary
private short getIdDelta()
Returns:short

the idDelta

getIdRangeOffsetback to summary
private int getIdRangeOffset()
Returns:int

the idRangeOffset