extractor
extractor
$ pip install ufo-extractor
import extractor import defcon ufo = defcon.Font() extractor.extractUFO("/path/to/MyFont.ttf", ufo) ufo.save("/path/to/MyFont.ufo")
getBestCmap
class table__c_m_a_p(DefaultTable.DefaultTable): def getcmap(self, platformID, platEncID): for subtable in self.tables: if (subtable.platformID == platformID and subtable.platEncID == platEncID): return subtable return None # not found ここ=> def getBestCmap(self, cmapPreferences=((3, 10), (0, 6), (0, 4), (3, 1), (0, 3), (0, 2), (0, 1), (0, 0))): """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. """ for platformID, platEncID in cmapPreferences: cmapSubtable = self.getcmap(platformID, platEncID) if cmapSubtable is not None: return cmapSubtable.cmap return None # None of the requested cmap subtables were found