diff --git a/CHANGELOG.md b/CHANGELOG.md index a81ca1dfc9..377b94ca27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ 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.2 (2025-Jan-??) - - ... +### Changes to existing checks +### On the Universal profile. + - **[fontdata_namecheck]** Use api endpoint (issues #https://github.com/fonttools/fontbakery/issues/2719#issuecomment-2618877625) ## 0.13.1 (2025-Jan-17) diff --git a/Lib/fontbakery/checks/fontdata_namecheck.py b/Lib/fontbakery/checks/fontdata_namecheck.py index 1fd9ab0767..797268eeef 100644 --- a/Lib/fontbakery/checks/fontdata_namecheck.py +++ b/Lib/fontbakery/checks/fontdata_namecheck.py @@ -15,24 +15,18 @@ def check_fontdata_namecheck(ttFont, familyname): import requests FB_ISSUE_TRACKER = "https://github.com/fonttools/fontbakery/issues" - NAMECHECK_URL = "http://namecheck.fontdata.com" + API_URL = f"https://namecheck.fontdata.com/api/?q={familyname.replace(' ', '+')}" + HTML_URL = f"http://namecheck.fontdata.com/?q={familyname.replace(' ', '+')}" try: - # Since October 2019, it seems that we need to fake our user-agent - # in order to get correct query results - FAKE = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1)" - response = requests.post( - NAMECHECK_URL, - params={"q": familyname}, - headers={"User-Agent": FAKE}, - timeout=10, - ) - data = response.content.decode("utf-8") - if "fonts by that exact name" in data: + response = requests.get(API_URL) + data = response.json() + # "1.0" means there is a 100% confidence that the name is already in use + if data["data"]["confidence"]["1.0"] > 0: yield INFO, Message( "name-collision", f'The family name "{familyname}" seems' f" to be already in use.\n" - f"Please visit {NAMECHECK_URL} for more info.", + f"Please visit {HTML_URL} for more info.", ) else: yield PASS, "Font familyname seems to be unique." @@ -41,7 +35,7 @@ def check_fontdata_namecheck(ttFont, familyname): yield ERROR, Message( "namecheck-service", - f"Failed to access: {NAMECHECK_URL}.\n" + f"Failed to access: {API_URL}.\n" f"\t\tThis check relies on the external service" f" http://namecheck.fontdata.com via the internet." f" While the service cannot be reached or does not"