<commit_before># Copyright (c) 2021, <NAME>
# License: MIT License
from typing import Optional, Dict
from pathlib import Path
from functools import lru_cache
from matplotlib.font_manager import FontProperties
from matplotlib.textpath import TextPath
from matplotlib.font_manager import FontManager
from . import fonts

_font_manager = None


def rebuild_system_fonts():
    import matplotlib.font_manager
    matplotlib.font_manager._rebuild()
    global _font_manager
    _font_manager = FontManager()


def _get_font_manager():
    global _font_manager
    if _font_manager is None:
        _font_manager = FontManager()
    return _font_manager


def load_system_fonts() -> Dict[str, fonts.FontFace]:
    """ Load system fonts by the FontManager of matplotlib.

    This may take a long time!

    """
    font_faces = dict()
    fm = _get_font_manager()
    for entry in fm.ttflist:
        ttf = fonts.cache_key(entry.fname)
        font_faces[ttf] = fonts.FontFace(
            ttf,<commit_msg>matplotlib.font_manager._rebuild() was removed in Matplotlib 3.4.2<commit_after># Copyright (c) 2021, <NAME>
# License: MIT License
from typing import Optional, Dict
from pathlib import Path
from functools import lru_cache
from matplotlib.font_manager import FontProperties
from matplotlib.textpath import TextPath
from matplotlib.font_manager import FontManager
from . import fonts

_font_manager = None


def rebuild_system_fonts():
    # matplotlib.font_manager._rebuild() was removed in Matplotlib 3.4.2
    global _font_manager
    _font_manager = FontManager()


def _get_font_manager():
    global _font_manager
    if _font_manager is None:
        _font_manager = FontManager()
    return _font_manager


def load_system_fonts() -> Dict[str, fonts.FontFace]:
    """ Load system fonts by the FontManager of matplotlib.

    This may take a long time!

    """
    font_faces = dict()
    fm = _get_font_manager()
    for entry in fm.ttflist:
        ttf = fonts.cache_key(entry.fname)
        font_faces[ttf] = fonts.FontFace(
            ttf,
{'fraction_non_alphanumeric': 0.07309941520467836, 'fraction_numerical': 0.00682261208576998, 'mean_word_length': 3.7195402298850575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '242392', 'n_tokens_mistral': 668, 'n_tokens_neox': 627, 'n_words': 187}