code: def main(args=None):
      """Generate per-character SVG from font and text"""
  
      if args is None:
          import sys
  
          args = sys.argv[1:]
  
      from fontTools.ttLib import TTFont
      import argparse
  
      parser = argparse.ArgumentParser(
          "fonttools pens.svgPathPen",
          description="Generate SVG from text",
      )
      parser.add_argument("font", metavar="font.ttf", help="Font file.")
      parser.add_argument("text", metavar="text", help="Text string.")
      parser.add_argument(
          "-y",
          metavar="<number>",
          help="Face index into a collection to open. Zero based.",
      )
      parser.add_argument(
          "--variations",
          metavar="AXIS=LOC",
          default="",
          help="List of space separated locations. A location consist in "
          "the name of a variation axis, followed by '=' and a number. E.g.: "
          "wght=700 wdth=80. The default is the location of the base master.",
      )
  
      options = parser.parse_args(args)
  
      fontNumber = int(options.y) if options.y is not None else 0
  
      font = TTFont(options.font, fontNumber=fontNumber)
      text = options.text
  
      location = {}
      for tag_v in options.variations.split():
          fields = tag_v.split("=")
          tag = fields[0].strip()
          v = float(fields[1])
          location[tag] = v
  
      hhea = font["hhea"]
      ascent, descent = hhea.ascent, hhea.descent
  
      glyphset = font.getGlyphSet(location=location)
      cmap = font["cmap"].getBestCmap()
  
      s = ""
      width = 0
      for u in text:
          g = cmap[ord(u)]
          glyph = glyphset[g]
  
          pen = SVGPathPen(glyphset)
          glyph.draw(pen)
          commands = pen.getCommands()
  
          s += (
              '<g transform="translate(%d %d) scale(1 -1)"><path d="%s"/></g>\n'
              % (
                  width,
                  ascent,
                  commands,
              )
          )
  
          width += glyph.width
  
      print('<?xml version="1.0" encoding="UTF-8"?>')
      print(
          '<svg width="%d" height="%d" xmlns="http://www.w3.org/2000/svg">'
          % (width, ascent - descent)
      )
      print(s, end="")
      print("</svg>")
  
file_path: catboost/contrib/python/fonttools/fontTools/pens/svgPathPen.py
imports: from typing import Callable
  from fontTools.pens.basePen import BasePen
label_desc: Use image node_id 2 for calling a global function with example usage: main(args) without return types