cff

fontTools.varLib.cff.addCFFVarStore(varFont, varModel, varDataList, masterSupports)[source]
fontTools.varLib.cff.convertCFFtoCFF2(varFont)[source]
fontTools.varLib.cff.conv_to_int(num)[source]
fontTools.varLib.cff.get_private(regionFDArrays, fd_index, ri, fd_map)[source]
fontTools.varLib.cff.merge_PrivateDicts(top_dicts, vsindex_dict, var_model, fd_map)[source]

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)[source]

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)[source]
fontTools.varLib.cff.merge_charstrings(glyphOrder, num_masters, top_dicts, masterModel)[source]
class fontTools.varLib.cff.CFFToCFF2OutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None, blender=None)[source]

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)[source]
class fontTools.varLib.cff.MergeOutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None, blender=None)[source]

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()[source]
op_hstem(index)[source]
op_vstem(index)[source]
op_hstemhm(index)[source]
op_vstemhm(index)[source]
op_hintmask(index)[source]
op_cntrmask(index)[source]
class fontTools.varLib.cff.CFF2CharStringMergePen(default_commands, glyphName, num_masters, master_idx, roundTolerance=0.01)[source]

Bases: T2CharStringPen

Pen to merge Type 2 CharStrings.

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

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)[source]