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

Class FontEntry

lib/matplotlib/font_manager.py:393–421  ·  view source on GitHub ↗

A class for storing Font properties. It is used when populating the font lookup dictionary.

Source from the content-addressed store, hash-verified

391
392@dataclasses.dataclass(frozen=True)
393class FontEntry:
394 """
395 A class for storing Font properties.
396
397 It is used when populating the font lookup dictionary.
398 """
399
400 fname: str = ''
401 index: int = 0
402 name: str = ''
403 style: str = 'normal'
404 variant: str = 'normal'
405 weight: str | int = 'normal'
406 stretch: str = 'normal'
407 size: str = 'medium'
408
409 def _repr_html_(self) -> str:
410 png_stream = self._repr_png_()
411 png_b64 = b64encode(png_stream).decode()
412 return f"<img src=\"data:image/png;base64, {png_b64}\" />"
413
414 def _repr_png_(self) -> bytes:
415 from matplotlib.figure import Figure # Circular import.
416 fig = Figure()
417 font_path = Path(self.fname) if self.fname != '' else None
418 fig.text(0, 0, self.name, font=font_path)
419 with BytesIO() as buf:
420 fig.savefig(buf, bbox_inches='tight', transparent=True)
421 return buf.getvalue()
422
423
424def ttfFontProperty(font):

Callers 6

test_fontentry_dataclassFunction · 0.90
ttfFontPropertyFunction · 0.85
afmFontPropertyFunction · 0.85
_json_decodeFunction · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…