@utils.memoize
def get_font_files():
    """Returns a list of all font files we could find

    Returned as a list of dir/files tuples::

        get_font_files() -> [('/some/dir', ['font1.ttf', ...]), ...]

    For example::

        >>> fabfonts = os.path.join(os.path.dirname(__file__), 'fonts')
        >>> 'IndUni-H-Bold.ttf' in get_font_files()[fabfontdir]
        True
        >>> 'DejaVuSansMono.ttf' in get_font_files()[fabfontdir]
        True
        >>> 'cmr10.ttf' in get_font_files()[fabfontdir]
        True

        >>> assert len(get_font_files()) > 0
        >>> for dirname, filename in get_font_files():
        ...     assert os.path.exists(os.path.join(dirname, filename))
        ...

    """
    dirs = [os.path.join(os.path.dirname(__file__), 'fonts'),
            os.path.expanduser('~/.fonts')]

    sys_dirs = [
        # this is where ubuntu puts fonts
        '/usr/share/fonts/truetype',
        # this is where fedora puts fonts
        '/usr/share/fonts',
    ]

    for dirname in sys_dirs:
        try:
            dirs += [os.path.join(dirname, subdir)
                     for subdir in os.listdir(dirname)]
        except __HOLE__:
            pass

    return [(p, os.listdir(p)) for p in dirs if os.path.isdir(p)]
dataset/ETHPy150Open jart/fabulous/fabulous/text.py/get_font_files