code: def main(args=None):
      """Plan the standard axis mappings for a variable font"""
  
      if args is None:
          import sys
  
          args = sys.argv[1:]
  
      from fontTools import configLogger
      from fontTools.ttLib import TTFont
      import argparse
  
      parser = argparse.ArgumentParser(
          "fonttools varLib.avarPlanner",
          description="Plan `avar` table for variable font",
      )
      parser.add_argument(
          "font", metavar="varfont.ttf", help="Variable-font file."
      )
      parser.add_argument(
          "-o",
          "--output-file",
          type=str,
          help="Output font file name.",
      )
      parser.add_argument(
          "--weights",
          type=str,
          help="Space-separate list of weights to generate.",
      )
      parser.add_argument(
          "--widths",
          type=str,
          help="Space-separate list of widths to generate.",
      )
      parser.add_argument(
          "--slants",
          type=str,
          help="Space-separate list of slants to generate.",
      )
      parser.add_argument(
          "--sizes",
          type=str,
          help="Space-separate list of optical-sizes to generate.",
      )
      parser.add_argument(
          "--samples", type=int, help="Number of samples."
      )
      parser.add_argument(
          "-s",
          "--sanitize",
          action="store_true",
          help="Sanitize axis limits",
      )
      parser.add_argument(
          "-g",
          "--glyphs",
          type=str,
          help="Space-separate list of glyphs to use for sampling.",
      )
      parser.add_argument(
          "--weight-design-limits",
          type=str,
          help="min:default:max in design units for the `wght` axis.",
      )
      parser.add_argument(
          "--width-design-limits",
          type=str,
          help="min:default:max in design units for the `wdth` axis.",
      )
      parser.add_argument(
          "--slant-design-limits",
          type=str,
          help="min:default:max in design units for the `slnt` axis.",
      )
      parser.add_argument(
          "--optical-size-design-limits",
          type=str,
          help="min:default:max in design units for the `opsz` axis.",
      )
      parser.add_argument(
          "--weight-pins",
          type=str,
          help="Space-separate list of before:after pins for the `wght` axis.",
      )
      parser.add_argument(
          "--width-pins",
          type=str,
          help="Space-separate list of before:after pins for the `wdth` axis.",
      )
      parser.add_argument(
          "--slant-pins",
          type=str,
          help="Space-separate list of before:after pins for the `slnt` axis.",
      )
      parser.add_argument(
          "--optical-size-pins",
          type=str,
          help="Space-separate list of before:after pins for the `opsz` axis.",
      )
      parser.add_argument(
          "-p",
          "--plot",
          action="store_true",
          help="Plot the resulting mapping.",
      )
  
      logging_group = parser.add_mutually_exclusive_group(
          required=False
      )
      logging_group.add_argument(
          "-v",
          "--verbose",
          action="store_true",
          help="Run more verbosely.",
      )
      logging_group.add_argument(
          "-q",
          "--quiet",
          action="store_true",
          help="Turn verbosity off.",
      )
  
      options = parser.parse_args(args)
  
      configLogger(
          level=(
              "DEBUG"
              if options.verbose
              else "WARNING"
              if options.quiet
              else "INFO"
          )
      )
  
      font = TTFont(options.font)
      if not "fvar" in font:
          log.error("Not a variable font.")
          return 1
  
      if options.glyphs is not None:
          glyphs = options.glyphs.split()
          if ":" in options.glyphs:
              glyphs = {}
              for g in options.glyphs.split():
                  if ":" in g:
                      glyph, frequency = g.split(":")
                      glyphs[glyph] = float(frequency)
                  else:
                      glyphs[g] = 1.0
      else:
          glyphs = None
  
      designspaceSnippets = []
  
      designspaceSnippets.append(
          processAxis(
              font,
              planWeightAxis,
              "wght",
              "Weight",
              values=options.weights,
              samples=options.samples,
              glyphs=glyphs,
              designLimits=options.weight_design_limits,
              pins=options.weight_pins,
              sanitize=options.sanitize,
              plot=options.plot,
          )
      )
      designspaceSnippets.append(
          processAxis(
              font,
              planWidthAxis,
              "wdth",
              "Width",
              values=options.widths,
              samples=options.samples,
              glyphs=glyphs,
              designLimits=options.width_design_limits,
              pins=options.width_pins,
              sanitize=options.sanitize,
              plot=options.plot,
          )
      )
      designspaceSnippets.append(
          processAxis(
              font,
              planSlantAxis,
              "slnt",
              "Slant",
              values=options.slants,
              samples=options.samples,
              glyphs=glyphs,
              designLimits=options.slant_design_limits,
              pins=options.slant_pins,
              sanitize=options.sanitize,
              plot=options.plot,
          )
      )
      designspaceSnippets.append(
          processAxis(
              font,
              planOpticalSizeAxis,
              "opsz",
              "OpticalSize",
              values=options.sizes,
              samples=options.samples,
              glyphs=glyphs,
              designLimits=options.optical_size_design_limits,
              pins=options.optical_size_pins,
              sanitize=options.sanitize,
              plot=options.plot,
          )
      )
  
      log.info("Designspace snippet:")
      for snippet in designspaceSnippets:
          if snippet:
              print(snippet)
  
      if options.output_file is None:
          outfile = makeOutputFileName(
              options.font, overWrite=True, suffix=".avar"
          )
      else:
          outfile = options.output_file
      if outfile:
          log.info("Saving %s", outfile)
          font.save(outfile)
  
imports: from fontTools.ttLib import newTable
  from fontTools.ttLib.tables._f_v_a_r import Axis
  from fontTools.pens.areaPen import AreaPen
  from fontTools.pens.basePen import NullPen
  from fontTools.pens.statisticsPen import StatisticsPen
  from fontTools.varLib.models import piecewiseLinearMap, normalizeValue
  from fontTools.misc.cliTools import makeOutputFileName
  import math
  import logging
  from pprint import pformat
label_desc: Use image node_id 20 for calling a global function with example usage: main(args) and returns: int