code: def _gatherLookupIndexes(gpos):
      
      # gather the indexes of the kern features
      kernFeatureIndexes = [index for index, featureRecord in enumerate(gpos.FeatureList.FeatureRecord) if featureRecord.FeatureTag == "kern"]
      # find scripts and languages that have kern features
      scriptKernFeatureIndexes = {}
      for scriptRecord in gpos.ScriptList.ScriptRecord:
          script = scriptRecord.ScriptTag
          thisScriptKernFeatureIndexes = []
          defaultLangSysRecord = scriptRecord.Script.DefaultLangSys
          if defaultLangSysRecord is not None:
              f = []
              for featureIndex in defaultLangSysRecord.FeatureIndex:
                  if featureIndex not in kernFeatureIndexes:
                      continue
                  f.append(featureIndex)
              if f:
                  thisScriptKernFeatureIndexes.append((None, f))
          if scriptRecord.Script.LangSysRecord is not None:
              for langSysRecord in scriptRecord.Script.LangSysRecord:
                  langSys = langSysRecord.LangSysTag
                  f = []
                  for featureIndex in langSysRecord.LangSys.FeatureIndex:
                      if featureIndex not in kernFeatureIndexes:
                          continue
                      f.append(featureIndex)
                  if f:
                      thisScriptKernFeatureIndexes.append((langSys, f))
          scriptKernFeatureIndexes[script] = thisScriptKernFeatureIndexes
      # convert the feature indexes to lookup indexes
      scriptLookupIndexes = {}
      for script, featureDefinitions in scriptKernFeatureIndexes.items():
          lookupIndexes = scriptLookupIndexes[script] = []
          for language, featureIndexes in featureDefinitions:
              for featureIndex in featureIndexes:
                  featureRecord = gpos.FeatureList.FeatureRecord[featureIndex]
                  for lookupIndex in featureRecord.Feature.LookupListIndex:
                      if lookupIndex not in lookupIndexes:
                          lookupIndexes.append(lookupIndex)
      # done
      return scriptLookupIndexes
docs: Gather a mapping of script to lookup indexes
      referenced by the kern feature for each script.
      Returns a dictionary of this structure:
          {
              "latn" : [0],
              "DFLT" : [0]
          }