Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update com.google.fonts/check/soft_dotted #4208

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ A more detailed list of changes is available in the corresponding milestones for
- ...


## 0.9.0a2 (2023-Aug-04)
### Changes to existing checks
#### On the Shaping profile
- **[com.google.fonts/check/soft_dotted]:** Added affected languages to output & downgraded to WARN. (issue #4085)


## 0.9.0a1 (2023-Aug-02)
### Note-worthy code changes
- This is the first version in which we're using the Black auto-formatter on the entire code-base. (Discussions #3397)
Expand Down
62 changes: 55 additions & 7 deletions Lib/fontbakery/profiles/shaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,20 +699,68 @@ def com_google_fonts_check_soft_dotted(ttFont):

message = ""
if fail_unchanged_strings:
fail_unchanged_strings = " ".join(fail_unchanged_strings)
message += (
"The dot of soft dotted characters used in orthographies must disappear in"
f" the following strings: {' '.join(fail_unchanged_strings)}"
f"The dot of soft dotted characters used in orthographies"
f" _must_ disappear in the following strings: {fail_unchanged_strings}"
)
if warn_unchanged_strings:
warn_unchanged_strings = " ".join(warn_unchanged_strings)
if message:
message += "\n\n"
message += (
"The dot of soft dotted characters should disappear in other cases,"
f" for example: {' '.join(warn_unchanged_strings)}"
f"The dot of soft dotted characters _should_ disappear in"
f" other cases, for example: {warn_unchanged_strings}"
)
if fail_unchanged_strings:
yield FAIL, Message("soft-dotted", message)
elif warn_unchanged_strings:

# Calculate font's affected languages for additional information
if fail_unchanged_strings or warn_unchanged_strings:
from shaperglot.checker import Checker
from shaperglot.languages import Languages, gflangs

languages = Languages()

# Find all affected languages
ortho_soft_dotted_langs = set()
for c in ortho_soft_dotted_strings:
for lang in gflangs:
if (
c in gflangs[lang].exemplar_chars.base
or c in gflangs[lang].exemplar_chars.auxiliary
):
ortho_soft_dotted_langs.add(lang)
if ortho_soft_dotted_langs:
affected_languages = []
unaffected_languages = []
languages = Languages()
checker = Checker(ttFont.reader.file.name)

for lang in ortho_soft_dotted_langs:
reporter = checker.check(languages[lang])
string = (
f"{gflangs[lang].name} ({gflangs[lang].script}, "
f"{'{:,.0f}'.format(gflangs[lang].population)} speakers)"
)
if reporter.is_success:
affected_languages.append(string)
else:
unaffected_languages.append(string)

if affected_languages:
affected_languages = ", ".join(affected_languages)
message += (
f"\n\nYour font fully covers the following languages that require"
f" the soft-dotted feature: {affected_languages}. "
)

if unaffected_languages:
unaffected_languages = ", ".join(unaffected_languages)
message += (
f"\n\nYour font does *not* cover the following languages that"
f" require the soft-dotted feature: {unaffected_languages}."
)

if fail_unchanged_strings or warn_unchanged_strings:
yield WARN, Message("soft-dotted", message)
else:
yield PASS, (
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ opentype-sanitizer==9.1.0
opentypespec==1.9.1
packaging==23.1
pip-api==0.0.30
protobuf==3.20.3
PyYAML==6.0.1
protobuf==3.20.3
requests==2.31.0
rich==13.4.2
stringbrewer==0.0.1
toml==0.10.2
ufolint==1.2.0
vharfbuzz==0.2.0
ufo2ft==2.32.0
shaperglot==0.3.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"stringbrewer",
f"ufo2ft{UFO2FT_VERSION}",
f"vharfbuzz{VHARFBUZZ_VERSION}",
"shaperglot>=0.2.0", # v0.2.0 had an API update
]

ufo_sources_extras = [
Expand Down Expand Up @@ -173,7 +174,6 @@
# used by 'italic_angle' check in OpenType profile ('post' table);
# also used by ISO 15008 profile
"beziers>=0.5.0", # 0.5.0 uses new fontTools glyph outline access
# ---
],
extras_require={
"all": all_extras,
Expand Down
6 changes: 3 additions & 3 deletions tests/profiles/shaping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ def test_check_soft_dotted():
font = TEST_FILE("abeezee/ABeeZee-Regular.ttf")
msg = assert_results_contain(check(font), WARN, "soft-dotted")
assert "The dot of soft dotted characters used in orthographies" not in msg
assert "The dot of soft dotted characters should disappear" in msg
assert "The dot of soft dotted characters _should_ disappear" in msg

font = TEST_FILE("cabin/Cabin-Regular.ttf")
msg = assert_results_contain(check(font), FAIL, "soft-dotted")
msg = assert_results_contain(check(font), WARN, "soft-dotted")
assert "The dot of soft dotted characters used in orthographies" in msg
assert "The dot of soft dotted characters should disappear" in msg
assert "The dot of soft dotted characters _should_ disappear" in msg

font = TEST_FILE("akshar/Akshar[wght].ttf")
assert_PASS(check(font), "All soft dotted characters seem to lose their dot ...")
Expand Down