Skip to content

Commit ba5610f

Browse files
Fix font manager so it doesn't miss some fonts whose attributes don't parse as UTF-8.
Update font manager to have same font path search as master.
1 parent 13c93fb commit ba5610f

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

lib/matplotlib/font_manager.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def OSXFontDirectory():
240240
try:
241241
if os.path.isdir(fontdir):
242242
for root, dirs, files in os.walk(fontdir):
243-
fontpaths.append(root)
243+
for dir in dirs:
244+
fontpaths.append(os.path.join(root, dir))
244245
except (IOError, OSError, TypeError, ValueError):
245246
pass
246247
return fontpaths
@@ -278,7 +279,8 @@ def x11FontDirectory():
278279
try:
279280
if os.path.isdir(fontdir):
280281
for root, dirs, files in os.walk(fontdir):
281-
fontpaths.append(root)
282+
for dir in dirs:
283+
fontpaths.append(os.path.join(root, dir))
282284
except (IOError, OSError, TypeError, ValueError):
283285
pass
284286
return fontpaths
@@ -604,8 +606,7 @@ def createFontList(fontfiles, fontext='ttf'):
604606
verbose.report("Cannot handle unicode filenames")
605607
#print >> sys.stderr, 'Bad file is', fpath
606608
continue
607-
try: prop = ttfFontProperty(font)
608-
except: continue
609+
prop = ttfFontProperty(font)
609610

610611
fontlist.append(prop)
611612
return fontlist
@@ -1291,14 +1292,6 @@ def is_opentype_cff_font(filename):
12911292

12921293
fontManager = None
12931294

1294-
_fmcache = os.path.join(get_configdir(), 'fontList.cache')
1295-
1296-
def _rebuild():
1297-
global fontManager
1298-
fontManager = FontManager()
1299-
pickle_dump(fontManager, _fmcache)
1300-
verbose.report("generated new fontManager")
1301-
13021295
# The experimental fontconfig-based backend.
13031296
if USE_FONTCONFIG and sys.platform != 'win32':
13041297
import re

src/ft2font.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,8 @@ FT2Font::get_sfnt(const Py::Tuple & args)
16371637
key[2] = Py::Int(sfnt.language_id);
16381638
key[3] = Py::Int(sfnt.name_id);
16391639
names[key] = Py::String((char *) sfnt.string,
1640-
(int) sfnt.string_len);
1640+
(int) sfnt.string_len,
1641+
"latin-1");
16411642
}
16421643
return names;
16431644
}

0 commit comments

Comments
 (0)