def fonts(doc: Doc) -> dict:
    """Return each font with its attributes and the pages where it appears."""
    ret = {}
    nb = number_pages(doc)
    font_index = get_page_fonts(doc, list(range(nb)))
    for i, page_fonts in enumerate(font_index):
        for font in page_fonts:
            o = page_fonts[font]['iref']
            n = page_fonts[font]['name'][1:]
            t = page_fonts[font]['type'][1:]
            e = page_fonts[font]['encoding']
            if t == 'Type1':
                if e is None:
                    e = 'built-in'
                else:
                    if type(e) != str:
                        e = 'other'
                    else:
                        e = e[1:]
            else:
                if type(e) != str:
                    e = 'other'
                else:
                    e = e[1:]
            if page_fonts[font]['to_unicode']:
                u = True
            else:
                u = False
            if o not in ret:
                ret[o] = {'name': n,
                          'type': t,
                          'encoding': e,
                          'pages': [],
                          'to_unicode': u,
                          }
            ret[o]['pages'].append(i)
    return ret
Return each font with its attributes and the pages where it appears.
pdfsyntax/api.py