のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

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

github.com