# cff

fontTools.varLib.cff.addCFFVarStore(varFont, varModel, varDataList, masterSupports)

fontTools.varLib.cff.convertCFFtoCFF2(varFont)

fontTools.varLib.cff.conv_to_int(num)

fontTools.varLib.cff.get_private(regionFDArrays, fd_index, ri, fd_map)

fontTools.varLib.cff.merge_PrivateDicts(top_dicts, vsindex_dict, var_model, fd_map)

  I step through the FontDicts in the FDArray of the varfont TopDict. For each varfont FontDict:

  - step through each key in FontDict.Private.

  - For each key, step through each relevant source font Private dict, and build a list of values to blend.

  The ‘relevant’ source fonts are selected by first getting the right submodel using `vsindex_dict[vsindex]`. The indices of the `subModel.locations` are mapped to source font list indices by assuming the latter order is the same as the order of the `var_model.locations`. I can then get the index of each subModel location in the list of `var_model.locations`.

fontTools.varLib.cff.getfd_map(varFont, fonts_list)

  Since a subset source font may have fewer FontDicts in their FDArray than the default font, we have to match up the FontDicts in the different fonts . We do this with the FDSelect array, and by assuming that the same glyph will reference matching FontDicts in each source font. We return a mapping from fdIndex in the default font to a dictionary which maps each master list index of each region font to the equivalent fdIndex in the region font.

class fontTools.varLib.cff.CVarData(varDataList, masterSupports, vsindex_dict)

  Bases: `tuple`

  masterSupports

    Alias for field number 1

  varDataList

    Alias for field number 0

  vsindex_dict

    Alias for field number 2

fontTools.varLib.cff.merge_region_fonts(varFont, model, ordered_fonts_list, glyphOrder)

fontTools.varLib.cff.merge_charstrings(glyphOrder, num_masters, top_dicts, masterModel)

class fontTools.varLib.cff.CFFToCFF2OutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None, blender=None)

  Bases: `T2OutlineExtractor`

  This class is used to remove the initial width from the CFF charstring without trying to add the width to self.nominalWidthX, which is None.

  popallWidth(evenOdd=0)

class fontTools.varLib.cff.MergeOutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None, blender=None)

  Bases: `CFFToCFF2OutlineExtractor`

  Used to extract the charstring commands - including hints - from a CFF charstring in order to merge it as another set of region data into a CFF2 variable font charstring.

  countHints()
  op_hstem(index)
  op_vstem(index)
  op_hstemhm(index)
  op_vstemhm(index)
  op_hintmask(index)
  op_cntrmask(index)

class fontTools.varLib.cff.CFF2CharStringMergePen(default_commands, glyphName, num_masters, master_idx, roundTolerance=0.01)

  Bases: `T2CharStringPen`

  Pen to merge Type 2 CharStrings.

  add_point(point_type, pt_coords)
  add_hint(hint_type, args)
  add_hintmask(hint_type, abs_args)
  restart(region_idx)
  getCommands()
  reorder_blend_args(commands, get_delta_func)

    We first re-order the master coordinate values. For a moveto to lineto, the args are now arranged as:

        [ [master_0 x,y], [master_1 x,y], [master_2 x,y] ]

    We re-arrange this to:

        [       [master_0 x, master_1 x, master_2 x],
                [master_0 y, master_1 y, master_2 y]
        ]

    If the master values are all the same, we collapse the list to as single value instead of a list.

    We then convert this to:

        [ [master_0 x] + [x delta tuple] + [numBlends=1]
          [master_0 y] + [y delta tuple] + [numBlends=1]
        ]

  getCharString(private=None, globalSubrs=None, var_model=None, optimize=True)