3636from numbers import Number
3737import os
3838from pathlib import Path
39+ import plistlib
3940import re
4041import subprocess
4142import sys
@@ -261,6 +262,14 @@ def _get_fontconfig_fonts():
261262 return [Path (os .fsdecode (fname )) for fname in out .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" ]) for entry in d ["_items" ]]
271+
272+
264273def findSystemFonts (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 if sys .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