Exemplo n.º 1
0
    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
        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)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
 def _interpolate(self, factor, minInfo, maxInfo, round=True, suppressError=True):
     """
     Subclasses may override this method.
     """
     minInfo = minInfo._toMathInfo()
     maxInfo = maxInfo._toMathInfo()
     result = interpolate(minInfo, maxInfo, factor)
     if round:
         result = result.round()
     self._fromMathInfo(result)
Exemplo n.º 4
0
 def _interpolate(self, factor, minInfo, maxInfo, round=True, suppressError=True):
     """
     Subclasses may override this method.
     """
     minInfo = minInfo._toMathInfo()
     maxInfo = maxInfo._toMathInfo()
     result = interpolate(minInfo, maxInfo, factor)
     if result is None and not suppressError:
         raise FontPartsError(("Info from font '%s' and font '%s' could not be "
                               "interpolated.")
                              % (minInfo.font.name, maxInfo.font.name))
     if round:
         result = result.round()
     self._fromMathInfo(result)
Exemplo n.º 5
0
 def _interpolate(self, factor, minInfo, maxInfo, round=True, suppressError=True):
     """
     Subclasses may override this method.
     """
     minInfo = minInfo._toMathInfo()
     maxInfo = maxInfo._toMathInfo()
     result = interpolate(minInfo, maxInfo, factor)
     if result is None and not suppressError:
         raise FontPartsError(("Info from font '%s' and font '%s' could not be "
                               "interpolated.")
                              % (minInfo.font.name, maxInfo.font.name))
     if round:
         result = result.round()
     self._fromMathInfo(result)
Exemplo n.º 6
0
    def _interpolate(self,
                     factor,
                     minInfo,
                     maxInfo,
                     round=True,
                     suppressError=True):
        """
        Subclasses may override this method.
        """
        from fontMath.mathFunctions import setRoundIntegerFunction

        setRoundIntegerFunction(normalizers.normalizeVisualRounding)

        minInfo = minInfo._toMathInfo()
        maxInfo = maxInfo._toMathInfo()
        result = interpolate(minInfo, maxInfo, factor)
        if result is None and not suppressError:
            raise FontPartsError(
                ("Info from font '%s' and font '%s' could not be "
                 "interpolated.") % (minInfo.font.name, maxInfo.font.name))
        if round:
            result = result.round()
        self._fromMathInfo(result)
Exemplo n.º 7
0
    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)