Skip to content

Commit

Permalink
Change CR_SelectFont to use glob
Browse files Browse the repository at this point in the history
On my system (Arch Linux) `/usr/share/fonts` existed, but had no
`truetype` directory under it. This will now find all `.ttf` files
under the fonts directory.
  • Loading branch information
WeeBull committed Feb 11, 2024
1 parent 5ea4c57 commit ea4a1e4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nodes/nodes_graphics_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import numpy as np
import torch
import glob
import os
import platform
from PIL import Image, ImageDraw, ImageOps, ImageFont
Expand Down Expand Up @@ -460,12 +461,12 @@ def INPUT_TYPES(cls):
font_dir = os.path.join(system_root, "Fonts") if system_root else None
# Default debian-based Linux & MacOS font dirs
elif platform.system() == "Linux":
font_dir = "/usr/share/fonts/truetype"
font_dir = "/usr/share/fonts"
elif platform.system() == "Darwin":
font_dir = "/System/Library/Fonts"

file_list = [f for f in os.listdir(font_dir) if os.path.isfile(os.path.join(font_dir, f)) and f.lower().endswith(".ttf")]
file_list = glob.glob(os.path.join(font_dir, "**", "*.ttf"))

return {"required": {
"font_name": (file_list,),
}
Expand Down

0 comments on commit ea4a1e4

Please sign in to comment.