mirror of
https://github.com/1j01/textual-paint.git
synced 2024-09-11 15:56:03 +03:00
Add font names for macOS
This commit is contained in:
parent
5a5d8b38af
commit
e2308c2a91
@ -22,6 +22,7 @@
|
||||
"**/*.egg-info/**/*"
|
||||
],
|
||||
"words": [
|
||||
"Andale",
|
||||
"APNG",
|
||||
"appcode",
|
||||
"appscript",
|
||||
@ -65,6 +66,7 @@
|
||||
"llpaper",
|
||||
"lrgb",
|
||||
"Lucida",
|
||||
"Menlo",
|
||||
"mirc",
|
||||
"modd",
|
||||
"mspaint",
|
||||
|
@ -44,20 +44,25 @@ font_names = [
|
||||
"CourierNew",
|
||||
"LucidaConsole",
|
||||
"Monaco",
|
||||
"Menlo",
|
||||
"Andale Mono",
|
||||
"Courier New",
|
||||
]
|
||||
font = None
|
||||
for font_dir in font_dirs:
|
||||
path = Path(os.path.expandvars(os.path.expanduser(font_dir)))
|
||||
files = path.glob("**/*.ttf")
|
||||
# files = list(files) # printing consumes the generator without this!
|
||||
# print("path", path, "files", "\n".join(map(str, files)))
|
||||
for file in files:
|
||||
# print(file.stem)
|
||||
# print(f"stem {file.stem!r}", file.stem in font_names)
|
||||
if file.stem in font_names:
|
||||
font = ImageFont.truetype(str(file), size=16, layout_engine=ImageFont.LAYOUT_BASIC)
|
||||
break
|
||||
if font:
|
||||
break
|
||||
if not font:
|
||||
print("Font not found, using default (built-in) font.")
|
||||
print("Font not found, falling back to built-in font for rasterization.")
|
||||
font = ImageFont.load_default()
|
||||
|
||||
ch_width: int
|
||||
|
Loading…
Reference in New Issue
Block a user