cmap: Character to Glyph Index Mapping Table

class fontTools.ttLib.tables._c_m_a_p.table__c_m_a_p(tag=None)[source]
buildReversed()[source]

Returns a reverse cmap such as {‘one’:{0x31}, ‘A’:{0x41,0x391}}.

The values are sets of Unicode codepoints because some fonts map different codepoints to the same glyph. For example, U+0041 LATIN CAPITAL LETTER A and U+0391 GREEK CAPITAL LETTER ALPHA are sometimes the same glyph.

getBestCmap(cmapPreferences=((3, 10), (0, 6), (0, 4), (3, 1), (0, 3), (0, 2), (0, 1), (0, 0)))[source]

Return the ‘best’ unicode cmap dictionary available in the font, or None, if no unicode cmap subtable is available.

By default it will search for the following (platformID, platEncID) pairs:

(3, 10), (0, 6), (0, 4), (3, 1), (0, 3), (0, 2), (0, 1), (0, 0)

This can be customized via the cmapPreferences argument.

class fontTools.ttLib.tables._c_m_a_p.CmapSubtable(format)[source]
getEncoding(default=None)[source]

Returns the Python encoding name for this cmap subtable based on its platformID, platEncID, and language. If encoding for these values is not known, by default None is returned. That can be overriden by passing a value to the default argument.

Note that if you want to choose a “preferred” cmap subtable, most of the time self.isUnicode() is what you want as that one only returns true for the modern, commonly used, Unicode-compatible triplets, not the legacy ones.

static getSubtableClass(format)[source]

Return the subtable class for a format.

static newSubtable(format)[source]

Return a new instance of a subtable for format.