Beispiel #1
0
 def _processMathTwo(self, copiedGlyph, factor, ptFunc, func):
     # width
     copiedGlyph.width = func(self.width, factor[0])
     # height
     copiedGlyph.height = func(self.height, factor[1])
     # contours
     copiedGlyph.contours = []
     if self.contours:
         copiedGlyph.contours = _processMathTwoContours(
             self.contours, factor, ptFunc)
     # components
     copiedGlyph.components = []
     if self.components:
         copiedGlyph.components = _processMathTwoComponents(
             self.components,
             factor,
             ptFunc,
             scaleComponentTransform=self.scaleComponentTransform)
     # anchors
     copiedGlyph.anchors = []
     if self.anchors:
         copiedGlyph.anchors = _processMathTwoAnchors(
             self.anchors, factor, ptFunc)
     # guidelines
     copiedGlyph.guidelines = []
     if self.guidelines:
         copiedGlyph.guidelines = _processMathTwoGuidelines(
             self.guidelines, factor, func)
     # image
     if self.image:
         copiedGlyph.image = _processMathTwoImage(self.image, factor,
                                                  ptFunc)
Beispiel #2
0
 def _processMathTwo(self, copiedInfo, factor, func):
     # basic attributes
     for attr, (formatter, factorIndex) in _infoAttrs.items():
         if hasattr(copiedInfo, attr):
             v = getattr(copiedInfo, attr)
             if v is not None and factor is not None:
                 if factorIndex == 3:
                     v = self._processMathTwoAngle(v, factor, func)
                 else:
                     if isinstance(v, (list, tuple)):
                         v = self._processMathTwoNumberList(
                             v, factor[factorIndex], func)
                     else:
                         v = self._processMathTwoNumber(
                             v, factor[factorIndex], func)
             else:
                 v = None
             setattr(copiedInfo, attr, v)
     # special attributes
     self._processPostscriptWeightName(copiedInfo)
     # guidelines
     copiedInfo.guidelines = []
     if self.guidelines:
         copiedInfo.guidelines = _processMathTwoGuidelines(
             self.guidelines, factor, func)
 def test_processMathTwoGuidelines(self):
     guidelines = [
         dict(x=2, y=3, angle=5, name="test", identifier="1", color="0,0,0,0")
     ]
     expected = [
         dict(x=4, y=4.5, angle=3.75, name="test", identifier="1", color="0,0,0,0")
     ]
     result = _processMathTwoGuidelines(guidelines, (2, 1.5), mul)
     result[0]["angle"] = _roundNumber(result[0]["angle"], 2)
     self.assertEqual(result, expected)
 def test_processMathTwoGuidelines(self):
     guidelines = [
         dict(x=2,
              y=3,
              angle=5,
              name="test",
              identifier="1",
              color="0,0,0,0")
     ]
     expected = [
         dict(x=4,
              y=4.5,
              angle=3.75,
              name="test",
              identifier="1",
              color="0,0,0,0")
     ]
     result = _processMathTwoGuidelines(guidelines, (2, 1.5), mul)
     result[0]["angle"] = _roundNumber(result[0]["angle"], 2)
     self.assertEqual(result, expected)
 def _processMathTwo(self, copiedInfo, factor, func):
     # basic attributes
     for attr, (formatter, factorIndex) in _infoAttrs.items():
         if hasattr(copiedInfo, attr):
             v = getattr(copiedInfo, attr)
             if v is not None and factor is not None:
                 if factorIndex == 3:
                     v = self._processMathTwoAngle(v, factor, func)
                 else:
                     if isinstance(v, (list, tuple)):
                         v = self._processMathTwoNumberList(v, factor[factorIndex], func)
                     else:
                         v = self._processMathTwoNumber(v, factor[factorIndex], func)
             else:
                 v = None
             setattr(copiedInfo, attr, v)
     # special attributes
     self._processPostscriptWeightName(copiedInfo)
     # guidelines
     copiedInfo.guidelines = []
     if self.guidelines:
         copiedInfo.guidelines = _processMathTwoGuidelines(self.guidelines, factor, func)
Beispiel #6
0
 def _processMathTwo(self, copiedGlyph, factor, ptFunc, func):
     # width
     copiedGlyph.width = func(self.width, factor[0])
     # height
     copiedGlyph.height = func(self.height, factor[1])
     # contours
     copiedGlyph.contours = []
     if self.contours:
         copiedGlyph.contours = _processMathTwoContours(self.contours, factor, ptFunc)
     # components
     copiedGlyph.components = []
     if self.components:
         copiedGlyph.components = _processMathTwoComponents(self.components, factor, ptFunc)
     # anchors
     copiedGlyph.anchors = []
     if self.anchors:
         copiedGlyph.anchors = _processMathTwoAnchors(self.anchors, factor, ptFunc)
     # guidelines
     copiedGlyph.guidelines = []
     if self.guidelines:
         copiedGlyph.guidelines = _processMathTwoGuidelines(self.guidelines, factor, func)
     # image
     if self.image:
         copiedGlyph.image = _processMathTwoImage(self.image, factor, ptFunc)