def test_us_weight(self): "Tests the usWeight of the fonts to be correct." "" for font in self.fonts: weight = noto_fonts.parse_weight(font_data.font_name(font)) expected_numeric_weight = noto_fonts.WEIGHTS[weight] self.assertEqual(font['OS/2'].usWeightClass, expected_numeric_weight)
def getGlyphSets(self, glyph_sets, weights): """Filter glyph sets to only those with certain weights.""" glyph_set_map = { noto_fonts.parse_weight(font_file): glyph_set for font_file, glyph_set in zip(*glyph_sets) if all(style not in font_file for style in self.exclude)} return [glyph_set_map[w] for w in weights]
def test_us_weight(self): "Tests the usWeight of the fonts to be correct.""" for font in self.fonts: weight = noto_fonts.parse_weight(font_data.font_name(font)) expected_numeric_weight = noto_fonts.WEIGHTS[weight] self.assertEqual( font['OS/2'].usWeightClass, expected_numeric_weight)
def test_us_weight(self): "Tests the usWeight of the fonts to be correct." "" for font in self.fonts: weight = noto_fonts.parse_weight(font_data.font_name(font)) expected_numeric_weight = noto_fonts.WEIGHTS[weight] # hack for windows GDI expected_numeric_weight = max(expected_numeric_weight, 250) self.assertEqual(font["OS/2"].usWeightClass, expected_numeric_weight)
def apply_temporary_fixes(font): """Apply some temporary fixes.""" # Fix usWeight: font_name = font_data.font_name(font) weight = noto_fonts.parse_weight(font_name) weight_number = noto_fonts.WEIGHTS[weight] font['OS/2'].usWeightClass = weight_number # Set ascent, descent, and lineGap values to Android K values hhea = font['hhea'] hhea.ascent = 1900 hhea.descent = -500 hhea.lineGap = 0
def apply_temporary_fixes(font): """Apply some temporary fixes.""" # Fix usWeight: font_name = font_data.font_name(font) weight = noto_fonts.parse_weight(font_name) weight_number = noto_fonts.WEIGHTS[weight] font['OS/2'].usWeightClass = weight_number # Set ascent, descent, and lineGap values to Android K values hhea = font['hhea'] hhea.ascent = 1900 hhea.descent = -500 hhea.lineGap = 0 # Copyright message font_data.set_name_record( font, 0, 'Copyright 2011 Google Inc. All Rights Reserved.')
def apply_temporary_fixes(font, is_for_cros=False): """Apply some temporary fixes.""" # Fix usWeight: font_name = font_data.font_name(font) weight = noto_fonts.parse_weight(font_name) weight_number = noto_fonts.WEIGHTS[weight] # Chrome OS wants Thin to have usWeightClass=100 if is_for_cros and weight == 'Thin': weight_number = 100 font['OS/2'].usWeightClass = weight_number # Set bold bits for Black (macStyle bit 0, fsSelection bit 5) name_records = font_data.get_name_records(font) family_name = name_records[1] if family_name.endswith('Black'): font['head'].macStyle |= (1 << 0) font['OS/2'].fsSelection |= (1 << 5) font['OS/2'].fsSelection &= ~(1 << 6)
def apply_temporary_fixes(font): """Apply some temporary fixes.""" # Fix usWeight: font_name = font_data.font_name(font) weight = noto_fonts.parse_weight(font_name) weight_number = noto_fonts.WEIGHTS[weight] font['OS/2'].usWeightClass = weight_number # Set ascent, descent, and lineGap values to Android K values hhea = font['hhea'] hhea.ascent = 1900 hhea.descent = -500 hhea.lineGap = 0 # Set bold bits for Black (macStyle bit 0, fsSelection bit 5) name_records = font_data.get_name_records(font) family_name = name_records[1] if family_name.endswith('Black'): font['head'].macStyle |= (1 << 0) font['OS/2'].fsSelection |= (1 << 5) font['OS/2'].fsSelection &= ~(1 << 6)