def test_check_find_empty_letters(): from fontbakery.profiles.adobefonts import \ com_adobe_fonts_check_find_empty_letters as check # this font has inked glyphs for all letters font_path = TEST_FILE('source-sans-pro/OTF/SourceSansPro-Regular.otf') test_font = TTFont(font_path) status, message = list(check(test_font))[-1] assert status == PASS # this font has empty glyphs for several letters font_path = TEST_FILE('familysans/FamilySans-Regular.ttf') test_font = TTFont(font_path) expected_message = "U+007A should be visible, but its glyph ('z') is empty." status, message = list(check(test_font))[-1] assert status == FAIL assert message == expected_message
def test_check_missing_whitespace(): """ Check that overridden test for nbsp yields WARN rather than FAIL. """ from fontbakery.profiles.adobefonts import \ com_google_fonts_check_whitespace_glyph_nbsp as check from fontbakery.profiles.shared_conditions import missing_whitespace_chars font_path = TEST_FILE('source-sans-pro/OTF/SourceSansPro-Regular.otf') test_font = TTFont(font_path) missing = missing_whitespace_chars(test_font) status, message = list(check(test_font, missing))[-1] assert status == PASS # remove U+00A0, status should be WARN (standard check would be FAIL) for subtable in test_font['cmap'].tables: subtable.cmap.pop(0x00A0, None) missing = missing_whitespace_chars(test_font) status, message = list(check(test_font, missing))[-1] assert status == WARN
def test_check_family_consistent_upm(): from fontbakery.profiles.adobefonts import ( com_adobe_fonts_check_family_consistent_upm as check) base_path = TEST_FILE("source-sans-pro/OTF") # these fonts have a consistent unitsPerEm of 1000: font_names = ['SourceSansPro-Regular.otf', 'SourceSansPro-Bold.otf', 'SourceSansPro-It.otf'] font_paths = [os.path.join(base_path, n) for n in font_names] test_fonts = [TTFont(x) for x in font_paths] # try fonts with consistent UPM (i.e. 1000) status, message = list(check(test_fonts))[-1] assert status == PASS # now try with one font with a different UPM (i.e. 2048) test_fonts[1]['head'].unitsPerEm = 2048 status, message = list(check(test_fonts))[-1] assert status == FAIL