Skip to content

Commit d50c9cc

Browse files
authored
Merge pull request #1 from radarhere/improved-xdg-dirs-support
Rearranged code
2 parents 8e6426f + f62796d commit d50c9cc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/PIL/ImageFont.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,13 +848,15 @@ def freetype(font: StrOrBytesPath | BinaryIO | None) -> FreeTypeFont:
848848
# when XDG_DATA_HOME is unset or empty. This user-level directory
849849
# takes precedence over system-level directories.
850850
data_home = os.path.expanduser("~/.local/share")
851-
dirs.append(os.path.join(data_home, "fonts"))
851+
xdg_dirs = [data_home]
852852

853853
data_dirs = os.environ.get("XDG_DATA_DIRS")
854854
if not data_dirs:
855855
# Similarly, defaults are defined for the system-level directories
856856
data_dirs = "/usr/local/share:/usr/share"
857-
dirs += [os.path.join(ddir, "fonts") for ddir in data_dirs.split(":")]
857+
xdg_dirs += data_dirs.split(":")
858+
859+
dirs += [os.path.join(xdg_dir, "fonts") for xdg_dir in xdg_dirs]
858860
elif sys.platform == "darwin":
859861
dirs += [
860862
"/Library/Fonts",

0 commit comments

Comments
 (0)