(self, size=None, weight='normal')
| 1227 | __version__ = '3.11.0' |
| 1228 | |
| 1229 | def __init__(self, size=None, weight='normal'): |
| 1230 | self._version = self.__version__ |
| 1231 | |
| 1232 | self.__default_weight = weight |
| 1233 | self.default_size = size |
| 1234 | |
| 1235 | # Create list of font paths. |
| 1236 | paths = [cbook._get_data_path('fonts', subdir) |
| 1237 | for subdir in ['ttf', 'afm', 'pdfcorefonts']] |
| 1238 | _log.debug('font search path %s', paths) |
| 1239 | |
| 1240 | self.defaultFamily = { |
| 1241 | 'ttf': 'DejaVu Sans', |
| 1242 | 'afm': 'Helvetica'} |
| 1243 | |
| 1244 | self.afmlist = [] |
| 1245 | self.ttflist = [] |
| 1246 | |
| 1247 | # Delay the warning by 5s. |
| 1248 | try: |
| 1249 | timer = threading.Timer(5, lambda: _log.warning( |
| 1250 | 'Matplotlib is building the font cache; this may take a moment.')) |
| 1251 | timer.start() |
| 1252 | except RuntimeError: |
| 1253 | timer = None |
| 1254 | try: |
| 1255 | for fontext in ["afm", "ttf"]: |
| 1256 | for path in [*findSystemFonts(paths, fontext=fontext), |
| 1257 | *findSystemFonts(fontext=fontext)]: |
| 1258 | try: |
| 1259 | self.addfont(path) |
| 1260 | except OSError as exc: |
| 1261 | _log.info("Failed to open font file %s: %s", path, exc) |
| 1262 | except Exception as exc: |
| 1263 | _log.info("Failed to extract font properties from %s: " |
| 1264 | "%s", path, exc) |
| 1265 | finally: |
| 1266 | if timer: |
| 1267 | timer.cancel() |
| 1268 | |
| 1269 | def addfont(self, path): |
| 1270 | """ |
nothing calls this directly
no test coverage detected