@@ -1177,28 +1177,53 @@ def score_size(self, size1, size2):
1177
1177
def findfont (self , prop , fontext = 'ttf' , directory = None ,
1178
1178
fallback_to_default = True , rebuild_if_missing = True ):
1179
1179
"""
1180
- Search the font list for the font that most closely matches
1181
- the :class:`FontProperties` *prop*.
1182
-
1183
- :meth:`findfont` performs a nearest neighbor search. Each
1184
- font is given a similarity score to the target font
1185
- properties. The first font with the highest score is
1186
- returned. If no matches below a certain threshold are found,
1187
- the default font (usually DejaVu Sans) is returned.
1188
-
1189
- `directory`, is specified, will only return fonts from the
1190
- given directory (or subdirectory of that directory).
1180
+ Find a font that most closely matches the given font properties.
1181
+
1182
+ Parameters
1183
+ ----------
1184
+ prop : str or `~matplotlib.font_manager.FontProperties`
1185
+ The font properties to search for. This can be either a
1186
+ `.FontProperties` object or a string defining a
1187
+ `fontconfig patterns`_.
1188
+
1189
+ fontext : {'ttf', 'afm'}, optional, default: 'ttf'
1190
+ The extension of the font file:
1191
+
1192
+ - 'ttf': TrueType and OpenType fonts (.ttf, .ttc, .otf)
1193
+ - 'afm': Adobe Font Metrics (.afm)
1194
+
1195
+ directory : str, optional
1196
+ If given, only search this directory and its subdirectories.
1197
+ fallback_to_default : bool
1198
+ If True, will fallback to the default font family (usually
1199
+ "DejaVu Sans" or "Helvetica") if the first lookup hard-fails.
1200
+ rebuild_if_missing : bool
1201
+ Whether to rebuild the font cache and search again if no match
1202
+ is found.
1203
+
1204
+ Returns
1205
+ -------
1206
+ fontfile : str
1207
+ The filename of the best matching font.
1208
+
1209
+ Notes
1210
+ -----
1211
+ This performs a nearest neighbor search. Each font is given a
1212
+ similarity score to the target font properties. The first font with
1213
+ the highest score is returned. If no matches below a certain
1214
+ threshold are found, the default font (usually DejaVu Sans) is
1215
+ returned.
1191
1216
1192
1217
The result is cached, so subsequent lookups don't have to
1193
1218
perform the O(n) nearest neighbor search.
1194
1219
1195
- If `fallback_to_default` is True, will fallback to the default
1196
- font family (usually "DejaVu Sans" or "Helvetica") if
1197
- the first lookup hard-fails.
1198
-
1199
1220
See the `W3C Cascading Style Sheet, Level 1
1200
1221
<http://www.w3.org/TR/1998/REC-CSS2-19980512/>`_ documentation
1201
1222
for a description of the font finding algorithm.
1223
+
1224
+ .. _fontconfig patterns:
1225
+ https://www.freedesktop.org/software/fontconfig/fontconfig-user.html
1226
+
1202
1227
"""
1203
1228
# Pass the relevant rcParams (and the font manager, as `self`) to
1204
1229
# _findfont_cached so to prevent using a stale cache entry after an
0 commit comments