def _interpolate(self, factor, minKerning, maxKerning, round=True, suppressError=True): """ This is the environment implementation of :meth:`BaseKerning.interpolate`. * **factor** will be an :ref:`type-int-float`, ``tuple`` or ``list``. * **minKerning** will be a :class:`BaseKerning` object. * **maxKerning** will be a :class:`BaseKerning` object. * **round** will be a ``bool`` indicating if the interpolated kerning should be rounded. * **suppressError** will be a ``bool`` indicating if incompatible data should be ignored. Subclasses may override this method. """ import fontMath minKerning = fontMath.MathKerning(kerning=minKerning, groups=minKerning.font.groups) maxKerning = fontMath.MathKerning(kerning=maxKerning, groups=maxKerning.font.groups) result = interpolate(minKerning, maxKerning, factor) if round: result.round() self.clear() result.extractKerning(self.font)
def collect_kerning_masters( designspace: designspaceLib.DesignSpaceDocument, axis_bounds: AxisBounds) -> List[Tuple[Location, FontMathObject]]: """Return master kerning objects wrapped by MathKerning.""" # Always take the groups from the default source. This also avoids fontMath # making a union of all groups it is given. groups = designspace.default.font.groups locations_and_masters = [] for source in designspace.sources: if source.layerName is not None: continue # No kerning in source layers. # If a source has groups, they should match the default's. if source.font.groups and source.font.groups != groups: logger.warning( "The source %s (%s) contains different groups than the default source. " "The default source's groups will be used for the instances.", source.name, source.filename, ) # This assumes that groups of all sources are the same. normalized_location = varLib.models.normalizeLocation( source.location, axis_bounds) locations_and_masters.append( (normalized_location, fontMath.MathKerning(source.font.kerning, groups))) return locations_and_masters
def _interpolate(self, factor, minKerning, maxKerning, round=True, suppressError=True): """ This is the environment implementation of :meth:`BaseKerning.interpolate`. * **factor** will be an :ref:`type-int-float`, ``tuple`` or ``list``. * **minKerning** will be a :class:`BaseKerning` object. * **maxKerning** will be a :class:`BaseKerning` object. * **round** will be a ``bool`` indicating if the interpolated kerning should be rounded. * **suppressError** will be a ``bool`` indicating if incompatible data should be ignored. Subclasses may override this method. """ import fontMath from fontMath.mathFunctions import setRoundIntegerFunction setRoundIntegerFunction(normalizers.normalizeVisualRounding) kerningGroupCompatibility = self._testKerningGroupCompatibility( minKerning, maxKerning, suppressError=suppressError) if not kerningGroupCompatibility: self.clear() else: minKerning = fontMath.MathKerning(kerning=minKerning, groups=minKerning.font.groups) maxKerning = fontMath.MathKerning(kerning=maxKerning, groups=maxKerning.font.groups) result = interpolate(minKerning, maxKerning, factor) if round: result.round() self.clear() result.extractKerning(self.font)
def collect_kerning_masters( designspace: designspaceLib.DesignSpaceDocument, axis_bounds: AxisBounds) -> List[Tuple[Location, FontMathObject]]: """Return master kerning objects wrapped by MathKerning.""" locations_and_masters = [] for source in designspace.sources: if source.layerName is not None: continue # No kerning in source layers. # This assumes that groups of all sources are the same. normalized_location = varLib.models.normalizeLocation( source.location, axis_bounds) locations_and_masters.append(( normalized_location, fontMath.MathKerning(source.font.kerning, source.font.groups), )) return locations_and_masters