|
161 | 161 | ]
|
162 | 162 |
|
163 | 163 |
|
| 164 | +@lru_cache(64) |
| 165 | +def _cached_realpath(path): |
| 166 | + return os.path.realpath(path) |
| 167 | + |
| 168 | + |
164 | 169 | def get_fontext_synonyms(fontext):
|
165 | 170 | """
|
166 | 171 | Return a list of file extensions extensions that are synonyms for
|
@@ -1308,10 +1313,9 @@ def findfont(self, prop, fontext='ttf', directory=None,
|
1308 | 1313 | rc_params = tuple(tuple(rcParams[key]) for key in [
|
1309 | 1314 | "font.serif", "font.sans-serif", "font.cursive", "font.fantasy",
|
1310 | 1315 | "font.monospace"])
|
1311 |
| - filename = self._findfont_cached( |
| 1316 | + return self._findfont_cached( |
1312 | 1317 | prop, fontext, directory, fallback_to_default, rebuild_if_missing,
|
1313 | 1318 | rc_params)
|
1314 |
| - return os.path.realpath(filename) |
1315 | 1319 |
|
1316 | 1320 | @lru_cache()
|
1317 | 1321 | def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
|
@@ -1382,7 +1386,7 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
|
1382 | 1386 | else:
|
1383 | 1387 | raise ValueError("No valid font could be found")
|
1384 | 1388 |
|
1385 |
| - return result |
| 1389 | + return _cached_realpath(result) |
1386 | 1390 |
|
1387 | 1391 |
|
1388 | 1392 | @lru_cache()
|
@@ -1411,10 +1415,10 @@ def is_opentype_cff_font(filename):
|
1411 | 1415 | def get_font(filename, hinting_factor=None):
|
1412 | 1416 | # Resolving the path avoids embedding the font twice in pdf/ps output if a
|
1413 | 1417 | # single font is selected using two different relative paths.
|
1414 |
| - filename = os.path.realpath(filename) |
| 1418 | + filename = _cached_realpath(filename) |
1415 | 1419 | if hinting_factor is None:
|
1416 | 1420 | hinting_factor = rcParams['text.hinting_factor']
|
1417 |
| - return _get_font(os.fspath(filename), hinting_factor, |
| 1421 | + return _get_font(filename, hinting_factor, |
1418 | 1422 | _kerning_factor=rcParams['text.kerning_factor'])
|
1419 | 1423 |
|
1420 | 1424 |
|
|
0 commit comments