code: def interpolate_cff2_metrics(varfont, topDict, glyphOrder, loc):
      """Unlike TrueType glyphs, neither advance width nor bounding box
      info is stored in a CFF2 charstring. The width data exists only in
      the hmtx and HVAR tables. Since LSB data cannot be interpolated
      reliably from the master LSB values in the hmtx table, we traverse
      the charstring to determine the actual bound box."""
  
      charstrings = topDict.CharStrings
      boundsPen = BoundsPen(glyphOrder)
      hmtx = varfont["hmtx"]
      hvar_table = None
      if "HVAR" in varfont:
          hvar_table = varfont["HVAR"].table
          fvar = varfont["fvar"]
          varStoreInstancer = VarStoreInstancer(
              hvar_table.VarStore, fvar.axes, loc
          )
  
      for gid, gname in enumerate(glyphOrder):
          entry = list(hmtx[gname])
          # get width delta.
          if hvar_table:
              if hvar_table.AdvWidthMap:
                  width_idx = hvar_table.AdvWidthMap.mapping[gname]
              else:
                  width_idx = gid
              width_delta = otRound(varStoreInstancer[width_idx])
          else:
              width_delta = 0
  
          # get LSB.
          boundsPen.init()
          charstring = charstrings[gname]
          charstring.draw(boundsPen)
          if boundsPen.bounds is None:
              # Happens with non-marking glyphs
              lsb_delta = 0
          else:
              lsb = otRound(boundsPen.bounds[0])
              lsb_delta = entry[1] - lsb
  
          if lsb_delta or width_delta:
              if width_delta:
                  entry[0] = max(0, entry[0] + width_delta)
              if lsb_delta:
                  entry[1] = lsb
              hmtx[gname] = tuple(entry)
  
file_path: catboost/contrib/python/fonttools/fontTools/varLib/mutator.py
imports: from fontTools.misc.fixedTools import floatToFixedToFloat, floatToFixed
  from fontTools.misc.roundTools import otRound
  from fontTools.pens.boundsPen import BoundsPen
  from fontTools.ttLib import TTFont, newTable
  from fontTools.ttLib.tables import ttProgram
  from fontTools.ttLib.tables._g_l_y_f import GlyphCoordinates, flagOverlapSimple, OVERLAP_COMPOUND
  from fontTools.varLib.models import supportScalar, normalizeLocation, piecewiseLinearMap
  from fontTools.varLib.merger import MutatorMerger
  from fontTools.varLib.varStore import VarStoreInstancer
  from fontTools.varLib.mvar import MVAR_ENTRIES
  from fontTools.varLib.iup import iup_delta
  import fontTools.subset.cff
  import os.path
  import logging
  from io import BytesIO
label_desc: Use image node_id 3 for calling a global function with example usage: interpolate_cff2_metrics(varfont, topDict, glyphOrder, loc) without return types