code: def get_glyphs_subset(fontfile, characters):
      """
      Subset a TTF font
  
      Reads the named fontfile and restricts the font to the characters.
      Returns a serialization of the subset font as file-like object.
  
      Parameters
      ----------
      fontfile : str
          Path to the font file
      characters : str
          Continuous set of characters to include in subset
      """
  
      options = subset.Options(
          glyph_names=True, recommended_glyphs=True
      )
  
      # Prevent subsetting extra tables.
      options.drop_tables += [
          "FFTM",  # FontForge Timestamp.
          "PfEd",  # FontForge personal table.
          "BDF",  # X11 BDF header.
          "meta",  # Metadata stores design/supported languages (meaningless for subsets).
      ]
  
      # if fontfile is a ttc, specify font number
      if fontfile.endswith(".ttc"):
          options.font_number = 0
  
      with subset.load_font(fontfile, options) as font:
          subsetter = subset.Subsetter(options=options)
          subsetter.populate(text=characters)
          subsetter.subset(font)
          fh = BytesIO()
          font.save(fh, reorderTables=False)
          return fh
  
imports: from io import BytesIO
  import functools
  from fontTools import subset
  import matplotlib
  from ..None import font_manager, ft2font
  from .._afm import AFM
  from ..backend_bases import RendererBase
label_desc: Use image node_id 2 for calling a global function with example usage: get_glyphs_subset(fontfile, characters) and returns: fh