code: def subset_glyphs(self, s):
      cff = self.cff
      for fontname in cff.keys():
          font = cff[fontname]
          cs = font.CharStrings
  
          glyphs = s.glyphs.union(s.glyphs_emptied)
  
          # Load all glyphs
          for g in font.charset:
              if g not in glyphs:
                  continue
              c, _ = cs.getItemAndSelector(g)
  
          if cs.charStringsAreIndexed:
              indices = [
                  i for i, g in enumerate(font.charset) if g in glyphs
              ]
              csi = cs.charStringsIndex
              csi.items = [csi.items[i] for i in indices]
              del csi.file, csi.offsets
              if hasattr(font, "FDSelect"):
                  sel = font.FDSelect
                  sel.format = None
                  sel.gidArray = [sel.gidArray[i] for i in indices]
              newCharStrings = {}
              for indicesIdx, charsetIdx in enumerate(indices):
                  g = font.charset[charsetIdx]
                  if g in cs.charStrings:
                      newCharStrings[g] = indicesIdx
              cs.charStrings = newCharStrings
          else:
              cs.charStrings = {
                  g: v for g, v in cs.charStrings.items() if g in glyphs
              }
          font.charset = [g for g in font.charset if g in glyphs]
          font.numGlyphs = len(font.charset)
  
          if s.options.retain_gids:
              isCFF2 = cff.major > 1
              for g in s.glyphs_emptied:
                  _empty_charstring(
                      font, g, isCFF2=isCFF2, ignoreWidth=True
                  )
  
      return True
  
imports: from fontTools.misc import psCharStrings
  from fontTools import ttLib
  from fontTools.pens.basePen import NullPen
  from fontTools.misc.roundTools import otRound
  from fontTools.misc.loggingTools import deprecateFunction
  from fontTools.subset.util import _add_method, _uniq_sort
label_desc: Use image node_id 4 for calling a global function with example usage: subset_glyphs(s) and returns: True