Package org.apache.fontbox.ttf
Class CmapSubtable
- java.lang.Object
-
- org.apache.fontbox.ttf.CmapSubtable
-
- All Implemented Interfaces:
CmapLookup
public class CmapSubtable extends java.lang.Object implements CmapLookup
A "cmap" subtable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCmapSubtable.SubHeaderClass used to manage CMap - Format 2.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,java.lang.Integer>characterCodeToGlyphIdprivate int[]glyphIdToCharacterCodeprivate java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>>glyphIdToCharacterCodeMultipleprivate static longLEAD_OFFSETprivate static org.apache.commons.logging.LogLOGprivate intplatformEncodingIdprivate intplatformIdprivate longsubTableOffsetprivate static longSURROGATE_OFFSET
-
Constructor Summary
Constructors Constructor Description CmapSubtable()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private voidbuildGlyphIdToCharacterCodeLookup(int maxGlyphId)java.lang.IntegergetCharacterCode(int gid)Deprecated.the mapping may be ambiguous, seegetCharCodes(int).private intgetCharCode(int gid)java.util.List<java.lang.Integer>getCharCodes(int gid)Returns all possible character codes for the given gid, or null if there is none.intgetGlyphId(int characterCode)Returns the GlyphId linked with the given character code.intgetPlatformEncodingId()intgetPlatformId()(package private) voidinitData(TTFDataStream data)This will read the required data from the stream.(package private) voidinitSubtable(CmapTable cmap, int numGlyphs, TTFDataStream 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.(package private) voidprocessSubtype0(TTFDataStream data)Initialize the CMapEntry when it is a subtype 0.(package private) voidprocessSubtype10(TTFDataStream data, int numGlyphs)Reads a format 10 subtable.(package private) voidprocessSubtype12(TTFDataStream data, int numGlyphs)Reads a format 12 subtable.(package private) voidprocessSubtype13(TTFDataStream data, int numGlyphs)Reads a format 13 subtable.(package private) voidprocessSubtype14(TTFDataStream data, int numGlyphs)Reads a format 14 subtable.(package private) voidprocessSubtype2(TTFDataStream data, int numGlyphs)Read a format 2 subtable.(package private) voidprocessSubtype4(TTFDataStream data, int numGlyphs)Reads a format 4 subtable.(package private) voidprocessSubtype6(TTFDataStream data, int numGlyphs)Reads a format 6 subtable.(package private) voidprocessSubtype8(TTFDataStream data, int numGlyphs)Reads a format 8 subtable.voidsetPlatformEncodingId(int platformEncodingIdValue)voidsetPlatformId(int platformIdValue)java.lang.StringtoString()
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
LEAD_OFFSET
private static final long LEAD_OFFSET
- See Also:
- Constant Field Values
-
SURROGATE_OFFSET
private static final long SURROGATE_OFFSET
- See Also:
- Constant Field Values
-
platformId
private int platformId
-
platformEncodingId
private int platformEncodingId
-
subTableOffset
private long subTableOffset
-
glyphIdToCharacterCode
private int[] glyphIdToCharacterCode
-
glyphIdToCharacterCodeMultiple
private final java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> glyphIdToCharacterCodeMultiple
-
characterCodeToGlyphId
private java.util.Map<java.lang.Integer,java.lang.Integer> characterCodeToGlyphId
-
-
Method Detail
-
initData
void initData(TTFDataStream data) throws java.io.IOException
This will read the required data from the stream.- Parameters:
data- The stream to read the data from.- Throws:
java.io.IOException- If there is an error reading the data.
-
initSubtable
void initSubtable(CmapTable cmap, int numGlyphs, TTFDataStream data) throws java.io.IOException
This will read the required data from the stream.- Parameters:
cmap- the CMAP this encoding belongs to.numGlyphs- number of glyphs.data- The stream to read the data from.- Throws:
java.io.IOException- If there is an error reading the data.
-
processSubtype8
void processSubtype8(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 8 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype10
void processSubtype10(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 10 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype12
void processSubtype12(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 12 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype13
void processSubtype13(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 13 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype14
void processSubtype14(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 14 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype6
void processSubtype6(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 6 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype4
void processSubtype4(TTFDataStream data, int numGlyphs) throws java.io.IOException
Reads a format 4 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
buildGlyphIdToCharacterCodeLookup
private void buildGlyphIdToCharacterCodeLookup(int maxGlyphId)
-
processSubtype2
void processSubtype2(TTFDataStream data, int numGlyphs) throws java.io.IOException
Read a format 2 subtable.- Parameters:
data- the data stream of the to be parsed ttf fontnumGlyphs- number of glyphs to be read- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
processSubtype0
void processSubtype0(TTFDataStream data) throws java.io.IOException
Initialize the CMapEntry when it is a subtype 0.- Parameters:
data- the data stream of the to be parsed ttf font- Throws:
java.io.IOException- If there is an error parsing the true type font.
-
newGlyphIdToCharacterCode
private int[] newGlyphIdToCharacterCode(int size)
Workaround for the fact that glyphIdToCharacterCode doesn't distinguish between missing character codes and code 0.
-
getPlatformEncodingId
public int getPlatformEncodingId()
- Returns:
- Returns the platformEncodingId.
-
setPlatformEncodingId
public void setPlatformEncodingId(int platformEncodingIdValue)
- Parameters:
platformEncodingIdValue- The platformEncodingId to set.
-
getPlatformId
public int getPlatformId()
- Returns:
- Returns the platformId.
-
setPlatformId
public void setPlatformId(int platformIdValue)
- Parameters:
platformIdValue- The platformId to set.
-
getGlyphId
public int getGlyphId(int characterCode)
Returns the GlyphId linked with the given character code.- Specified by:
getGlyphIdin interfaceCmapLookup- Parameters:
characterCode- the given character code to be mapped- Returns:
- glyphId the corresponding glyph id for the given character code
-
getCharacterCode
@Deprecated public java.lang.Integer getCharacterCode(int gid)
Deprecated.the mapping may be ambiguous, seegetCharCodes(int). The first mapped value is returned by default.Returns the character code for the given GID, or null if there is none.- Parameters:
gid- glyph id- Returns:
- character code
-
getCharCode
private int getCharCode(int gid)
-
getCharCodes
public java.util.List<java.lang.Integer> getCharCodes(int gid)
Returns all possible character codes for the given gid, or null if there is none.- Specified by:
getCharCodesin interfaceCmapLookup- Parameters:
gid- glyph id- Returns:
- a list with all character codes the given gid maps to
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-