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

Commit18bfd1e

Browse files
authored
Merge pull request#27230 from anntzer/macosfonts
Query macOS for available system fonts.
2 parents3f94e78 +6e3ed38 commit18bfd1e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎lib/matplotlib/font_manager.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
fromnumbersimportNumber
3737
importos
3838
frompathlibimportPath
39+
importplistlib
3940
importre
4041
importsubprocess
4142
importsys
@@ -261,6 +262,14 @@ def _get_fontconfig_fonts():
261262
return [Path(os.fsdecode(fname))forfnameinout.split(b'\n')]
262263

263264

265+
@lru_cache
266+
def_get_macos_fonts():
267+
"""Cache and list the font paths known to ``system_profiler SPFontsDataType``."""
268+
d,=plistlib.loads(
269+
subprocess.check_output(["system_profiler","-xml","SPFontsDataType"]))
270+
return [Path(entry["path"])forentryind["_items"]]
271+
272+
264273
deffindSystemFonts(fontpaths=None,fontext='ttf'):
265274
"""
266275
Search for fonts in the specified font paths. If no paths are
@@ -279,6 +288,7 @@ def findSystemFonts(fontpaths=None, fontext='ttf'):
279288
else:
280289
installed_fonts=_get_fontconfig_fonts()
281290
ifsys.platform=='darwin':
291+
installed_fonts+=_get_macos_fonts()
282292
fontpaths= [*X11FontDirectories,*OSXFontDirectories]
283293
else:
284294
fontpaths=X11FontDirectories
@@ -1011,7 +1021,7 @@ class FontManager:
10111021
# Increment this version number whenever the font cache data
10121022
# format or behavior has changed and requires an existing font
10131023
# cache files to be rebuilt.
1014-
__version__=330
1024+
__version__=390
10151025

10161026
def__init__(self,size=None,weight='normal'):
10171027
self._version=self.__version__

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp