File tree Expand file tree Collapse file tree 4 files changed +15
-18
lines changed
checks/vendorspecific/googlefonts Expand file tree Collapse file tree 4 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -307,11 +307,11 @@ 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 fontbakery .utils import get_resource_file_path
310+ from fontbakery .utils import get_resource_file_contents
311311
312312 rfn_exceptions_txt = "data/googlefonts/reserved_font_name_exceptions.txt"
313- filename = get_resource_file_path (rfn_exceptions_txt )
314- for exception in open ( filename , "r" , encoding = "utf-8" ). readlines ():
313+ contents = get_resource_file_contents (rfn_exceptions_txt )
314+ for exception in contents . splitlines ():
315315 exception = exception .split ("#" )[0 ].strip ()
316316 exception = exception .replace (" " , "" )
317317 if exception == "" :
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ def check_family_name_compliance(ttFont):
2626 """Check family name for GF Guide compliance."""
2727 import re
2828
29- from fontbakery .utils import get_name_entries , get_resource_file_path
29+ from fontbakery .utils import get_name_entries , get_resource_file_contents
3030
3131 camelcase_exceptions_txt = "data/googlefonts/camelcased_familyname_exceptions.txt"
3232 abbreviations_exceptions_txt = (
@@ -45,8 +45,8 @@ def check_family_name_compliance(ttFont):
4545 known_exception = False
4646
4747 # Process exceptions
48- filename = get_resource_file_path (camelcase_exceptions_txt )
49- for exception in open ( filename , "r" , encoding = "utf-8" ). readlines ():
48+ contents = get_resource_file_contents (camelcase_exceptions_txt )
49+ for exception in contents . splitlines ():
5050 exception = exception .split ("#" )[0 ].strip ()
5151 if exception == "" :
5252 continue
@@ -71,8 +71,8 @@ def check_family_name_compliance(ttFont):
7171 known_exception = False
7272
7373 # Process exceptions
74- filename = get_resource_file_path (abbreviations_exceptions_txt )
75- for exception in open ( filename , "r" , encoding = "utf-8" ). readlines ():
74+ contents = get_resource_file_contents (abbreviations_exceptions_txt )
75+ for exception in contents . splitlines ():
7676 exception = exception .split ("#" )[0 ].strip ()
7777 if exception == "" :
7878 continue
Original file line number Diff line number Diff line change 11import re
22from functools import lru_cache
33
4- from fontbakery .utils import exit_with_install_instructions , get_resource_file_path
4+ from fontbakery .utils import exit_with_install_instructions , get_resource_file_contents
55
66
77@lru_cache (maxsize = 1 )
@@ -21,8 +21,7 @@ def registered_vendor_ids():
2121 exit_with_install_instructions ("googlefonts" )
2222
2323 registered_vendor_ids = {}
24- CACHED = get_resource_file_path ("data/fontbakery-microsoft-vendorlist.cache" )
25- content = open (CACHED , encoding = "utf-8" ).read ()
24+ content = get_resource_file_contents ("data/fontbakery-microsoft-vendorlist.cache" )
2625 # Strip all <A> HTML tags from the raw HTML. The current page contains a
2726 # closing </A> for which no opening <A> is present, which causes
2827 # beautifulsoup to silently stop processing that section from the error
Original file line number Diff line number Diff line change 2020import sys
2121import traceback
2222from copy import deepcopy
23- from typing import TYPE_CHECKING , Optional
23+ from typing import Optional
2424
2525from fontTools .pens .basePen import BasePen
2626from fontTools .ttLib import TTFont
3333 PANOSE_Family_Type ,
3434)
3535
36- if TYPE_CHECKING :
37- from pathlib import Path
3836
39-
40- def get_resource_file_path (sub_file_path : str ) -> Path :
37+ def get_resource_file_contents (sub_file_path : str ) -> str :
4138 """Return the full file path of a resource file inside the fontbakery
4239 directory.
4340
@@ -51,8 +48,9 @@ def get_resource_file_path(sub_file_path: str) -> Path:
5148 from importlib .resources import as_file , files
5249
5350 with as_file (files ("fontbakery" ).joinpath (sub_file_path )) as path :
54- file_path = path
55- return file_path
51+ with open (path , encoding = "utf-8" ) as f :
52+ contents = f .read ()
53+ return contents
5654
5755
5856def exit_with_install_instructions (profile_name ):
You can’t perform that action at this time.
0 commit comments