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

Class FontPath

lib/matplotlib/font_manager.py:337–389  ·  view source on GitHub ↗

A class to describe a path to a font with a face index. Parameters ---------- path : str The path to a font. face_index : int The face index in the font.

Source from the content-addressed store, hash-verified

335# existing one. In this case, sub-classing str is the simpler and less-disruptive
336# option.
337class FontPath(str):
338 """
339 A class to describe a path to a font with a face index.
340
341 Parameters
342 ----------
343 path : str
344 The path to a font.
345 face_index : int
346 The face index in the font.
347 """
348
349 __match_args__ = ('path', 'face_index')
350
351 def __new__(cls, path, face_index):
352 ret = super().__new__(cls, path)
353 ret._face_index = face_index
354 return ret
355
356 @property
357 def path(self):
358 """The path to a font."""
359 return str(self)
360
361 @property
362 def face_index(self):
363 """The face index in a font."""
364 return self._face_index
365
366 def _as_tuple(self):
367 return (self.path, self.face_index)
368
369 def __eq__(self, other):
370 if isinstance(other, FontPath):
371 return self._as_tuple() == other._as_tuple()
372 return super().__eq__(other)
373
374 def __ne__(self, other):
375 return not (self == other)
376
377 def __lt__(self, other):
378 if isinstance(other, FontPath):
379 return self._as_tuple() < other._as_tuple()
380 return super().__lt__(other)
381
382 def __gt__(self, other):
383 return not (self == other or self < other)
384
385 def __hash__(self):
386 return hash(self._as_tuple())
387
388 def __repr__(self):
389 return f'FontPath{self._as_tuple()}'
390
391
392@dataclasses.dataclass(frozen=True)

Callers 8

fontNameMethod · 0.90
_embedTeXFontMethod · 0.90
draw_mathtextMethod · 0.90
draw_textMethod · 0.90
test_font_pathFunction · 0.90
test_find_validFunction · 0.90
test_addfont_as_pathFunction · 0.90
_findfont_cachedMethod · 0.85

Calls

no outgoing calls

Tested by 3

test_font_pathFunction · 0.72
test_find_validFunction · 0.72
test_addfont_as_pathFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…