Ejemplo n.º 1
0
    def setPoint(self, key, value) :
        if value == None :
            (x, y) = (None, None)
        elif value == "" :
            (x, y) = (0, 0)
        else :
            try :
                (x, y) = map(int, re.split(r",\s*", value[1:-1]))
            except :
                popUpError("Please use the format (x, y).")

        self.setAnchor(key, x, y)
Ejemplo n.º 2
0
    def setPoint(self, key, value) :
        if value == None :
            (x, y) = (None, None)
        elif value == "" :
            (x, y) = (0, 0)
        else :
            try :
                (x, y) = map(int, re.split(r",\s*", value[1:-1]))
            except :
                popUpError("Please use the format (x, y).")

        self.setAnchor(key, x, y)
Ejemplo n.º 3
0
    def setUpPattern(self, glyphPattern, font):
        regexpPattern = ""
        glyphItems = glyphPattern.split(' ')

        for item in glyphItems:

            lastLetter = item[-1:]
            if lastLetter == "?" or lastLetter == "*" or lastLetter == "+":
                itemMod = lastLetter
                item = item[0:-1]
            else:
                itemMod = ""

            glyphNum = font.glyphWithGDLName(item)

            if item == "ANY":
                itemPattern = self._singleGlyphPattern()

            elif glyphNum >= 0:
                itemPattern = "<" + str(glyphNum) + ">"

            elif item in font.classes:
                classData = font.classes[item]
                itemPattern = "("
                sep = ""
                for classGlyph in classData.elements:
                    itemPattern += sep + "<" + str(classGlyph) + ">"
                    sep = "|"
                itemPattern += ")"

            else:
                self.pattern = ""
                popUpError("ERROR: '" + item +
                           "' is not a valid class or glyph name.")

                return

            if itemMod != "":
                if itemPattern[0:1] != "(":
                    itemPattern = "(" + itemPattern + ")" + "?"
                else:
                    itemPattern = itemPattern + "?"

            regexpPattern += itemPattern
        # end of for item loop

        self.pattern = regexpPattern
Ejemplo n.º 4
0
    def setUpPattern(self, glyphPattern, font) :
        regexpPattern = ""
        glyphItems = glyphPattern.split(' ')
               
        for item in glyphItems :
            
            lastLetter = item[-1:]
            if lastLetter == "?" or lastLetter == "*" or lastLetter == "+" :
                itemMod = lastLetter
                item = item[0:-1]
            else :
                itemMod = ""
                    
            glyphNum = font.glyphWithGDLName(item)
                    
            if item == "ANY" :
                itemPattern = self._singleGlyphPattern()
                
            elif glyphNum >= 0 :
                itemPattern = "<" + str(glyphNum) + ">"
                    
            elif item in font.classes :
                classData = font.classes[item]
                itemPattern = "("
                sep = ""
                for classGlyph in classData.elements :
                   itemPattern += sep + "<" + str(classGlyph) + ">"
                   sep = "|"
                itemPattern += ")"
                
            else :
                self.pattern = ""               
                popUpError("ERROR: '" + item + "' is not a valid class or glyph name.")

                return
            
            if itemMod != "" :
                if itemPattern[0:1] != "(" :
                    itemPattern = "(" + itemPattern + ")" + "?"
                else :
                    itemPattern = itemPattern + "?"

            regexpPattern += itemPattern
        # end of for item loop
                
        self.pattern = regexpPattern
Ejemplo n.º 5
0
    def addXML(self, parent) :
        try :
            e = et.SubElement(parent, 'test')
            if self.comment :
                c = et.SubElement(e, 'comment')
                c.text = self.comment
            t = et.SubElement(e, 'string')
            if self.text :
                t.text = re.sub(r'\\u([0-9A-Fa-f]{4})|\\U([0-9A-Fa-f]{5,8})', \
                    lambda m:unichr(int(m.group(1) or m.group(2), 16)), self.text)
            else :
                t.text = ""
            e.set('label', self.name)
            if self.background != QtGui.QColor('white') : 
                e.set('background', self.background.name())
            if self.rtl : e.set('rtl', 'True')
            if self.width != 100 : e.set('expand', str(self.width))
        except :
            popUpError(msg = "ERROR: test could not be saved: " + self.name)

        return e
Ejemplo n.º 6
0
    def addXML(self, parent):
        try:
            e = et.SubElement(parent, 'test')
            if self.comment:
                c = et.SubElement(e, 'comment')
                c.text = self.comment
            t = et.SubElement(e, 'string')
            if self.text:
                t.text = re.sub(r'\\u([0-9A-Fa-f]{4})|\\U([0-9A-Fa-f]{5,8})', \
                    lambda m:unichr(int(m.group(1) or m.group(2), 16)), self.text)
            else:
                t.text = ""
            e.set('label', self.name)
            if self.background != QtGui.QColor('white'):
                e.set('background', self.background.name())
            if self.rtl: e.set('rtl', 'True')
            if self.width != 100: e.set('expand', str(self.width))
        except:
            popUpError(msg="ERROR: test could not be saved: " + self.name)

        return e
Ejemplo n.º 7
0
 def addXML(self, parent) :
     try :
         e = XmlTree.SubElement(parent, 'tweak')
         if self.comment :
             c = XmlTree.SubElement(e, 'comment')
             c.text = self.comment
         t = XmlTree.SubElement(e, 'string')
         if self.text :
             t.text = re.sub(r'\\u([0-9A-Fa-f]{4})|\\U([0-9A-Fa-f]{5,8})', \
                 lambda m:unichr(int(m.group(1) or m.group(2), 16)), self.text)
         else :
             t.text = ""
         e.set('label', self.name)
         if self.background != QtGui.QColor('white') : 
             e.set('background', self.background.name())
         if self.rtl : e.set('rtl', 'True')
         if self.width != 100 : e.set('expand', str(self.width))
             
         gl = XmlTree.SubElement(e, 'glyphs')
         for twglyph in self.glyphs  :
             gf = XmlTree.SubElement(gl, 'glyph')
             gf.set('gid', str(twglyph.gid))
             gf.set('name', twglyph.name)
             if twglyph.gclass and twglyph.gclass != "" :
                 gf.set('class', twglyph.gclass)
             if twglyph.status and twglyph.status != "required" :
                 gf.set('status', twglyph.status)
             gf.set('shiftx', str(twglyph.shiftx))
             gf.set('shifty', str(twglyph.shifty))
             gf.set('shiftx-pending', str(twglyph.shiftx_pending))
             gf.set('shifty-pending', str(twglyph.shifty_pending))
             
     except :
         popUpError("ERROR: tweak could not be saved: " + self.name)
         
     return e