code: def _fonts2pys(self):
          
  
          # Get mapping from fonts to fontfiles
  
          system_fonts = font_manager.findSystemFonts()
  
          font_name2font_file = {}
          for sys_font in system_fonts:
              font_name = font_manager.FontProperties(fname=sys_font).get_name()
              if font_name in self.fonts_used:
                  font_name2font_file[font_name] = sys_font
  
          # Only include fonts that have been used in the attributes
          for font_name in font_name2font_file:
              # Serialize font
              with open(font_name2font_file[font_name]) as fontfile:
                  font_data = fontfile.read()
                  ascii_font_data = base64.b64encode(font_data)
  
              # Store font in pys file
              font_line_list = [font_name, ascii_font_data]
              self.pys_file.write(u"\t".join(font_line_list) + u"\n")
docs: Writes fonts to pys file