varStore

fontTools.varLib.varStore.bit_count(self, /)

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
class fontTools.varLib.varStore.OnlineVarStoreBuilder(axisTags)[source]

Bases: object

setModel(model)[source]
setSupports(supports)[source]
finish(optimize=True)[source]
storeMasters(master_values, *, round=<built-in function round>)[source]
storeMastersMany(master_values_list, *, round=<built-in function round>)[source]
storeDeltas(deltas, *, round=<built-in function round>)[source]
storeDeltasMany(deltas_list, *, round=<built-in function round>)[source]
fontTools.varLib.varStore.VarData_addItem(self, deltas, *, round=<built-in function round>)[source]
fontTools.varLib.varStore.VarRegion_get_support(self, fvar_axes)[source]
fontTools.varLib.varStore.VarStore___bool__(self)[source]
class fontTools.varLib.varStore.VarStoreInstancer(varstore, fvar_axes, location={})[source]

Bases: object

Evaluate a VarStore’s deltas at a (mutable via setLocation) location.

Region supports are cached for the lifetime of the instancer: after mutating the store’s regions (or the fvar axes), construct a new instancer rather than reusing this one via setLocation.

setLocation(location)[source]
static interpolateFromDeltasAndScalars(deltas, scalars)[source]
interpolateFromDeltas(varDataIndex, deltas)[source]
fontTools.varLib.varStore.VarStore_subset_varidxes(self, varIdxes, optimize=True, retainFirstMap=False, advIdxes={}, *, VarData='VarData')[source]
fontTools.varLib.varStore.VarStore_prune_regions(self, *, VarData='VarData', VarRegionList='VarRegionList')[source]

Remove unused VarRegions.

fontTools.varLib.varStore.Object_collect_device_varidxes(self, varidxes)[source]
fontTools.varLib.varStore.Object_remap_device_varidxes(self, varidxes_map)[source]
fontTools.varLib.varStore.VarStore_optimize(self, use_NO_VARIATION_INDEX=True, quantization=1)[source]

Optimize storage. Returns mapping from old VarIdxes to new ones.

fontTools.varLib.varStore.VarStore_getExtremes(self, varIdx, fvarAxes, axisLimits, identityAxisIndex=None)[source]

Conservatively bound the value this VarStore produces for varIdx.

Returns (minV, maxV) in F2Dot14 delta units, guaranteed to cover the truly reachable range as the input axes vary over their extents: [-1, +1] per axis, or the [min, max] interval from axisLimits (a dict of axis tag to a (min, default, max, …) sequence) for axes listed there. If identityAxisIndex is not None, that axis’s own identity contribution (its coordinate, in F2Dot14 units) is added to the bound.

Before the final OpenType rounding, the produced value is piecewise multilinear in the axis coordinates (each region’s scalar is a product of independent per-axis tents), so over the box its exact extremes are attained at vertices of the grid formed by each axis’s tent breakpoints. One-sided tents (start == peak or peak == end) are discontinuous at their peak, so the grid also includes the adjacent F2Dot14 coordinate on the open side. When that grid is small enough (real fonts) it is enumerated and the result is exact; otherwise the result falls back to a per-region interval bound, which ignores correlations between regions and may be wider than the true range — never narrower. Callers use this to cull provably-unreachable variation data, so conservativeness is a soundness requirement, not a nicety. The fallback costs O(regions × axes); the cap on the exact path keeps crafted fonts from hanging the instancer.

Raw extrema are rounded only after summing the identity and delta terms, matching avar2 processing.

fontTools.varLib.varStore.main(args=None)[source]

Optimize a font’s GDEF variation store