mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Partial Fix #370: look for linux fonts in common places
This commit is contained in:
parent
4d2dd3ee7b
commit
17d720aebc
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user