@@ -941,12 +941,11 @@ def _normalize_font_family(family):
941941
942942class FontManager :
943943 """
944- On import, the :class:`FontManager` singleton instance creates a
945- list of TrueType fonts based on the font properties: name, style,
946- variant, weight, stretch, and size. The :meth:`findfont` method
947- does a nearest neighbor search to find the font that most closely
948- matches the specification. If no good enough match is found, a
949- default font is returned.
944+ On import, the `FontManager` singleton instance creates a list of ttf and
945+ afm fonts and caches their `FontProperties`. The `FontManager.findfont`
946+ method does a nearest neighbor search to find the font that most closely
947+ matches the specification. If no good enough match is found, the default
948+ font is returned.
950949 """
951950 # Increment this version number whenever the font cache data
952951 # format or behavior has changed and requires a existing font
@@ -1196,12 +1195,15 @@ def findfont(self, prop, fontext='ttf', directory=None,
11961195
11971196 directory : str, optional
11981197 If given, only search this directory and its subdirectories.
1198+
11991199 fallback_to_default : bool
12001200 If True, will fallback to the default font family (usually
12011201 "DejaVu Sans" or "Helvetica") if the first lookup hard-fails.
1202+
12021203 rebuild_if_missing : bool
1203- Whether to rebuild the font cache and search again if no match
1204- is found.
1204+ Whether to rebuild the font cache and search again if the first
1205+ match appears to point to a nonexisting font (i.e., the font cache
1206+ contains outdated entries).
12051207
12061208 Returns
12071209 -------
@@ -1225,7 +1227,6 @@ def findfont(self, prop, fontext='ttf', directory=None,
12251227
12261228 .. _fontconfig patterns:
12271229 https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
1228-
12291230 """
12301231 # Pass the relevant rcParams (and the font manager, as `self`) to
12311232 # _findfont_cached so to prevent using a stale cache entry after an
@@ -1282,7 +1283,8 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
12821283 prop .get_family (), self .defaultFamily [fontext ])
12831284 default_prop = prop .copy ()
12841285 default_prop .set_family (self .defaultFamily [fontext ])
1285- return self .findfont (default_prop , fontext , directory , False )
1286+ return self .findfont (default_prop , fontext , directory ,
1287+ fallback_to_default = False )
12861288 else :
12871289 raise ValueError (f"Failed to find font { prop } , and fallback "
12881290 f"to the default font was disabled" )
@@ -1297,7 +1299,7 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
12971299 'findfont: Found a missing font file. Rebuilding cache.' )
12981300 _rebuild ()
12991301 return fontManager .findfont (
1300- prop , fontext , directory , True , False )
1302+ prop , fontext , directory , rebuild_if_missing = False )
13011303 else :
13021304 raise ValueError ("No valid font could be found" )
13031305
0 commit comments