8000 Refactor and remove FontsPath class · matplotlib/matplotlib@2b58d16 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b58d16

Browse files
committed
Refactor and remove FontsPath class
1 parent b715ddb commit 2b58d16

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed
< 10000 div role="region" aria-labelledby="heading-:Rtlab:" class="position-relative" style="contain:layout">

lib/matplotlib/font_manager.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,19 +1020,6 @@ def json_load(filename):
10201020
return json.load(fh, object_hook=_json_decode)
10211021

10221022

1023-
class FontsPath:
1024-
"""Class to hold the result of findfont"""
1025-
def __init__(self, file_paths):
1026-
self._filepaths = None
1027-
self.set_filepaths(file_paths)
1028-
1029-
def set_filepaths(self, file_paths):
1030-
self._filepaths = file_paths
1031-
1032-
def get_filepaths(self):
1033-
return self._filepaths
1034-
1035-
10361023
def _normalize_font_family(family):
10371024
if isinstance(family, str):
10381025
family = [family]
@@ -1335,16 +1322,16 @@ def findfont(self, prop, fontext='ttf', directory=None,
13351322
FontProperties._from_any(prop), fontext, directory,
13361323
fallback_to_default, rebuild_if_missing, rc_params)
13371324

1338-
# if fontfile isn't found, fpath will be a FontsPath object
1339-
if isinstance(fpath, FontsPath):
1340-
fbpaths.update(fpath.get_filepaths())
1325+
# if fontfile isn't found, fpath will be an OrderedDict
1326+
if isinstance(fpath, OrderedDict):
1327+
fbpaths.update(fpath)
13411328
else:
13421329
fpaths[ffamily[fidx]] = fpath
13431330

13441331
# append fallback font(s) to the very end
13451332
fpaths.update(fbpaths)
13461333

1347-
return FontsPath(fpaths)
1334+
return fpaths
13481335

13491336

13501337
@lru_cache()
@@ -1457,9 +1444,9 @@ def _get_font(filenames, hinting_factor, *, _kerning_factor, thread_id):
14571444
def get_font(filename, hinting_factor=None):
14581445
# Resolving the path avoids embedding the font twice in pdf/ps output if a
14591446
# single font is selected using two different relative paths.
1460-
if isinstance(filename, FontsPath):
1447+
if isinstance(filename, OrderedDict):
14611448
filenames = []
1462-
for fname in filename.get_filepaths().values():
1449+
for fname in filename.values():
14631450
filenames.append(_cached_realpath(fname))
14641451
else:
14651452
filenames = [_cached_realpath(filename)]

0 commit comments

Comments
 (0)
0