Class Cmap
- java.lang.Object
-
- com.adobe.fontengine.font.opentype.Table
-
- com.adobe.fontengine.font.opentype.Cmap
-
public final class Cmap extends Table
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 Classes Modifier and Type Class Description static interfaceCmap.CmapSelectorClass used to receive the list of recognized subtables in this cmap table.static classCmap.MacEncodingIDstatic classCmap.MS_EncodingIDstatic classCmap.PlatformIDEnum classes for the various platformIDs and encodingIDs.static classCmap.UnicodeEncodingID
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intchar2glyph(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.booleanisSymbolic()Tell whether the font is symbolic.intprobe(int platformID, int encodingID)Return the offset of a give cmap subtable if present, -1 otherwise.voidstream(java.util.Map tables)voidstreamForSWF(java.util.Map tables, int numGlyphs)voidsubsetAndStream(Subset subset, SubsetSimpleTrueType ttSubset, java.util.Map tables)In the SubsetSimpleTrueType case, the client will have provided a cmap and a set of codepoints to map against it.voidsubsetAndStreamForSWF(java.util.TreeSet codePoints, Subset subset, java.util.Map tables, boolean includeVariationCmap)intunicodeChar2glyph(int usv)Get the glyph mapped from a given character.
-
-
-
Method Detail
-
probe
public int probe(int platformID, int encodingID) throws InvalidFontException, UnsupportedFontExceptionReturn the offset of a give cmap subtable if present, -1 otherwise.
-
isSymbolic
public boolean isSymbolic() throws UnsupportedFontException, InvalidFontExceptionTell 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
public int getCmapSubtableIndex(int platformId, int encodingId) throws InvalidFontException- Throws:
InvalidFontException
-
unicodeChar2glyph
public int unicodeChar2glyph(int usv) throws UnsupportedFontException, InvalidFontExceptionGet 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
public int coolTypeUnicodeChar2glyph(int usv) throws UnsupportedFontException, InvalidFontExceptionApproximates 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
public int char2glyph(int ch, int index) throws UnsupportedFontException, InvalidFontException
-
getLowestMappedCode
public int getLowestMappedCode(int stOffset) throws UnsupportedFontException, InvalidFontExceptionGet 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, InvalidFontExceptionGet 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, InvalidFontExceptionGet 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
public int getOffset(int subtableIndex) throws InvalidFontException, UnsupportedFontException
-
glyph2char
public int[] glyph2char(int numGlyphs, int index) throws UnsupportedFontException, InvalidFontExceptionGet 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, java.util.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(java.util.TreeSet codePoints, Subset subset, java.util.Map tables, boolean includeVariationCmap) throws UnsupportedFontException, InvalidFontException
-
stream
public void stream(java.util.Map tables)
-
streamForSWF
public void streamForSWF(java.util.Map tables, int numGlyphs) throws UnsupportedFontException, InvalidFontException
-
-