Skip to content

Commit

Permalink
Remove validation of location of article images.
Browse files Browse the repository at this point in the history
com.google.fonts/check/article/images
On the Google Fonts profile.

(issue #4703)
  • Loading branch information
felipesanches committed May 31, 2024
1 parent acacf4b commit 0ff568d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A more detailed list of changes is available in the corresponding milestones for
- Checks which validate the description files now also validate article files (issue #4730)
- **[com.google.font/check/description/unsupported_elements]:** Also checks for wellformedness of HTML video tags. (issue #4730)
- **[com.google.fonts/check/metadata/copyright_max_length], [com.google.fonts/check/metadata/nameid/copyright], [com.google.fonts/check/metadata/valid_copyright], [com.google.fonts/check/name/copyright_length]:** These checks have all been merged into [com.google.fonts/check/font_copyright]. (PR #4748 / issue #4735)
- **EXPERIMENTAL - [com.google.fonts/check/article/images]:** Ensure article page has minimum length and includes visual assets. Also added more thorough code-testing. (issue #4653)
- **EXPERIMENTAL - [com.google.fonts/check/article/images]:** Ensure article page has minimum length and includes visual assets. Also added more thorough code-testing. (issue #4653) and remove checking of location of the image files (issue #4703)

#### On the Type Network profile
- **[com.typenetwork/check/usweightclass]:** Detects better "Semi", "Extra" and "Ultra" weights using a space on the name. (PR #4751)
Expand Down
24 changes: 4 additions & 20 deletions Lib/fontbakery/checks/googlefonts/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
conditions=["family_directory"],
rationale="""
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 that they are not excessively large in filesize and resolution.
are not excessively large in filesize and resolution.
These constraints are loosely based on infrastructure limitations under
default configurations.
Expand All @@ -21,10 +20,10 @@
experimental="Since 2024/Mar/25",
)
def com_google_fonts_check_article_images(config, family_directory):
"""Validate location, size, and resolution of article images,
"""Validate size, and resolution of article images,
and ensure article page has minimum length and includes visual assets."""
from bs4 import BeautifulSoup
from fontbakery.utils import bullet_list
from fontbakery.utils import bullet_list, image_dimensions

MAX_WIDTH = 2048
MAX_HEIGHT = 1024
Expand Down Expand Up @@ -85,26 +84,11 @@ def is_vector(filename):
f"Visual asset files are missing:\n{bullet_list(config, missing_files)}",
)

misplaced_files = [
all_image_files = [
os.path.join(article_dir, filename)
for filename in os.listdir(article_dir)
if is_vector(filename) or is_raster(filename)
]
all_image_files = misplaced_files
if os.path.isdir(images_dir):
all_image_files += [
os.path.join(images_dir, filename)
for filename in os.listdir(images_dir)
if is_vector(filename) or is_raster(filename)
]
if misplaced_files:
yield WARN, Message(
"misplaced-image-files",
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",
)

for filename in all_image_files:
if is_vector(filename):
Expand Down
18 changes: 7 additions & 11 deletions tests/checks/googlefonts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5019,7 +5019,7 @@ def test_check_linegaps():


def test_check_article_images():
"""Test ARTICLE page visual content, length requirements, and image properties."""
"""Test article page visual content, length requirements, and image properties."""
check = CheckTester(
"com.google.fonts/check/article/images", profile=googlefonts_profile
)
Expand Down Expand Up @@ -5050,23 +5050,19 @@ def test_check_article_images():
check(MockFont(family_directory=family_directory)), WARN, "missing-visual-file"
)

# Test case for misplaced image files
family_directory = portable_path("data/test/misplaced_image_files")
assert_results_contain(
check(MockFont(family_directory=family_directory)),
WARN,
"misplaced-image-files",
)

# TODO:
# # Test case for image file exceeding size limit
# family_directory = portable_path("data/test/large_image_file")
# assert_results_contain(check(MockFont(family_directory=family_directory)), FAIL, "filesize")
# assert_results_contain(
# check(MockFont(family_directory=family_directory)), FAIL, "filesize"
# )

# TODO:
# # Test case for image file exceeding resolution limit
# family_directory = portable_path("data/test/large_resolution_image")
# assert_results_contain(check(MockFont(family_directory=family_directory)), FAIL, "image-too-large")
# assert_results_contain(
# check(MockFont(family_directory=family_directory)), FAIL, "image-too-large"
# )

# Test case for ARTICLE meeting requirements
family_directory = portable_path("data/test/article_valid")
Expand Down

0 comments on commit 0ff568d

Please sign in to comment.