mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
Partial Fix #370: look for osx fonts in common places
This commit is contained in:
parent
707b43f14d
commit
4d2dd3ee7b
|
@ -239,6 +239,10 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
|
||||||
try:
|
try:
|
||||||
return FreeTypeFont(font, size, index, encoding)
|
return FreeTypeFont(font, size, index, encoding)
|
||||||
except IOError:
|
except IOError:
|
||||||
|
if font.endswith(".ttf"):
|
||||||
|
ttf_filename = font
|
||||||
|
else:
|
||||||
|
ttf_filename = "%s.ttf" % font
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
# check the windows font repository
|
# check the windows font repository
|
||||||
# NOTE: must use uppercase WINDIR, to work around bugs in
|
# NOTE: must use uppercase WINDIR, to work around bugs in
|
||||||
|
@ -247,6 +251,12 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
|
||||||
if windir:
|
if windir:
|
||||||
filename = os.path.join(windir, "fonts", font)
|
filename = os.path.join(windir, "fonts", font)
|
||||||
return FreeTypeFont(filename, size, index, encoding)
|
return FreeTypeFont(filename, size, index, encoding)
|
||||||
|
elif sys.platform == 'darwin':
|
||||||
|
macdirs = ['/Library/Fonts/', '/System/Library/Fonts/', os.path.expanduser('~/Library/Fonts/')]
|
||||||
|
for macdir in macdirs:
|
||||||
|
filepath = os.path.join(macdir, ttf_filename)
|
||||||
|
if os.path.exists(filepath):
|
||||||
|
return FreeTypeFont(filepath, size, index, encoding)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user