Only scan font dirs recursively if the font is not found in any top level dir
This commit is contained in:
parent
ed85f177b6
commit
0a01f41996
1 changed files with 10 additions and 6 deletions
16
setup.py
16
setup.py
|
|
@ -923,17 +923,21 @@ def add_builtin_fonts(args: Options) -> None:
|
|||
continue
|
||||
font_file = ''
|
||||
if is_macos:
|
||||
for candidate in (os.path.expanduser('~/Library/Fonts'), '/Library/Fonts', '/System/Library/Fonts', '/Network/Library/Fonts'):
|
||||
candidates = (
|
||||
os.path.expanduser('~/Library/Fonts'), '/Library/Fonts', '/System/Library/Fonts', '/Network/Library/Fonts')
|
||||
for candidate in candidates:
|
||||
q = os.path.join(candidate, filename)
|
||||
if os.path.exists(q):
|
||||
font_file = q
|
||||
break
|
||||
for root, _, files in os.walk(candidate, onerror=lambda _: None):
|
||||
if filename in files:
|
||||
font_file = os.path.join(root, filename)
|
||||
else:
|
||||
for candidate in candidates:
|
||||
for root, _, files in os.walk(candidate, onerror=lambda _: None):
|
||||
if filename in files:
|
||||
font_file = os.path.join(root, filename)
|
||||
break
|
||||
if font_file:
|
||||
break
|
||||
if font_file:
|
||||
break
|
||||
elif is_windows:
|
||||
for candidate in (
|
||||
os.path.expandvars(r'%userprofile%\AppData\Local\Microsoft\Windows\Fonts'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue