Added getBestCmap() convenience method to the cmap table, to return the best available unicode cmap in the font
This commit is contained in:
parent
045287aa25
commit
9dcddb853a
@ -38,6 +38,18 @@ class table__c_m_a_p(DefaultTable.DefaultTable):
|
|||||||
return subtable
|
return subtable
|
||||||
return None # not found
|
return None # not found
|
||||||
|
|
||||||
|
def getBestCmap(self, cmapPreferences=((3, 10), (3, 1), (0, 3))):
|
||||||
|
"""Return the 'best' unicode cmap dictionary available in the font.
|
||||||
|
By default it will search for the following (platformID, platEncID) pairs:
|
||||||
|
(3, 10), (3, 1), (0, 3)
|
||||||
|
But this can be customized via the cmapPreferences argument.
|
||||||
|
"""
|
||||||
|
for platformID, platEncID in cmapPreferences:
|
||||||
|
cmapSubtable = self.getcmap(platformID, platEncID)
|
||||||
|
if cmapSubtable is not None:
|
||||||
|
return cmapSubtable.cmap
|
||||||
|
raise ValueError("None of the requested cmap subtables were found")
|
||||||
|
|
||||||
def buildReversed(self):
|
def buildReversed(self):
|
||||||
"""Returns a reverse cmap such as {'one':{0x31}, 'A':{0x41,0x391}}.
|
"""Returns a reverse cmap such as {'one':{0x31}, 'A':{0x41,0x391}}.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user