#NEWLINE# def find_kerning_diffs( self ) : #NEWLINE# #INDENT# 'Report differences in kerning rules.' #NEWLINE# ( classes_a , classes_b ) = ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# rx = re . compile ( '(@[\\w\\d_.]+) = \\[([\\s\\w\\d_.]+)\\];' ) #NEWLINE# self . _parse_kerning_classes ( rx , self . text_a , classes_a ) #NEWLINE# self . _parse_kerning_classes ( rx , self . text_b , classes_b ) #NEWLINE# unmatched = defaultdict ( list ) #NEWLINE# mismatched = defaultdict ( list ) #NEWLINE# rx = re . compile ( 'pos ([\\w\\d@_.]+) ([\\w\\d@_.]+) (-?\\d+);' ) #NEWLINE# self . _parse_kerning ( rx , '-' , self . text_a , classes_a , unmatched ) #NEWLINE# self . _parse_kerning ( rx , '+' , self . text_b , classes_b , unmatched ) #NEWLINE# self . _organize_kerning_diffs ( unmatched , mismatched ) #NEWLINE# unmatched = [ ( k , v ) for ( k , v ) in unmatched . iteritems ( ) if v ] #NEWLINE# res = [ ( '%d differences in kerning pairs' % len ( unmatched ) ) ] #NEWLINE# unmatched . sort ( self . _compare_keys ) #NEWLINE# for ( ( sign , left , right ) , vals ) in unmatched [ : self . out_lines ] : #NEWLINE# #INDENT# res . append ( ( '%s pos %s %s %s' % ( sign , left , right , vals ) ) ) #NEWLINE# #UNINDENT# res . append ( '' ) #NEWLINE# mismatched = [ ( k , v ) for ( k , v ) in mismatched . iteritems ( ) if any ( v ) ] #NEWLINE# res . append ( ( '%d differences in kerning values' % len ( mismatched ) ) ) #NEWLINE# mismatched . sort ( self . _compare_kerning_values ) #NEWLINE# for ( ( left , right ) , ( vals1 , vals2 ) ) in mismatched [ : self . out_lines ] : #NEWLINE# #INDENT# if ( sum ( ( abs ( ( v1 - v2 ) ) for ( v1 , v2 ) in zip ( vals1 , vals2 ) ) ) > self . err ) : #NEWLINE# #INDENT# res . append ( ( 'pos %s %s: %s vs %s' % ( left , right , vals1 , vals2 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# res . append ( '' ) #NEWLINE# return '\n' . join ( res )