Skip to content

Commit

Permalink
Check area of arabic letter high hamza (U+0621)
Browse files Browse the repository at this point in the history
to be roughly the same as arabic letter hamza (U+0675).

com.google.fonts/check/arabic_high_hamza
On the Universal Profile.
(issue #4315)
  • Loading branch information
felipesanches committed Nov 17, 2023
1 parent 67fdda6 commit 5c515ad
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ A more detailed list of changes is available in the corresponding milestones for

## Upcoming release: 0.10.4 (2023-Nov-??)
### Changes to existing checks
#### On the Universal Profile
- **[com.google.fonts/check/arabic_high_hamza]:** Check area of arabic letter high hamza (U+0621) to be roughly the same as arabic letter hamza (U+0675) (issue #4315)

#### On the Google Fonts Profile
- **[com.google.fonts/check/metadata/escaped_strings]:** Accept escaped quotes. They're fine. This check is really meant to detect things like "Juli\303\241n" instead of "Julián". (issue #4331)
- **[com.google.fonts/check/glyphsets/shape_languages]:** Use tables to make the check results more readable. (issue #4326)
Expand Down
34 changes: 31 additions & 3 deletions Lib/fontbakery/profiles/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,9 +841,19 @@ def com_google_fonts_check_arabic_spacing_symbols(ttFont):
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
from fontTools.pens.areaPen import AreaPen

ARABIC_LETTER_HAMZA = 0x0621
ARABIC_LETTER_HIGH_HAMZA = 0x0675

glyph_set = ttFont.getGlyphSet()
if ARABIC_LETTER_HAMZA not in glyph_set or ARABIC_LETTER_HAMZA not in glyph_set:
yield SKIP, Message(
"glyphs-missing",
"This check will only run on fonts that have both glyphs U+0621 and U+0675",
)
return

passed = True
font = babelfont.load(ttFont.reader.file.name)

Expand All @@ -857,9 +867,27 @@ def com_google_fonts_check_arabic_high_hamza(ttFont):
"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)

# 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)
area_pen = AreaPen(glyph_set)

glyph_set[ARABIC_LETTER_HAMZA].draw(area_pen)
hamza_area = area_pen.value

area_pen.value = 0
glyph_set[ARABIC_LETTER_HIGH_HAMZA].draw(area_pen)
high_hamza_area = area_pen.value

if abs((high_hamza_area - hamza_area) / hamza_area) > 0.1:
passed = False
yield FAIL, Message(
"glyph-area",
"The arabic letter high hamza (U+0675) should have roughly"
" the same size the arabic letter hamza (U+0621),"
" but a different glyph outline area was detected.",
)

if passed:
yield PASS, "Looks good!"
Expand Down

0 comments on commit 5c515ad

Please sign in to comment.