def test_win_ascent_and_win_descent_equal_bbox(self): """Check Win Ascent and Win Descent equal yMax, yMin of bbox MS recommends OS/2's win Ascent and win Descent must be the ymax and ymin of the bbox""" family_ymax_ymin = [] for font in self.fonts: ymin, ymax = shortest_tallest_glyphs(font) family_ymax_ymin.append(ymin) family_ymax_ymin.append(ymax) ymax = max(family_ymax_ymin) ymin = min(family_ymax_ymin) for font in self.fonts: for master in font.masters: win_ascent = master.customParameters['winAscent'] win_descent = master.customParameters['winDescent'] self.assertEqual( int(win_ascent), ymax, ("%s master's winAscent %s is not equal to yMax %s") % ( master.name, win_ascent, ymax) ) # ymin is abs because win descent is a positive integer self.assertEqual( int(win_descent), abs(ymin), ("%s master's winDescent %s is not equal to yMin %s") % ( master.name, win_descent, abs(ymin)) )
def set_win_asc_win_desc_to_bbox(font): masters = font.masters ymin, ymax = shortest_tallest_glyphs(font) for master in masters: master.customParameters['winDescent'] = abs(ymin) master.customParameters['winAscent'] = ymax