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

Function get_font

lib/matplotlib/font_manager.py:1787–1830  ·  view source on GitHub ↗

Get an `.ft2font.FT2Font` object given a list of file paths. Parameters ---------- font_filepaths : Iterable[str, bytes, os.PathLike, FontPath], \ str, bytes, os.PathLike, FontPath Relative or absolute paths to the font files to be used. If a single string, bytes,

(font_filepaths, hinting_factor=None)

Source from the content-addressed store, hash-verified

1785
1786@_api.delete_parameter('3.11', 'hinting_factor')
1787def get_font(font_filepaths, hinting_factor=None):
1788 """
1789 Get an `.ft2font.FT2Font` object given a list of file paths.
1790
1791 Parameters
1792 ----------
1793 font_filepaths : Iterable[str, bytes, os.PathLike, FontPath], \
1794str, bytes, os.PathLike, FontPath
1795 Relative or absolute paths to the font files to be used.
1796
1797 If a single string, bytes, or `os.PathLike`, then it will be treated
1798 as a list with that entry only.
1799
1800 If more than one filepath is passed, then the returned FT2Font object
1801 will fall back through the fonts, in the order given, to find a needed
1802 glyph.
1803
1804 Returns
1805 -------
1806 `.ft2font.FT2Font`
1807
1808 """
1809 match font_filepaths:
1810 case FontPath(path, index):
1811 paths = ((_cached_realpath(path), index), )
1812 case str() | bytes() | os.PathLike() as path:
1813 paths = ((_cached_realpath(path), 0), )
1814 case _:
1815 paths = tuple(
1816 (_cached_realpath(fname.path), fname.face_index)
1817 if isinstance(fname, FontPath) else (_cached_realpath(fname), 0)
1818 for fname in font_filepaths)
1819
1820 font = _get_font(
1821 # must be a tuple to be cached
1822 paths,
1823 _kerning_factor=mpl.rcParams['text.kerning_factor'],
1824 # also key on the thread ID to prevent segfaults with multi-threading
1825 thread_id=threading.get_ident(),
1826 enable_last_resort=mpl.rcParams['font.enable_last_resort'],
1827 )
1828 # Ensure the transform is always consistent.
1829 font._set_transform([[0x10000, 0], [0, 0x10000]], [0, 0])
1830 return font
1831
1832
1833def _load_fontmanager(*, try_read_cache=True):

Callers 15

_get_fontMethod · 0.90
get_glyphs_texMethod · 0.90
_font_to_ps_type3Function · 0.90
_get_pdf_charprocsFunction · 0.90
embedTTFMethod · 0.90
draw_texMethod · 0.90
_prepare_fontMethod · 0.90
test_font_priorityFunction · 0.90
test_find_ttcFunction · 0.90
test_find_validFunction · 0.90
test_find_invalidFunction · 0.90

Calls 3

_cached_realpathFunction · 0.85
_get_fontFunction · 0.85
_set_transformMethod · 0.45

Tested by 5

test_font_priorityFunction · 0.72
test_find_ttcFunction · 0.72
test_find_validFunction · 0.72
test_find_invalidFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…