コード例 #1
0
def explicitGlyph( font, char, encoding=None ):
    """Return glyphName or None if there is not explicit glyph for char"""
    cmap = font['cmap']
    if encoding is None:
        encoding = describe.guessEncoding( font )
    table = cmap.getcmap( *encoding )
    glyfName = table.cmap.get( ord(char))
    return glyfName
コード例 #2
0
ファイル: _toolsfont.py プロジェクト: MaxwellEdison/PyMine
    def _generalMetadata( self ):
        """Load general meta-data for this font (called via withFont)

        Guess the appropriate encoding, query line height,
        and character height.
        """
        try:
            self.encoding = describe.guessEncoding( self.font, self.encoding )
            self.lineHeight = glyphquery.lineHeight( self.font )
            self.charHeight = glyphquery.charHeight( self.font )
        except Exception:
            log.error( """Unable to load TrueType font from %r""", self.filename)
            raise
コード例 #3
0
    def _generalMetadata( self ):
        """Load general meta-data for this font (called via withFont)

        Guess the appropriate encoding, query line height,
        and character height.
        """
        try:
            self.encoding = describe.guessEncoding( self.font, self.encoding )
            self.lineHeight = glyphquery.lineHeight( self.font )
            self.charHeight = glyphquery.charHeight( self.font )
        except Exception:
            log.error( """Unable to load TrueType font from %r""", self.filename)
            raise
コード例 #4
0
ファイル: glyphquery.py プロジェクト: RoniuOniu/WMZF_2020
def glyphName(font, char, encoding=None, warnOnFailure=1):
    """Retrieve the glyph name for the given character

    XXX
        Not sure what the effect of the Unicode mapping
        will be given the use of ord...
    """
    glyfName = explicitGlyph(font, char, encoding)
    if glyfName is None:
        encoding = describe.guessEncoding(font)  #KH
        cmap = font['cmap']  #KH
        table = cmap.getcmap(*encoding)  #KH
        glyfName = table.cmap.get(-1)
        if glyfName is None:
            glyfName = font['glyf'].glyphOrder[0]
            if text_log and warnOnFailure:
                text_log.warn(
                    """Unable to find glyph name for %r, in %r using first glyph in table (%r)""",
                    char, describe.shortName(font), glyfName)
    return glyfName
コード例 #5
0
ファイル: glyphquery.py プロジェクト: Guillon88/stdm
def glyphName( font, char, encoding=None, warnOnFailure=1 ):
    """Retrieve the glyph name for the given character

    XXX
        Not sure what the effect of the Unicode mapping
        will be given the use of ord...
    """
    glyfName = explicitGlyph( font, char, encoding )
    if glyfName is None:
        encoding = describe.guessEncoding( font )       #KH
        cmap = font['cmap']                             #KH
        table = cmap.getcmap( *encoding )               #KH
        glyfName = table.cmap.get( -1)
        if glyfName is None:
            glyfName = font['glyf'].glyphOrder[0]
            if text_log and warnOnFailure:
                text_log.warn(
                    """Unable to find glyph name for %r, in %r using first glyph in table (%r)""",
                    char,
                    describe.shortName(font),
                    glyfName
                )
    return glyfName