File tree Expand file tree Collapse file tree
checks/vendorspecific/googlefonts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11Below are the noteworthy changes from each release.
22A 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 ).
33
4- ## Upcoming release: 1.1.0 (2025-Jul-??)
4+ ## Upcoming release: 1.1.0 (2025-Sept-??)
5+ - Replace deprecated ` pkg_resources ` by ` importlib.resources ` (issue #5028 )
6+ - ...
57
68### Changes to existing checks
79### On the Universal profile
Original file line number Diff line number Diff line change @@ -307,10 +307,10 @@ def rfn_exception(font):
307307 been published previously with an RFN, or fonts which benefit from
308308 an agreement with Google Fonts.
309309 """
310- from pkg_resources import resource_filename
310+ from fontbakery . utils import get_resource_file_path
311311
312312 rfn_exceptions_txt = "data/googlefonts/reserved_font_name_exceptions.txt"
313- filename = resource_filename ( "fontbakery" , rfn_exceptions_txt )
313+ filename = get_resource_file_path ( rfn_exceptions_txt )
314314 for exception in open (filename , "r" , encoding = "utf-8" ).readlines ():
315315 exception = exception .split ("#" )[0 ].strip ()
316316 exception = exception .replace (" " , "" )
Original file line number Diff line number Diff line change 2525def check_family_name_compliance (ttFont ):
2626 """Check family name for GF Guide compliance."""
2727 import re
28- from pkg_resources import resource_filename
29- from fontbakery .utils import get_name_entries
28+
29+ from fontbakery .utils import get_name_entries , get_resource_file_path
3030
3131 camelcase_exceptions_txt = "data/googlefonts/camelcased_familyname_exceptions.txt"
3232 abbreviations_exceptions_txt = (
@@ -45,7 +45,7 @@ def check_family_name_compliance(ttFont):
4545 known_exception = False
4646
4747 # Process exceptions
48- filename = resource_filename ( "fontbakery" , camelcase_exceptions_txt )
48+ filename = get_resource_file_path ( camelcase_exceptions_txt )
4949 for exception in open (filename , "r" , encoding = "utf-8" ).readlines ():
5050 exception = exception .split ("#" )[0 ].strip ()
5151 if exception == "" :
@@ -71,7 +71,7 @@ def check_family_name_compliance(ttFont):
7171 known_exception = False
7272
7373 # Process exceptions
74- filename = resource_filename ( "fontbakery" , abbreviations_exceptions_txt )
74+ filename = get_resource_file_path ( abbreviations_exceptions_txt )
7575 for exception in open (filename , "r" , encoding = "utf-8" ).readlines ():
7676 exception = exception .split ("#" )[0 ].strip ()
7777 if exception == "" :
Original file line number Diff line number Diff line change 11import re
22from functools import lru_cache
3- from pkg_resources import resource_filename
43
5- from fontbakery .utils import exit_with_install_instructions
4+ from fontbakery .utils import exit_with_install_instructions , get_resource_file_path
65
76
87@lru_cache (maxsize = 1 )
@@ -22,9 +21,7 @@ def registered_vendor_ids():
2221 exit_with_install_instructions ("googlefonts" )
2322
2423 registered_vendor_ids = {}
25- CACHED = resource_filename (
26- "fontbakery" , "data/fontbakery-microsoft-vendorlist.cache"
27- )
24+ CACHED = get_resource_file_path ("data/fontbakery-microsoft-vendorlist.cache" )
2825 content = open (CACHED , encoding = "utf-8" ).read ()
2926 # Strip all <A> HTML tags from the raw HTML. The current page contains a
3027 # closing </A> for which no opening <A> is present, which causes
Original file line number Diff line number Diff line change 1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515#
16+ from __future__ import annotations
17+
1618import os
1719import subprocess
1820import sys
1921import traceback
20- from typing import Optional
2122from copy import deepcopy
23+ from typing import TYPE_CHECKING , Optional
2224
2325from fontTools .pens .basePen import BasePen
2426from fontTools .ttLib import TTFont
3133 PANOSE_Family_Type ,
3234)
3335
36+ if TYPE_CHECKING :
37+ from pathlib import Path
38+
39+
40+ def get_resource_file_path (sub_file_path : str ) -> Path :
41+ """Return the full file path of a resource file inside the fontbakery
42+ directory.
43+
44+ Args:
45+ sub_file_path (str): The file path relative to the `fontbakery`
46+ directory.
47+
48+ Returns:
49+ Path: The full file path
50+ """
51+ from importlib .resources import as_file , files
52+
53+ with as_file (files ("fontbakery" ).joinpath (sub_file_path )) as path :
54+ file_path = path
55+ return file_path
56+
3457
3558def exit_with_install_instructions (profile_name ):
3659 sys .exit (
Original file line number Diff line number Diff line change @@ -209,10 +209,6 @@ exclude = [
209209minversion = " 6.0"
210210testpaths = [" tests" ]
211211addopts = " --color=yes --verbose"
212- filterwarnings = [
213- " ignore:pkg_resources is deprecated as an API:DeprecationWarning" ,
214- " ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning" ,
215- ]
216212
217213# ============================================================================
218214[tool .pylint .master ]
You can’t perform that action at this time.
0 commit comments