old_contents: # TWP: Generate OpenType feature substitution code for selected glyphs
  # works with simple ligatures and alternates.
  # Does not attempt to decode multiple-feature glyphs such as "f_f_i.alt"
  # as there is no single clear right input set for that
  
  f = fl.font
  if f == None:
    exit
  
  def printCode(g, index):
    if g == None:
      return
    dropDot = glyphs[index].name.split(".")[0]
    inputNames = dropDot.replace("_"," ")
    if len(glyphs[index].name.split(".")) == 1:
    	return
    print "  sub", inputNames, "by", glyphs[index].name , ";"
  
  font = fl.font
  glyphs = font.glyphs
  for index in range(len(glyphs)):
    if fl.Selected(index):
      printCode(glyphs[index], index)
  
new_contents: # FontLab script to generate OpenType feature substitution code for selected glyphs
  # works with simple ligatures and alternates.
  # Does not attempt to decode multiple-feature glyphs such as "f_f_i.alt"
  # as there is no single clear right input set for that
  #
  # by Thomas Phinney, open source under Apache 2.0 license
  
  f = fl.font
  if f == None:
    exit
  
  # function to call for each glyph...
  # it takes two arguments
  def printCode(g):
    if g == None:
      return
  # take the part of the glyph name before the period:
    dropDot = g.name.split(".")[0]
  # separate ligature components:
    ligSplit = dropDot.replace("_"," ")
  # if neither of these substitutions did anything, exit function and don't print the replacement code
    if dropDot == g.name and ligSplit == g.name.split(".")[0] :
    	return
  # hey, let's print the glyph replacement code now!
    print "  sub", ligSplit, "by", g.name , ";"
  
  # This is the actual program (using the function above)
  font = fl.font
  glyphs = font.glyphs
  # for every glyph in the font
  for index in range(len(glyphs)):
    if fl.Selected(index):
      printCode(glyphs[index])
  
subject: Update Generate-substitutions.py