Skip to content

Commit

Permalink
WARN when article images are not in the expected dir
Browse files Browse the repository at this point in the history
Also, add a bit more context on the rationale text.

com.google.fonts/check/article/images
On the Google Fonts profile

(issue #4594)
  • Loading branch information
felipesanches committed Mar 25, 2024
1 parent d7bd25a commit d17e7f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Lib/fontbakery/checks/googlefonts/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
The purpose of this check is to ensure images (either raster or vector files)
are placed on the correct directory (an `images` subdirectory inside `article`) and
they they are not excessively large in filesize and resolution.
These constraints are loosely based on infrastructure limitations under
default configurations.
""",
proposal="https://github.com/fonttools/fontbakery/issues/4594",
experimental="Since 2024/Mar/19",
experimental="Since 2024/Mar/25",
)
def com_google_fonts_check_metadata_parses(config, family_directory):
"""Validate location, size and resolution of article images."""
Expand All @@ -25,7 +28,7 @@ def com_google_fonts_check_metadata_parses(config, family_directory):
MAXSIZE_RASTER = 800 * 1024 # 800kb

def is_raster(filename):
for ext in ["png", "jpg", "gif"]:
for ext in ["png", "jpg", "jpeg", "jxl", "gif"]:
if filename.lower().endswith(f".{ext}"):
return True
return False
Expand Down Expand Up @@ -60,11 +63,11 @@ def is_vector(filename):
]
if misplaced_files:
passed = False
yield FAIL, Message(
yield WARN, Message(
"misplaced-image-files",
f"There are {len(misplaced_files)} image files in the `article` directory"
f" and they should be moved to an `article/images` subdirectory.\n\n"
f" Misplaced files:\n\n"
f"There are {len(misplaced_files)} image files in the `article`"
f" directory and they should be moved to an `article/images`"
f" subdirectory:\n\n"
f"{bullet_list(config, misplaced_files)}\n",
)

Expand Down
2 changes: 1 addition & 1 deletion tests/checks/googlefonts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5000,7 +5000,7 @@ def test_check_article_images():

assert_results_contain(
check(MockFont(family_directory=family_dir)),
FAIL,
WARN,
"misplaced-image-files",
"The files are not in the correct directory...",
)
Expand Down

0 comments on commit d17e7f1

Please sign in to comment.