Skip to content

Commit

Permalink
new/renamed check: description of fonts with articles
Browse files Browse the repository at this point in the history
Renamed check:
from com.google.fonts/check/description/noto_has_article
to com.google.fonts/check/description/has_article
On the Google Fonts profile

Also checks that fonts with article files have an empty description.

(issue #4318)
  • Loading branch information
simoncozens authored Mar 27, 2024
1 parent bc79f4a commit 3ab0ac6
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ A more detailed list of changes is available in the corresponding milestones for
- **EXPERIMENTAL - [com.google.fonts/check/article/images]:** Validate maximum filesize and resolution of images in the article/images directory. (issue #4594)

### Changes to existing checks
#### On the Google Fonts profile
- [com.google.fonts/check/description/noto_has_article]:** This check has been renamed to `description/has_article` and also checks that fonts with article files have an empty description. (issue #4318)

#### On the Universal profile
- **[com.google.fonts/check/arabic_high_hamza]:** Fixed detection of glyphs by codepoint. And fixed a code-typo, to also check for high hamza glyph. (issue #4539)
- **[com.google.fonts/check/interpolation_issues]:** Also detect kinks and contours becoming overweight or underweight. (issue #4388)
Expand Down
67 changes: 52 additions & 15 deletions Lib/fontbakery/checks/googlefonts/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,62 @@ def github_gfonts_description(font: Font, network):


@check(
id="com.google.fonts/check/description/noto_has_article",
conditions=["is_noto"],
id="com.google.fonts/check/description/has_article",
rationale="""
Noto fonts are displayed in a different way on the fonts.google.com
web site, and so must also contain an article about them.
Fonts may have a longer article about them, or a description, but
not both - except for Noto fonts which should have both!
""",
proposal="https://github.com/fonttools/fontbakery/issues/3841",
proposal=[
"https://github.com/fonttools/fontbakery/issues/3841",
"https://github.com/fonttools/fontbakery/issues/4318",
],
)
def com_google_fonts_check_description_noto_has_article(font):
"""Noto fonts must have an ARTICLE.en_us.html file"""
def com_google_fonts_check_description_has_article(font):
"""Check for presence of an ARTICLE.en_us.html file"""
directory = os.path.dirname(font.file)
descfilepath = os.path.join(directory, "article", "ARTICLE.en_us.html")
if os.path.exists(descfilepath):
yield PASS, "ARTICLE.en_us.html exists"
else:
yield FAIL, Message(
"missing-article",
"This is a Noto font but it lacks an ARTICLE.en_us.html file",
)
article_path = os.path.join(directory, "article", "ARTICLE.en_us.html")
has_article = os.path.exists(article_path)
article_is_empty = has_article and os.path.getsize(article_path) == 0

description_is_empty = not font.description
ok = True

if not font.is_noto and has_article:
if not description_is_empty:
ok = False
yield FAIL, Message(
"description-and-article",
"This font has both a DESCRIPTION.en_us.html file"
" and an ARTICLE.en_us.html file. In this case the"
" description must be empty.",
)
if article_is_empty:
ok = False
yield FAIL, Message(
"empty-article",
"The ARTICLE.en_us.html file is empty.",
)
elif font.is_noto:
if not has_article:
ok = False
yield FAIL, Message(
"missing-article",
"This is a Noto font but it lacks an ARTICLE.en_us.html file",
)
if has_article and article_is_empty:
ok = False
yield FAIL, Message(
"empty-article",
"The ARTICLE.en_us.html file is empty.",
)
if not font.description or description_is_empty:
ok = False
yield FAIL, Message(
"empty-description",
"This is a Noto font but it lacks a DESCRIPTION.en_us.html file",
)
if ok:
yield PASS, "Looks good!"


@check(
Expand Down
2 changes: 1 addition & 1 deletion Lib/fontbakery/profiles/googlefonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"com.google.fonts/check/description/git_url",
"com.google.fonts/check/description/has_unsupported_elements",
"com.google.fonts/check/description/min_length",
"com.google.fonts/check/description/noto_has_article",
"com.google.fonts/check/description/has_article",
"com.google.fonts/check/description/urls",
"com.google.fonts/check/description/valid_html",
],
Expand Down
5 changes: 5 additions & 0 deletions data/test/notosanskhudawadi/DESCRIPTION.en_us.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>
Noto is a global font collection for writing in all modern and ancient
languages. Noto Sans Khudawadi is an unmodulated (“sans serif”) design for
texts in the historical Indic <em>Khudawadi</em> script. It has 110 glyphs.
</p>
15 changes: 12 additions & 3 deletions tests/checks/googlefonts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4744,16 +4744,25 @@ def gid1area(ttFont):
)


def test_check_noto_has_article():
"""Noto fonts must have an ARTICLE.en_us.html file"""
check = CheckTester("com.google.fonts/check/description/noto_has_article")
def test_check_has_article():
"""Noto fonts must have an ARTICLE.en_us.html file, others with an
article should have an empty DESCRIPTION"""
check = CheckTester("com.google.fonts/check/description/has_article")

font = TEST_FILE("notosanskhudawadi/NotoSansKhudawadi-Regular.ttf")
assert_PASS(check(font), "with a good font")

font = TEST_FILE("noto_sans_tamil_supplement/NotoSansTamilSupplement-Regular.ttf")
assert_results_contain(check(font), FAIL, "missing-article", "with a bad font")

font = TEST_FILE("tirodevanagarihindi/TiroDevanagariHindi-Regular.ttf")
assert_results_contain(
check(font),
FAIL,
"description-and-article",
"with a font with description and article",
)


def test_check_description_has_unsupported_elements():
"""Check the description doesn't contain unsupported html elements"""
Expand Down

0 comments on commit 3ab0ac6

Please sign in to comment.