<s> class GlyphRecord ( object ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> def __init__ ( self , glyphName ) : <EOL> self . glyph = None <EOL> self . glyphName = glyphName <EOL> self . xPlacement = <NUM_LIT:0> <EOL> self . yPlacement = <NUM_LIT:0> <EOL> self . xAdvance = <NUM_LIT:0> <EOL> self . yAdvance = <NUM_LIT:0> <EOL> self . advanceWidth = <NUM_LIT:0> <EOL> self . advanceHeight = <NUM_LIT:0> <EOL> self . alternates = [ ] <EOL> self . _alternatesReference = None <EOL> self . _ligatureComponents = [ ] <EOL> self . _substitutionHistory = [ ] <EOL> def __repr__ ( self ) : <EOL> name = str ( self . glyphName ) <EOL> xP = str ( self . xPlacement ) <EOL> yP = str ( self . yPlacement ) <EOL> xA = str ( self . xAdvance ) <EOL> yA = str ( self . yAdvance ) <EOL> s = "<STR_LIT>" % ( name , xP , yP , xA , yA ) <EOL> return s <EOL> def __add__ ( self , valueRecord ) : <EOL> self . xPlacement += valueRecord . XPlacement <EOL> self . yPlacement += valueRecord . YPlacement <EOL> self . xAdvance += valueRecord . XAdvance <EOL> self . yAdvance += valueRecord . YAdvance <EOL> return self <EOL> def _get_ligatureComponents ( self ) : <EOL> return list ( self . _ligatureComponents ) <EOL> def _set_ligatureComponents ( self , components ) : <EOL> self . _ligatureComponents = list ( components ) <EOL> ligatureComponents = property ( _get_ligatureComponents , _set_ligatureComponents ) <EOL> def saveState ( self , glyphName ) : <EOL> if isinstance ( glyphName , list ) : <EOL> glyphName = list ( glyphName ) <EOL> self . _substitutionHistory . append ( glyphName ) <EOL> def getSide1GlyphNameWithUnicodeValue ( self , reversedCMAP ) : <EOL> if self . glyphName in reversedCMAP : <EOL> return self . glyphName <EOL> for glyphName in reversed ( self . _substitutionHistory ) : <EOL> if isinstance ( glyphName , list ) : <EOL> glyphName = glyphName [ <NUM_LIT:0> ] <EOL> if glyphName in reversedCMAP : <EOL> return glyphName <EOL> return None <EOL> def getSide2GlyphNameWithUnicodeValue ( self , reversedCMAP ) : <EOL> if self . glyphName in reversedCMAP : <EOL> return self . glyphName <EOL> for glyphName in reversed ( self . _substitutionHistory ) : <EOL> if isinstance ( glyphName , list ) : <EOL> glyphName = glyphName [ - <NUM_LIT:1> ] <EOL> if glyphName in reversedCMAP : <EOL> return glyphName <EOL> return None <EOL> def glyphNamesToGlyphRecords ( glyphList ) : <EOL> """<STR_LIT>""" <EOL> return [ GlyphRecord ( glyphName ) for glyphName in glyphList ] <EOL> def glyphRecordsToTuples ( glyphRecords ) : <EOL> """<STR_LIT>""" <EOL> tuples = [ ] <EOL> for record in glyphRecords : <EOL> xP = record . xPlacement <EOL> yP = record . yPlacement <EOL> xA = record . xAdvance <EOL> yA = record . yAdvance <EOL> gN = record . glyphName <EOL> tuples . append ( ( gN , xP , yP , xA , yA ) ) <EOL> return tuples <EOL> def glyphRecordsToGlyphNames ( glyphRecords ) : <EOL> """<STR_LIT>""" <EOL> return [ record . glyphName for record in glyphRecords ] <EOL> def _testMath ( ) : <EOL> """<STR_LIT>""" <EOL> def _testUnicodeGuessing ( ) : <EOL> """<STR_LIT>""" <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> import doctest <EOL> doctest . testmod ( ) </s>
