mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
Improve xdg directory support in Linux
This commit is contained in:
parent
114e01701a
commit
2e15dc9f53
|
@ -837,12 +837,19 @@ def truetype(
|
||||||
if windir:
|
if windir:
|
||||||
dirs.append(os.path.join(windir, "fonts"))
|
dirs.append(os.path.join(windir, "fonts"))
|
||||||
elif sys.platform in ("linux", "linux2"):
|
elif sys.platform in ("linux", "linux2"):
|
||||||
lindirs = os.environ.get("XDG_DATA_DIRS")
|
data_home = os.environ.get("XDG_DATA_HOME")
|
||||||
if not lindirs:
|
if not data_home:
|
||||||
# According to the freedesktop spec, XDG_DATA_DIRS should
|
# The freedesktop spec defines the following default directory for
|
||||||
# default to /usr/share
|
# when XDG_DATA_HOME is unset or empty. This user-level directory
|
||||||
lindirs = "/usr/share"
|
# takes precedence over system-level directories.
|
||||||
dirs += [os.path.join(lindir, "fonts") for lindir in lindirs.split(":")]
|
data_home = os.path.expanduser("~/.local/share")
|
||||||
|
dirs.append(os.path.join(data_home, "fonts"))
|
||||||
|
|
||||||
|
data_dirs = os.environ.get("XDG_DATA_DIRS")
|
||||||
|
if not data_dirs:
|
||||||
|
# Similarly, defaults are defined for the system-level directories
|
||||||
|
data_dirs = "/usr/local/share:/usr/share"
|
||||||
|
dirs += [os.path.join(ddir, "fonts") for ddir in data_dirs.split(":")]
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
dirs += [
|
dirs += [
|
||||||
"/Library/Fonts",
|
"/Library/Fonts",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user