Skip to content

Commit

Permalink
New check: allah_ligature
Browse files Browse the repository at this point in the history
Added to the Universal profile.
allah_ligature: "Check correct formation of allah ligature in presence of explicit tashkeel."

(issue #4727)
  • Loading branch information
yanone authored and felipesanches committed Sep 6, 2024
1 parent c0a53a7 commit 612e6ba
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ Below are the noteworthy changes from each release.
A more detailed list of changes is available in the corresponding milestones for each release in the Github issue tracker (https://github.com/googlefonts/fontbakery/milestones?state=closed).

## Upcoming release: 0.13.0 (2024-Sep-??)
### New checks
#### Added to the Universal profile
- **[allah_ligature]:** Check correct formation of allah ligature in presence of explicit tashkeel. (issue #4727)

### Changes to existing checks
#### On the Universal profile
- **[name/family_and_style_max_length"]:** Use nameID 16 (Typographic family name) to determine name length if it exists. (PR #4811)
Expand Down Expand Up @@ -135,6 +139,7 @@ A more detailed list of changes is available in the corresponding milestones for
- **[com.google.fonts/check/case_mapping]:** Only check letters. As per David Corbett's suggestion, we now check for unicode category = "L*". (issue #4733)
- **EXPERIMENTAL - [com.google.fonts/check/tabular_kerning]:** Revised check another time to remove even further false positives (issue #4640)

### Changes to existing checks
#### On the Outline profile
- **[com.google.fonts/check/outline_direction]:** fixed an error where the outermost path was not correctly detected. (issue #4719)
- **[com.google.fonts/check/outline_direction]:** fix wording in rational, it stated the opposite of what the check does. (issue #4743)
Expand Down
53 changes: 52 additions & 1 deletion Lib/fontbakery/checks/arabic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from fontbakery.prelude import FAIL, SKIP, Message, check
from fontbakery.prelude import PASS, FAIL, SKIP, Message, check
from fontbakery.utils import get_glyph_name


Expand Down Expand Up @@ -123,3 +123,54 @@ def check_arabic_high_hamza(ttFont):
" the same size the arabic letter hamza (U+0621),"
" but a different glyph outline area was detected.",
)


@check(
id="allah_ligature",
rationale="""
Ensure that the allah ligature, if present in a font, is correctly
formed in the presence of manually placed tashkeel marks.
""",
proposal="https://github.com/fonttools/fontbakery/issues/4727",
)
def com_google_fonts_check_allah_ligature(ttFont):
"""Ensure correct formation of allah ligature in the presence of tashkeel marks."""

cmap = ttFont["cmap"].getBestCmap()
allah_unicode = 0xFDF2

if allah_unicode not in cmap.keys():
yield SKIP, "Font does not contain the allah ligature."
return

allah_glyphname = cmap[allah_unicode]

from vharfbuzz import Vharfbuzz

vharfbuzz = Vharfbuzz(ttFont.reader.file.name)

def shape(text):
buf = vharfbuzz.shape(text)
return vharfbuzz.serialize_buf(buf, glyphsonly=True)

# Even though the font contains the allah ligature, it's generally not used
if shape("الله") != allah_glyphname:
yield PASS, (
"The allah ligature is present but not substituted for "
"plain 'allah' input string."
)
return

# The allah ligature is used, so we need to check if it's correctly formed
plain_allah = shape("الله")
allah_with_tashkeel = shape("اللَّهُ")

if plain_allah in allah_with_tashkeel.split("|"):
yield FAIL, Message(
"wrong-allah-with-tashkeel",
"The basic allah ligature (U+FDF2) is used in the presence of tashkeel marks. ",
)

# TODO:
# add check that checks whether the damma is placed on the heh, not the lam
# see IBM Plex Sans Arabic v1.004
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/adobefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"opentype/varfont/family_axis_ranges",
"opentype/varfont/ital_range",
"opentype/vendor_id",
"allah_ligature",
"alt_caron",
"arabic_high_hamza",
"arabic_spacing_symbols",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/fontbureau.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"pending_review": [
"opentype/weight_class_fvar",
"opentype/slant_direction",
"allah_ligature",
"cjk_not_enough_glyphs",
"cmap/format_12",
"color_cpal_brightness",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/fontwerk.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"fontdata_namecheck",
],
"pending_review": [
"allah_ligature",
"typographic_family_name",
"vtt_volt_data", # very similar to vttclean, may be a good idea to merge them.
#
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"opentype/cff_ascii_strings",
"opentype/slant_direction",
"opentype/weight_class_fvar",
"allah_ligature",
"cjk_not_enough_glyphs",
"cmap/format_12",
"color_cpal_brightness",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/typenetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"googlefonts/negative_advance_width",
"googlefonts/STAT/axis_order",
#
"allah_ligature",
"caps_vertically_centered", # Disabled: issue #4274
"case_mapping",
"cmap/format_12",
Expand Down
1 change: 1 addition & 0 deletions Lib/fontbakery/profiles/universal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"ufo_unnecessary_fields",
],
"Universal Profile Checks": [
"allah_ligature",
"alt_caron",
"arabic_high_hamza",
"arabic_spacing_symbols",
Expand Down
Binary file added data/test/fustat/Fustat[wght].ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions tests/test_checks_arabic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from fontTools.ttLib import TTFont

from fontbakery.status import FAIL
from fontbakery.codetesting import (
assert_PASS,
assert_SKIP,
assert_results_contain,
CheckTester,
TEST_FILE,
)


def test_check_allah_ligature():
"""Ensure correct formation of allah ligature in the presence of tashkeel marks."""
check = CheckTester("allah_ligature")

# font has no allah ligature
ttFont = TTFont(TEST_FILE("ibmplexsans-vf/IBMPlexSansVar-Roman.ttf"))
assert_SKIP(check(ttFont))

# allah ligature is present but generally unused
ttFont = TTFont(TEST_FILE("fustat/Fustat[wght].ttf"))
assert_PASS(check(ttFont))

# classic mistake: tashkeel are placed on top of the allah ligature, colliding
ttFont = TTFont(TEST_FILE("ibmplexsansarabic_v1_004/IBMPlexSansArabic-Regular.ttf"))
assert_results_contain(check(ttFont), FAIL, "wrong-allah-with-tashkeel")

# ligature is present and generally used, and correctly formed with tashkeel
ttFont = TTFont(TEST_FILE("ibmplexsansarabic_v1_005/IBMPlexSansArabic-Regular.ttf"))
assert_PASS(check(ttFont))

0 comments on commit 612e6ba

Please sign in to comment.