code: def subset_font_raw(font_in, font_out, unicodes, opts):
      if "--namelist" in opts:
          # 2010-12-06 DC To allow setting namelist filenames,
          # change getopt.gnu_getopt from namelist to namelist=
          # and invert comments on following 2 lines
          # name_fn = opts['--namelist']
          name_fn = f"{font_out}.name"
          name = open(name_fn, "w")
      else:
          name = None
      if "--script" in opts:
          pe_fn = "/tmp/script.pe"
          pe = open(pe_fn, "w")
      else:
          pe = None
      font = fontforge.open(font_in)
      if pe:
          print(f'Open("{font_in}")', file=pe)
          extract_vert_to_script(font_in, pe)
      for i in unicodes:
          select_with_refs(font, i, font, pe, name)
  
      addl_glyphs = []
      if "--nmr" in opts:
          addl_glyphs.append("nonmarkingreturn")
      if "--null" in opts:
          addl_glyphs.append(".null")
      if "--nd" in opts:
          addl_glyphs.append(".notdef")
      for glyph in addl_glyphs:
          font.selection.select(("more",), glyph)
          if name:
              print(
                  f"0x{fontforge.unicodeFromName(glyph):0.4X}",
                  glyph,
                  file=name,
              )
          if pe:
              print(f'SelectMore("{glyph}")', file=pe)
  
      flags = ()
  
      if "--opentype-features" in opts:
          flags += ("opentype",)
  
      if "--simplify" in opts:
          font.simplify()
          font.round()
          flags += ("omit-instructions",)
  
      if "--strip_names" in opts:
          font.sfnt_names = ()
  
      if "--new" in opts:
          font.copy()
          new = fontforge.font()
          new.encoding = font.encoding
          new.em = font.em
          new.layers["Fore"].is_quadratic = font.layers[
              "Fore"
          ].is_quadratic
          for i in unicodes:
              select_with_refs(font, i, new, pe, name)
          new.paste()
          # This is a hack - it should have been taken care of above.
          font.selection.select("space")
          font.copy()
          new.selection.select("space")
          new.paste()
          new.sfnt_names = font.sfnt_names
          font = new
      else:
          font.selection.invert()
          print("SelectInvert()", file=pe)
          font.cut()
          print("Clear()", file=pe)
  
      if "--move-display" in opts:
          print("Moving display glyphs into Unicode ranges...")
          font.familyname += " Display"
          font.fullname += " Display"
          font.fontname += "Display"
          font.appendSFNTName("English (US)", "Family", font.familyname)
          font.appendSFNTName("English (US)", 16, font.familyname)
          font.appendSFNTName("English (US)", 17, "Display")
          font.appendSFNTName("English (US)", "Fullname", font.fullname)
          for glname in unicodes:
              font.selection.none()
              if isinstance(glname, str):
                  if glname.endswith(".display"):
                      font.selection.select(glname)
                      font.copy()
                      font.selection.none()
                      newgl = glname.replace(".display", "")
                      font.selection.select(newgl)
                      font.paste()
                  font.selection.select(glname)
                  font.cut()
  
      if name:
          print("Writing NameList", end="")
          name.close()
  
      if pe:
          print(f'Generate("{font_out}")', file=pe)
          pe.close()
          subprocess.call(["fontforge", "-script", pe_fn])
      else:
          font.generate(font_out, flags=flags)
      font.close()
  
      if "--roundtrip" in opts:
          # FontForge apparently contains a bug where it incorrectly calculates
          # the advanceWidthMax in the hhea table, and a workaround is to open
          # and re-generate
          font2 = fontforge.open(font_out)
          font2.generate(font_out, flags=flags)
  
file_path: matplotlib/tools/subset.py
imports: import getopt
  import os
  import struct
  import subprocess
  import sys
  import fontforge
label_desc: Use image node_id 3 for calling a global function with example usage: subset_font_raw(font_in, font_out, unicodes, opts) without return types