def font_priority(font):
 style_normal = (font[u'font-style'] == u'normal')
 width_normal = (font[u'font-stretch'] == u'normal')
 weight_normal = (font[u'font-weight'] == u'normal')
 num_normal = sum(filter(None, (style_normal, width_normal, weight_normal)))
 subfamily_name = (font[u'wws_subfamily_name'] or font[u'preferred_subfamily_name'] or font[u'subfamily_name'])
 if ((num_normal == 3) and (subfamily_name == u'Regular')):
  return 0
 if (num_normal == 3):
  return 1
 if (subfamily_name == u'Regular'):
  return 2
 return (3 + (3 - num_normal))

def font_priority ( font ) : style_normal = ( font [ u'font-style' ] == u'normal' ) width_normal = ( font [ u'font-stretch' ] == u'normal' ) weight_normal = ( font [ u'font-weight' ] == u'normal' ) num_normal = sum ( filter ( None , ( style_normal , width_normal , weight_normal ) ) ) subfamily_name = ( font [ u'wws_subfamily_name' ] or font [ u'preferred_subfamily_name' ] or font [ u'subfamily_name' ] ) if ( ( num_normal == 3 ) and ( subfamily_name == u'Regular' ) ) : return 0 if ( num_normal == 3 ) : return 1 if ( subfamily_name == u'Regular' ) : return 2 return ( 3 + ( 3 - num_normal ) )
try to ensure that the "regular" face is the first font for a given family .