From 1c6a89e4c2c3a27d7dcd4d5a3662b1d3008d1ad3 Mon Sep 17 00:00:00 2001 From: Charles Law Date: Mon, 29 Dec 2014 17:03:39 -0800 Subject: [PATCH] default to using /usr/share when XDG_DATA_DIRS is empty or unset --- PIL/ImageFont.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py index 5b4770f54..afbae372f 100644 --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -252,7 +252,12 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None): filename = os.path.join(windir, "fonts", font) return FreeTypeFont(filename, size, index, encoding) elif sys.platform in ('linux', 'linux2'): - lindirs = os.environ.get("XDG_DATA_DIRS", "").split(":") + lindirs = os.environ.get("XDG_DATA_DIRS", "") + if not lindirs: + #According to the freedesktop spec, XDG_DATA_DIRS should + #default to /usr/share + lindirs = '/usr/share' + lindirs = lindirs.split(":") for lindir in lindirs: parentpath = os.path.join(lindir, "fonts") for walkroot, walkdir, walkfilenames in os.walk(parentpath):