cff¶
-
class
fontTools.varLib.cff.CFF2CharStringMergePen(default_commands, glyphName, num_masters, master_idx, roundTolerance=0.5)[source]¶ Pen to merge Type 2 CharStrings.
-
addComponent(glyphName, transformation)¶ Transform the points of the base glyph and draw it onto self.
-
closePath()¶ Close the current sub path. You must call either pen.closePath() or pen.endPath() after each sub path.
-
curveTo(*points)¶ Draw a cubic bezier with an arbitrary number of control points.
The last point specified is on-curve, all others are off-curve (control) points. If the number of control points is > 2, the segment is split into multiple bezier segments. This works like this:
Let n be the number of control points (which is the number of arguments to this call minus 1). If n==2, a plain vanilla cubic bezier is drawn. If n==1, we fall back to a quadratic segment and if n==0 we draw a straight line. It gets interesting when n>2: n-1 PostScript-style cubic segments will be drawn as if it were one curve. See decomposeSuperBezierSegment().
The conversion algorithm used for n>2 is inspired by NURB splines, and is conceptually equivalent to the TrueType “implied points” principle. See also decomposeQuadraticSegment().
-
endPath()¶ End the current sub path, but don’t close it. You must call either pen.closePath() or pen.endPath() after each sub path.
-
lineTo(pt)¶ Draw a straight line from the current point to ‘pt’.
-
property
log¶
-
moveTo(pt)¶ Begin a new sub path, set the current point to ‘pt’. You must end each sub path with a call to pen.closePath() or pen.endPath().
-
qCurveTo(*points)¶ Draw a whole string of quadratic curve segments.
The last point specified is on-curve, all others are off-curve points.
This method implements TrueType-style curves, breaking up curves using ‘implied points’: between each two consequtive off-curve points, there is one implied point exactly in the middle between them. See also decomposeQuadraticSegment().
The last argument (normally the on-curve point) may be None. This is to support contours that have NO on-curve points (a rarely seen feature of TrueType outlines).
-
reorder_blend_args(commands, get_delta_func, round_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]
]
-
skipMissingComponents= True¶
-
-
class
fontTools.varLib.cff.CFFToCFF2OutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None)[source]¶ 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.
-
alternatingLineto(isHorizontal)¶
-
closePath()¶
-
countHints()¶
-
endPath()¶
-
execute(charString)¶
-
hcurveto(args)¶
-
op_abs(index)¶
-
op_add(index)¶
-
op_and(index)¶
-
op_blend(index)¶
-
op_callgsubr(index)¶
-
op_callsubr(index)¶
-
op_cntrmask(index)¶
-
op_div(index)¶
-
op_drop(index)¶
-
op_dup(index)¶
-
op_endchar(index)¶
-
op_eq(index)¶
-
op_exch(index)¶
-
op_flex(index)¶
-
op_flex1(index)¶
-
op_get(index)¶
-
op_hflex(index)¶
-
op_hflex1(index)¶
-
op_hhcurveto(index)¶ dy1? {dxa dxb dyb dxc}+ hhcurveto
-
op_hintmask(index)¶
-
op_hlineto(index)¶
-
op_hmoveto(index)¶
-
op_hstem(index)¶
-
op_hstemhm(index)¶
-
op_hvcurveto(index)¶ dx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf?
-
op_ifelse(index)¶
-
op_ignore(index)¶
-
op_index(index)¶
-
op_load(index)¶
-
op_mul(index)¶
-
op_neg(index)¶
-
op_not(index)¶
-
op_or(index)¶
-
op_put(index)¶
-
op_random(index)¶
-
op_rcurveline(index)¶ {dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveline
-
op_return(index)¶
-
op_rlinecurve(index)¶ {dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurve
-
op_rlineto(index)¶
-
op_rmoveto(index)¶
-
op_roll(index)¶
-
op_rrcurveto(index)¶ {dxa dya dxb dyb dxc dyc}+ rrcurveto
-
op_sqrt(index)¶
-
op_store(index)¶
-
op_sub(index)¶
-
op_vhcurveto(index)¶ dy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto
-
op_vlineto(index)¶
-
op_vmoveto(index)¶
-
op_vsindex(index)¶
-
op_vstem(index)¶
-
op_vstemhm(index)¶
-
op_vvcurveto(index)¶ dx1? {dya dxb dyb dyc}+ vvcurveto
-
pop()¶
-
popall()¶
-
push(value)¶
-
rCurveTo(pt1, pt2, pt3)¶
-
rLineTo(point)¶
-
rMoveTo(point)¶
-
reset()¶
-
vcurveto(args)¶
-
-
class
fontTools.varLib.cff.CVarData(varDataList, masterSupports, vsindex_dict)¶ -
count(value, /)¶ Return number of occurrences of value.
-
index(value, start=0, stop=9223372036854775807, /)¶ Return first index of value.
Raises ValueError if the value is not present.
-
masterSupports¶ Alias for field number 1
-
varDataList¶ Alias for field number 0
-
vsindex_dict¶ Alias for field number 2
-
-
class
fontTools.varLib.cff.MergeOutlineExtractor(pen, localSubrs, globalSubrs, nominalWidthX, defaultWidthX, private=None)[source]¶ 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.
-
alternatingLineto(isHorizontal)¶
-
closePath()¶
-
endPath()¶
-
execute(charString)¶
-
hcurveto(args)¶
-
op_abs(index)¶
-
op_add(index)¶
-
op_and(index)¶
-
op_blend(index)¶
-
op_callgsubr(index)¶
-
op_callsubr(index)¶
-
op_div(index)¶
-
op_drop(index)¶
-
op_dup(index)¶
-
op_endchar(index)¶
-
op_eq(index)¶
-
op_exch(index)¶
-
op_flex(index)¶
-
op_flex1(index)¶
-
op_get(index)¶
-
op_hflex(index)¶
-
op_hflex1(index)¶
-
op_hhcurveto(index)¶ dy1? {dxa dxb dyb dxc}+ hhcurveto
-
op_hlineto(index)¶
-
op_hmoveto(index)¶
-
op_hvcurveto(index)¶ dx1 dx2 dy2 dy3 {dya dxb dyb dxc dxd dxe dye dyf}* dxf? {dxa dxb dyb dyc dyd dxe dye dxf}+ dyf?
-
op_ifelse(index)¶
-
op_ignore(index)¶
-
op_index(index)¶
-
op_load(index)¶
-
op_mul(index)¶
-
op_neg(index)¶
-
op_not(index)¶
-
op_or(index)¶
-
op_put(index)¶
-
op_random(index)¶
-
op_rcurveline(index)¶ {dxa dya dxb dyb dxc dyc}+ dxd dyd rcurveline
-
op_return(index)¶
-
op_rlinecurve(index)¶ {dxa dya}+ dxb dyb dxc dyc dxd dyd rlinecurve
-
op_rlineto(index)¶
-
op_rmoveto(index)¶
-
op_roll(index)¶
-
op_rrcurveto(index)¶ {dxa dya dxb dyb dxc dyc}+ rrcurveto
-
op_sqrt(index)¶
-
op_store(index)¶
-
op_sub(index)¶
-
op_vhcurveto(index)¶ dy1 dx2 dy2 dx3 {dxa dxb dyb dyc dyd dxe dye dxf}* dyf? vhcurveto (30) {dya dxb dyb dxc dxd dxe dye dyf}+ dxf? vhcurveto
-
op_vlineto(index)¶
-
op_vmoveto(index)¶
-
op_vsindex(index)¶
-
op_vvcurveto(index)¶ dx1? {dya dxb dyb dyc}+ vvcurveto
-
pop()¶
-
popall()¶
-
popallWidth(evenOdd=0)¶
-
push(value)¶
-
rCurveTo(pt1, pt2, pt3)¶
-
rLineTo(point)¶
-
rMoveTo(point)¶
-
reset()¶
-
vcurveto(args)¶
-
-
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.
-
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.