Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4020d8

Browse files
committed
Convert path to str in FontManager.addpath
1 parent4a3c5d6 commitd4020d8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

‎lib/matplotlib/font_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,8 @@ def addfont(self, path):
10911091
----------
10921092
path : str or path-like
10931093
"""
1094+
path=str(path)# Convert to string in case of a path as
1095+
# afmFontProperty and FT2Font expect this
10941096
ifPath(path).suffix.lower()==".afm":
10951097
withopen(path,"rb")asfh:
10961098
font=_afm.AFM(fh)

‎lib/matplotlib/tests/test_font_manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ def test_user_fonts_linux(tmpdir, monkeypatch):
176176
_get_fontconfig_fonts.cache_clear()
177177

178178

179+
deftest_addfont():
180+
font_test_file='mpltest.ttf'
181+
path=Path(__file__).parent/font_test_file
182+
# Add font using Path, which should not produce an error. See #22582
183+
fontManager.addfont(path)
184+
185+
179186
@pytest.mark.skipif(sys.platform!='win32',reason='Windows only')
180187
deftest_user_fonts_win32():
181188
ifnot (os.environ.get('APPVEYOR')oros.environ.get('TF_BUILD')):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp