Class Cmap
java.lang.Object
com.adobe.fontengine.font.opentype.Table
com.adobe.fontengine.font.opentype.Cmap
Gives access to a 'cmap' table.
Encoding forms support
A number of subtable formats are designed to combine the decoding of a character stream and the computation of the glyph ID. For example, format 8 is geared to support encoding forms with one or two 16 bits code units (such as UTF-16) and has a 64K bit array to indicate those code units which represent a code point on their own and those code units which are the first of a pair. The idea is that the details of the encoding form can be captured in the font.
Our point of view is that encoding forms are not the business of fonts, so we ignore those parts of those formats.
Version handling
'cmap' tables have only a minor version number. This implementation:
- fully supports version 0 tables
- interprets version x > 0 tables as version 0 tables
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceClass used to receive the list of recognized subtables in this cmap table.static final classstatic final classstatic final classEnum classes for the various platformIDs and encodingIDs.static final class -
Method Summary
Modifier and TypeMethodDescriptionintchar2glyph(int ch, int index) intcoolTypeUnicodeChar2glyph(int usv) Approximates CoolType's interpretation of cmaps.voidenumerateCmaps(Cmap.CmapSelector selector) Enumerate the cmaps contained in the cmap table.intgetCmapSubtableIndex(int platformId, int encodingId) intgetHighestMappedCode(int stOffset, boolean max2bytes) Get the character code that is the highest that is mapped by the cmap found at stOffset.intgetLowestMappedCode(int stOffset) Get the character code that is the lowest that is mapped by the cmap found at stOffset.intgetMapping(int stOffset, int charCode) Get the glyphID for charCode using the subtable at stOffset.intgetOffset(int subtableIndex) int[]glyph2char(int numGlyphs, int index) Get the inverted mapping from glyphs to characters for one subtable.booleanTell whether the font is symbolic.intprobe(int platformID, int encodingID) Return the offset of a give cmap subtable if present, -1 otherwise.voidvoidstreamForSWF(Map tables, int numGlyphs) voidsubsetAndStream(Subset subset, SubsetSimpleTrueType ttSubset, Map tables) In the SubsetSimpleTrueType case, the client will have provided a cmap and a set of codepoints to map against it.voidsubsetAndStreamForSWF(TreeSet codePoints, Subset subset, Map tables, boolean includeVariationCmap) intunicodeChar2glyph(int usv) Get the glyph mapped from a given character.
-
Method Details
-
probe
public int probe(int platformID, int encodingID) throws InvalidFontException, UnsupportedFontException Return the offset of a give cmap subtable if present, -1 otherwise. -
isSymbolic
Tell whether the font is symbolic. -
enumerateCmaps
public void enumerateCmaps(Cmap.CmapSelector selector) throws UnsupportedFontException, InvalidFontException Enumerate the cmaps contained in the cmap table. Call the selector's cmapFound method for each recognized platform id/encoding id combination.- Parameters:
selector-- Throws:
UnsupportedFontExceptionInvalidFontException
-
getCmapSubtableIndex
- Throws:
InvalidFontException
-
unicodeChar2glyph
Get the glyph mapped from a given character.- Parameters:
usv- the Unicode scalar value to look up- Returns:
- the gid of the glyph mapped from
usv, 0 if not mapped. Note that this is the true OpenType gid, even in the case of cid cff otf. It is NOT the cid. - Throws:
UnsupportedFontExceptionInvalidFontException
-
coolTypeUnicodeChar2glyph
Approximates CoolType's interpretation of cmaps. This approximation is fairly incomplete: for example, CoolType has some heuristics to interpret the cmaps of Win 3.1 ME fonts (which have an MS/Symbol cmap that follows some conventions and are marked with high order bits in OS/2.fsSelection). -
char2glyph
-
getLowestMappedCode
Get the character code that is the lowest that is mapped by the cmap found at stOffset. -
getHighestMappedCode
public int getHighestMappedCode(int stOffset, boolean max2bytes) throws UnsupportedFontException, InvalidFontException Get the character code that is the highest that is mapped by the cmap found at stOffset. If max2bytes is true, the highest code that is at most 2 bytes is returned. -
getMapping
public int getMapping(int stOffset, int charCode) throws UnsupportedFontException, InvalidFontException Get the glyphID for charCode using the subtable at stOffset.- Parameters:
stOffset- the offset (in the cmap table) of the subtable to usecharCode- the character code to map- Returns:
- the glyphID for
charCode - Throws:
UnsupportedFontExceptionInvalidFontException
-
getOffset
-
glyph2char
public int[] glyph2char(int numGlyphs, int index) throws UnsupportedFontException, InvalidFontException Get the inverted mapping from glyphs to characters for one subtable. The subtable, identified byindexmust be present.- Parameters:
numGlyphs- the number of glyphs in the fontindex- the index of the cmap to invert- Returns:
- array of
numGlyphsintegers, mapping glyphIDs to characters; if a glyphs is not mapped by the subtable, the value in this array is -1. - Throws:
UnsupportedFontExceptionInvalidFontException
-
subsetAndStream
public void subsetAndStream(Subset subset, SubsetSimpleTrueType ttSubset, Map tables) throws UnsupportedFontException, InvalidFontException In the SubsetSimpleTrueType case, the client will have provided a cmap and a set of codepoints to map against it. We will convert these to relate to the new subset GlyphIDs stored in the OTSubset. We don't bother to emit cmaps in any other case than the SubsetSimpleTrueType case. -
subsetAndStreamForSWF
public void subsetAndStreamForSWF(TreeSet codePoints, Subset subset, Map tables, boolean includeVariationCmap) throws UnsupportedFontException, InvalidFontException -
stream
-
streamForSWF
public void streamForSWF(Map tables, int numGlyphs) throws UnsupportedFontException, InvalidFontException
-