diff --git a/PIL/ImageFont.py b/PIL/ImageFont.py index e59f6a46d..5b4770f54 100644 --- a/PIL/ImageFont.py +++ b/PIL/ImageFont.py @@ -251,6 +251,14 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None): if windir: 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(":") + for lindir in lindirs: + parentpath = os.path.join(lindir, "fonts") + for walkroot, walkdir, walkfilenames in os.walk(parentpath): + if ttf_filename in walkfilenames: + filepath = os.path.join(walkroot, ttf_filename) + return FreeTypeFont(filepath, size, index, encoding) elif sys.platform == 'darwin': macdirs = ['/Library/Fonts/', '/System/Library/Fonts/', os.path.expanduser('~/Library/Fonts/')] for macdir in macdirs: