code: def _test(glyphset, upem, glyphs, quiet=False, *, control=False):
      from fontTools.pens.transformPen import TransformPen
      from fontTools.misc.transform import Scale
  
      wght_sum = 0
      wght_sum_perceptual = 0
      wdth_sum = 0
      slnt_sum = 0
      slnt_sum_perceptual = 0
      for glyph_name in glyphs:
          glyph = glyphset[glyph_name]
          if control:
              pen = StatisticsControlPen(glyphset=glyphset)
          else:
              pen = StatisticsPen(glyphset=glyphset)
          transformer = TransformPen(pen, Scale(1.0 / upem))
          glyph.draw(transformer)
  
          area = abs(pen.area)
          width = glyph.width
          wght_sum += area
          wght_sum_perceptual += pen.area * width
          wdth_sum += width
          slnt_sum += pen.slant
          slnt_sum_perceptual += pen.slant * width
  
          if quiet:
              continue
  
          print()
          print("glyph:", glyph_name)
  
          for item in [
              "area",
              "momentX",
              "momentY",
              "momentXX",
              "momentYY",
              "momentXY",
              "meanX",
              "meanY",
              "varianceX",
              "varianceY",
              "stddevX",
              "stddevY",
              "covariance",
              "correlation",
              "slant",
          ]:
              print("%s: %g" % (item, getattr(pen, item)))
  
      if not quiet:
          print()
          print("font:")
  
      print("weight: %g" % (wght_sum * upem / wdth_sum))
      print(
          "weight (perceptual): %g" % (wght_sum_perceptual / wdth_sum)
      )
      print("width:  %g" % (wdth_sum / upem / len(glyphs)))
      slant = slnt_sum / len(glyphs)
      print("slant:  %g" % slant)
      print("slant angle:  %g" % -degrees(atan(slant)))
      slant_perceptual = slnt_sum_perceptual / wdth_sum
      print("slant (perceptual):  %g" % slant_perceptual)
      print(
          "slant (perceptual) angle:  %g"
          % -degrees(atan(slant_perceptual))
      )
  
imports: from math import sqrt, degrees, atan
  from fontTools.pens.basePen import BasePen, OpenContourError
  from fontTools.pens.momentsPen import MomentsPen
label_desc: Use image node_id 1 for calling a global function with example usage: _test(glyphset, upem, glyphs, quiet) without return types