MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _get_win32_installed_fonts

Function _get_win32_installed_fonts

lib/matplotlib/font_manager.py:221–250  ·  view source on GitHub ↗

List the font paths known to the Windows registry.

()

Source from the content-addressed store, hash-verified

219
220
221def _get_win32_installed_fonts():
222 """List the font paths known to the Windows registry."""
223 import winreg
224 items = set()
225 # Search and resolve fonts listed in the registry.
226 for domain, base_dirs in [
227 (winreg.HKEY_LOCAL_MACHINE, [win32FontDirectory()]), # System.
228 (winreg.HKEY_CURRENT_USER, MSUserFontDirectories), # User.
229 ]:
230 for base_dir in base_dirs:
231 for reg_path in MSFontDirectories:
232 try:
233 with winreg.OpenKey(domain, reg_path) as local:
234 for j in range(winreg.QueryInfoKey(local)[1]):
235 # value may contain the filename of the font or its
236 # absolute path.
237 key, value, tp = winreg.EnumValue(local, j)
238 if not isinstance(value, str):
239 continue
240 try:
241 # If value contains already an absolute path,
242 # then it is not changed further.
243 path = Path(base_dir, value).resolve()
244 except RuntimeError:
245 # Don't fail with invalid entries.
246 continue
247 items.add(path)
248 except (OSError, MemoryError):
249 continue
250 return items
251
252
253@cache

Callers 1

findSystemFontsFunction · 0.85

Calls 4

win32FontDirectoryFunction · 0.85
PathClass · 0.85
resolveMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…