@@ -277,17 +277,31 @@ def _get_macos_fonts():
277277
278278def findSystemFonts (fontpaths = None , fontext = 'ttf' ):
279279 """
280- Search for fonts in the specified font paths. If no paths are
281- given, will use a standard set of system paths, as well as the
282- list of fonts tracked by fontconfig if fontconfig is installed and
283- available. A list of TrueType fonts are returned by default with
284- AFM fonts as an option.
280+ Find fonts in a search path, system paths, or some other platform-specific method.
281+
282+ Parameters
283+ ----------
284+ fontpaths : list of str, optional
285+ Search for fonts in these specified font paths. If no paths are given and the
286+ :envvar:`MPL_IGNORE_SYSTEM_FONTS` is not set, use a standard set of system
287+ paths, as well as the list of fonts tracked by fontconfig if fontconfig is
288+ installed and available.
289+ fontext : {'ttf', 'afm'}, default: 'ttf'
290+ If 'ttf', search for TrueType fonts; if 'afm', search for with AFM fonts.
291+
292+ Returns
293+ -------
294+ list of str
295+ A list of file paths with fonts of the given type.
285296 """
286297 fontfiles = set ()
287298 fontexts = get_fontext_synonyms (fontext )
288299
289300 if fontpaths is None :
290- if sys .platform == 'win32' :
301+ if os .getenv ('MPL_IGNORE_SYSTEM_FONTS' ):
302+ installed_fonts = []
303+ fontpaths = []
304+ elif sys .platform == 'win32' :
291305 installed_fonts = _get_win32_installed_fonts ()
292306 fontpaths = []
293307 elif sys .platform == 'emscripten' :
@@ -1465,6 +1479,8 @@ def findfont(self, prop, fontext='ttf', directory=None,
14651479
14661480 directory : str, optional
14671481 If given, only search this directory and its subdirectories.
1482+ If :envvar:`MPL_IGNORE_SYSTEM_FONTS` is set, then this defaults to
1483+ Matplotlib's internal font directory.
14681484
14691485 fallback_to_default : bool
14701486 If True, will fall back to the default font family (usually
@@ -1506,6 +1522,8 @@ def findfont(self, prop, fontext='ttf', directory=None,
15061522 "serif" , "sans-serif" , "cursive" , "fantasy" , "monospace" ]]
15071523 rc_params = tuple (tuple (e ) if isinstance (e , list ) else e
15081524 for e in rc_params ) # Make this hashable.
1525+ if directory is None and os .getenv ('MPL_IGNORE_SYSTEM_FONTS' ):
1526+ directory = cbook ._get_data_path ('fonts' )
15091527 ret = self ._findfont_cached (
15101528 prop , fontext , directory , fallback_to_default , rebuild_if_missing ,
15111529 rc_params )
0 commit comments