From f1b8a955cac6712623ff9704de8e0f29b1365756 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Fri, 20 Oct 2023 17:24:11 +0100 Subject: [PATCH] New check: Arabic letter high hamza isn't classified as a mark. Many fonts incorrectly treat ARABIC LETTER HIGH HAMZA (U+0675) as a variant of ARABIC HAMZA ABOVE (U+0654) and make it a combining mark of the same size. But U+0675 is a base letter and should be a variant of ARABIC LETTER HAMZA (U+0621) but raised slightly above baseline. Not doing so effectively makes the font useless for Jawi and possibly Kazakh as well. Added to the Universal Profile com.google.fonts/check/arabic_high_hamza (experimental) (issue #4290) --- CHANGELOG.md | 1 + Lib/fontbakery/profiles/universal.py | 48 +++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 284b71c56f..edf29faabf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ A more detailed list of changes is available in the corresponding milestones for ### New checks #### Added to the Universal Profile - **EXPERIMENTAL - [com.google.fonts/check/arabic_spacing_symbols]:** Check that Arabic spacing symbols U+FBB2–FBC1 aren't classified as marks. (issue #4295) + - **EXPERIMENTAL - [com.google.fonts/check/arabic_high_hamza]:** Check that glyph for U+0675 ARABIC LETTER HIGH HAMZA is not a mark. (issue #4290) ### Changes to existing checks #### On the Universal Profile diff --git a/Lib/fontbakery/profiles/universal.py b/Lib/fontbakery/profiles/universal.py index d76a649778..3d4993a4c3 100644 --- a/Lib/fontbakery/profiles/universal.py +++ b/Lib/fontbakery/profiles/universal.py @@ -71,6 +71,7 @@ "com.google.fonts/check/STAT_in_statics", "com.google.fonts/check/alt_caron", "com.google.fonts/check/arabic_spacing_symbols", + "com.google.fonts/check/arabic_high_hamza", ] ) @@ -777,7 +778,7 @@ def com_google_fonts_check_legacy_accents(ttFont): experimental="Since 2023/Oct/20", severity=4, ) -def com_google_fonts_check_spacing_symbols(ttFont): +def com_google_fonts_check_arabic_spacing_symbols(ttFont): """Check that Arabic spacing symbols U+FBB2–FBC1 aren't classified as marks.""" import babelfont @@ -819,6 +820,51 @@ def com_google_fonts_check_spacing_symbols(ttFont): yield PASS, "Looks good!" +@check( + id="com.google.fonts/check/arabic_high_hamza", + proposal=[ + "https://github.com/googlefonts/fontbakery/issues/4290", + ], + rationale=""" + Many fonts incorrectly treat ARABIC LETTER HIGH HAMZA (U+0675) as a variant of + ARABIC HAMZA ABOVE (U+0654) and make it a combining mark of the same size. + + But U+0675 is a base letter and should be a variant of ARABIC LETTER HAMZA + (U+0621) but raised slightly above baseline. + + Not doing so effectively makes the font useless for Jawi and + possibly Kazakh as well. + """, + experimental="Since 2023/Oct/20", + severity=4, +) +def com_google_fonts_check_arabic_high_hamza(ttFont): + """Check that glyph for U+0675 ARABIC LETTER HIGH HAMZA is not a mark.""" + import babelfont + + ARABIC_LETTER_HIGH_HAMZA = 0x0675 + + passed = True + font = babelfont.load(ttFont.reader.file.name) + + if "GDEF" in ttFont: + class_def = ttFont["GDEF"].table.GlyphClassDef.classDefs + for glyph in font.glyphs: + if ARABIC_LETTER_HIGH_HAMZA in set(glyph.codepoints): + if glyph.name in class_def and class_def[glyph.name] == 3: + passed = False + yield FAIL, Message( + "mark-in-gdef", + f'"{glyph.name}" is defined in GDEF as a mark (class 3).', + ) + # TODO: Should we also validate the bounding box of the glyph and compare + # it to U+0621 expecting them to have roughly the same size? + # (within a certain tolerance margin) + + if passed: + yield PASS, "Looks good!" + + @check( id="com.google.fonts/check/required_tables", conditions=["ttFont"],