def test_expandGuideline(self):
        guideline = dict(x=100, y=None, angle=None)
        self.assertEqual(sorted(_expandGuideline(guideline).items()),
                         [('angle', 90), ('x', 100), ('y', 0)])

        guideline = dict(y=100, x=None, angle=None)
        self.assertEqual(sorted(_expandGuideline(guideline).items()),
                         [('angle', 0), ('x', 0), ('y', 100)])
    def test_expandGuideline(self):
        guideline = dict(x=100, y=None, angle=None)
        self.assertEqual(
            sorted(_expandGuideline(guideline).items()),
            [('angle', 90), ('x', 100), ('y', 0)]
        )

        guideline = dict(y=100, x=None, angle=None)
        self.assertEqual(
            sorted(_expandGuideline(guideline).items()),
            [('angle', 0), ('x', 0), ('y', 100)]
        )
Exemple #3
0
 def __init__(self, glyph):
     self.contours = []
     self.components = []
     if glyph is None:
         self.anchors = []
         self.guidelines = []
         self.image = _expandImage(None)
         self.lib = {}
         self.name = None
         self.unicodes = None
         self.width = None
         self.height = None
         self.note = None
     else:
         p = MathGlyphPen(self)
         glyph.drawPoints(p)
         self.anchors = [dict(anchor) for anchor in glyph.anchors]
         self.guidelines = [_expandGuideline(guideline) for guideline in glyph.guidelines]
         self.image = _expandImage(glyph.image)
         self.lib = deepcopy(dict(glyph.lib))
         self.name = glyph.name
         self.unicodes = list(glyph.unicodes)
         self.width = glyph.width
         self.height = glyph.height
         self.note = glyph.note
Exemple #4
0
 def __init__(self, glyph):
     self.contours = []
     self.components = []
     if glyph is None:
         self.anchors = []
         self.guidelines = []
         self.image = _expandImage(None)
         self.lib = {}
         self.name = None
         self.unicodes = None
         self.width = None
         self.height = None
         self.note = None
     else:
         p = MathGlyphPen(self)
         glyph.drawPoints(p)
         self.anchors = [dict(anchor) for anchor in glyph.anchors]
         self.guidelines = [_expandGuideline(guideline) for guideline in glyph.guidelines]
         self.image = _expandImage(glyph.image)
         self.lib = deepcopy(dict(glyph.lib))
         self.name = glyph.name
         self.unicodes = list(glyph.unicodes)
         self.width = glyph.width
         self.height = glyph.height
         self.note = glyph.note
 def __init__(self, infoObject):
     for attr in _infoAttrs.keys():
         if hasattr(infoObject, attr):
             setattr(self, attr, getattr(infoObject, attr))
     if isinstance(infoObject, MathInfo):
         self.guidelines = [dict(guideline) for guideline in infoObject.guidelines]
     elif infoObject.guidelines is not None:
         self.guidelines = [_expandGuideline(guideline) for guideline in infoObject.guidelines]
     else:
         self.guidelines = []
Exemple #6
0
    def __init__(self, glyph, scaleComponentTransform=True):
        """Initialize a new MathGlyph object.

        Args:
            glyph: Input defcon or defcon-like Glyph object to copy from. Set to None to
                to make an empty MathGlyph.
            scaleComponentTransform (bool): when performing multiplication or division, by
                default all elements of a component's affine transformation matrix are
                multiplied by the given scalar. If scaleComponentTransform is False, then
                only the component's xOffset and yOffset attributes are scaled, whereas the
                xScale, xyScale, yxScale and yScale attributes are kept unchanged.
        """
        self.scaleComponentTransform = scaleComponentTransform
        self.contours = []
        self.components = []
        if glyph is None:
            self.anchors = []
            self.guidelines = []
            self.image = _expandImage(None)
            self.lib = {}
            self.name = None
            self.unicodes = None
            self.width = None
            self.height = None
            self.note = None
        else:
            p = MathGlyphPen(self)
            glyph.drawPoints(p)
            self.anchors = [dict(anchor) for anchor in glyph.anchors]
            self.guidelines = [
                _expandGuideline(guideline) for guideline in glyph.guidelines
            ]
            self.image = _expandImage(glyph.image)
            self.lib = deepcopy(dict(glyph.lib))
            self.name = glyph.name
            self.unicodes = list(glyph.unicodes)
            self.width = glyph.width
            self.height = glyph.height
            self.note = glyph.note