10000 Resolve linked fonts in fontManager.findfont() · matplotlib/matplotlib@5e030c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e030c8

Browse files
committed
Resolve linked fonts in fontManager.findfont()
The commit ensures that the realpath of linked fonts is used across the library. This prevents embedding a linked fonts twice and makes sure that linked fonts are referenced consistently in PDFs files. The link resolution cannot happend in addfont() since this would break the *directory* argument of findfont().
1 parent 4a78af5 commit 5e030c8

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,9 +1238,10 @@ def findfont(self, prop, fontext='ttf', directory=None,
12381238
rc_params = tuple(tuple(rcParams[key]) for key in [
12391239
"font.serif", "font.sans-serif", "font.cursive", "font.fantasy",
12401240
"font.monospace"])
1241-
return self._findfont_cached(
1241+
filename = self._findfont_cached(
12421242
prop, fontext, directory, fallback_to_default, rebuild_if_missing,
12431243
rc_params)
1244+
return os.path.realpath(filename)
12441245

12451246
@lru_cache()
12461247
def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
@@ -1339,9 +1340,6 @@ def is_opentype_cff_font(filename):
13391340

13401341

13411342
def get_font(filename, hinting_factor=None):
1342-
# Resolving the path avoids embedding the font twice in pdf/ps output if a
1343-
# single font is selected using two different relative paths.
1344-
filename = os.path.realpath(filename)
13451343
if hinting_factor is None:
13461344
hinting_factor = rcParams['text.hinting_factor']
13471345
return _get_font(os.fspath(filename), hinting_factor,

0 commit comments

Comments
 (0)
0