default to using /usr/share when XDG_DATA_DIRS is empty or unset

This commit is contained in:
Charles Law 2014-12-29 17:03:39 -08:00
parent ee7b15c924
commit 1c6a89e4c2

View File

@ -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):