Example #1
0
def getProcessGlyphs(mode=0, font=None, workspace=None):
	'''Returns a list of glyphs for processing in TypeRig gui apps

	Args:
		mode (int): 0 - Current active glyph; 1 - All glyphs in current window; 2 - All selected glyphs; 3 - All glyphs in font
		font (fgFont) - Font file (object)
		workspace (flWorkspace) - Workspace
	
	Returns:
		list(eGlyph)
	'''
	# - Dependancies
	from typerig.glyph import eGlyph
	from typerig.proxy import pFont, pWorkspace

	# - Init
	process_glyphs = []
	active_workspace = pWorkspace()
	active_font = pFont(font)
		
	# - Collect process glyphs
	if mode == 0: process_glyphs.append(eGlyph())
	if mode == 1: process_glyphs = [eGlyph(glyph) for glyph in active_workspace.getTextBlockGlyphs()]
	if mode == 2: process_glyphs = active_font.selectedGlyphs(extend=eGlyph) 
	if mode == 3: process_glyphs = active_font.glyphs(extend=eGlyph)
	
	return process_glyphs
Example #2
0
    def tag_nodes(self, mode):
        # - Init
        new_name = self.edt_tagStringNode.text.strip()

        # - Helper
        def tag(glyph, newName):
            wLayers = glyph._prepareLayers(pLayers)

            for layer in wLayers:
                for node in glyph.selectedNodes(layer):
                    node.name = newName

            glyph.updateObject(
                glyph.fl,
                'Glyph: %s; Nodes named: %s ' % (glyph.name, new_name))
            glyph.update()

        # - Process
        if mode == 'G':
            glyph = eGlyph()
            tag(glyph, new_name)

        elif mode == 'W':
            process_glyphs = []
            process_glyphs = [
                eGlyph(glyph) for glyph in pWorkspace().getTextBlockGlyphs()
            ]

            for glyph in process_glyphs:
                tag(glyph, new_name)
Example #3
0
    def refresh(self):
        # - Init
        layerBanList = ['#', 'img']
        self.glyph = eGlyph()

        # - Prepare
        self.edt_glyphName.setText(eGlyph().name)
        self.selection = self.glyph.layer().name
        self.lst_layers.clear()

        # - Build List and style it
        self.lst_layers.addItems(
            sorted([
                layer.name for layer in self.glyph.layers()
                if all([item not in layer.name for item in layerBanList])
            ]))

        for index in range(self.lst_layers.count):
            currItem = self.lst_layers.item(index)
            currLayer = self.glyph.layer(currItem.text())

            control = (currLayer.isService, currLayer.isMasterLayer,
                       currLayer.isMaskLayer, currLayer.isWireframe)
            controlColor = [int(item) * 255 for item in control[:-1]
                            ] + [150 - int(control[-1]) * 100]
            text = 'Service Master Mask Wireframe'.split(' ')
            controlText = ' | '.join(
                [text[pos] for pos in range(len(text)) if control[pos]])

            currItem.setData(QtCore.Qt.DecorationRole,
                             QtGui.QColor(*controlColor))
            currItem.setData(QtCore.Qt.ToolTipRole, controlText)
Example #4
0
    def eqContour(self, method):
        glyph = eGlyph()
        selection = glyph.selected(True)
        wLayers = glyph._prepareLayers(pLayers)

        for layer in wLayers:
            # !!! Fixed the problem, but with too many loops - rethink
            nodes_fl = [glyph.nodes(layer)[nid] for nid in selection]
            nodes = [eNode(node) for node in nodes_fl]
            conNodes = [node for node in nodes if node.getNextOn() in nodes_fl]
            segmentNodes = [node.getSegmentNodes() for node in conNodes]

            for segment in reversed(segmentNodes):
                if len(segment) == 4:
                    wSegment = eCurveEx(segment)

                    if method is 'tunni':
                        wSegment.eqTunni()

                    elif method is 'hobby':
                        curvature = (float(self.spn_hobby0.value),
                                     float(self.spn_hobby1.value))
                        wSegment.eqHobbySpline(curvature)

                    elif method is 'prop':
                        proportion = float(self.spn_prop.value)
                        wSegment.eqProportionalHandles(proportion)

        glyph.updateObject(glyph.fl,
                           'Optimize %s @ %s.' % (method, '; '.join(wLayers)))
        glyph.update()
Example #5
0
    def drop_guide_V(self):
        glyph = eGlyph()
        wLayers = glyph._prepareLayers(pLayers)
        italicAngle = 0  #glyph.package.italicAngle_value

        for layerName in wLayers:
            if 'BBox' in self.cmb_select_V.currentText:
                width = glyph.layer(layerName).boundingBox.width()
                origin = glyph.layer(layerName).boundingBox.x()

            elif 'Adv' in self.cmb_select_V.currentText:
                width = glyph.getAdvance(layerName)
                origin = 0.

            #print width, origin , width + origin, float(width)*self.spb_prc_V.value/100 + origin

            guidePos = (float(width) * self.spb_prc_V.value / 100 + origin +
                        self.spb_unit_V.value, 0)
            glyph.addGuideline(guidePos,
                               layer=layerName,
                               angle=italicAngle,
                               name=self.edt_guideName.text,
                               tag=self.edt_guideTag.text,
                               color=self.cmb_select_color.currentText)

        glyph.updateObject(
            glyph.fl,
            'Drop Guide <%s> @ %s.' % (self.edt_guideName.text, '; '.join(
                glyph._prepareLayers(pLayers))))
        glyph.update()
Example #6
0
    def tag_glyphs(self, mode):
        # - Init
        new_tags = self.edt_tagString.text.replace(' ', '').split(',')

        # - Helper
        def tag(glyph, tagList):
            glyph.setTags(tagList)
            glyph.updateObject(
                glyph.fl, 'Glyph: %s; Add tags: %s ' % (glyph.name, tagList))
            glyph.update()

        # - Process
        if mode == 'G':
            glyph = eGlyph()
            tag(glyph, new_tags)

        else:
            process_glyphs = []

            if mode == 'W':
                process_glyphs = [
                    pGlyph(glyph)
                    for glyph in pWorkspace().getTextBlockGlyphs()
                ]

            elif mode == 'S':
                process_glyphs = pFont().selected_pGlyphs()

            for glyph in process_glyphs:
                tag(glyph, new_tags)

        self.edt_tagString.clear()
Example #7
0
    def refresh(self):
        # - Init
        self.glyph = eGlyph()
        self.wLayers = self.glyph._prepareLayers(pLayers)

        # - Prepare
        self.wAnchors = {}
        self.wAnchorNames = []
        for layer in self.wLayers:
            currAnchors = self.glyph.anchors(layer)
            self.wAnchors[layer] = currAnchors
            self.wAnchorNames.append([anchor.name for anchor in currAnchors])

        self.edt_glyphName.setText(self.glyph.name)
        self.lst_anchors.clear()

        # - Build List and style it
        self.lst_anchors.addItems(list(set(sum(self.wAnchorNames, []))))

        for index in range(self.lst_anchors.count):
            currItem = self.lst_anchors.item(index)

            checkLayers = [
                currItem.text() in name for name in self.wAnchorNames
            ]
            layer_order = 'Layer Order: ' + ', '.join(self.wLayers)
            toolTip = 'Anchor present in all selected layers.\n\n' + layer_order if all(
                checkLayers
            ) else 'Anchor NOT present in all selected layers.\n\n' + layer_order

            currItem.setData(
                QtCore.Qt.DecorationRole,
                QtGui.QColor('LimeGreen' if all(checkLayers) else 'Crimson'))
            currItem.setData(QtCore.Qt.ToolTipRole, toolTip)
Example #8
0
    def setFontMetrics(self, metricName):
        glyph = eGlyph()
        wLayers = glyph._prepareLayers(pLayers)

        for layer in wLayers:
            if self.btn_togSelection.isChecked():
                selection = glyph.selectedNodes(layer)

                if len(selection):
                    glyph.package.setMaster(layer)
                    exec('glyph.package.%s_value = selection[0].y' %
                         metricName)

            if self.btn_togBBOX.isChecked():
                glyph.package.setMaster(layer)
                bbox_layer = glyph.layer(layer).boundingBox

                if metricName in ['ascender', 'capsHeight', 'xHeight']:
                    exec(
                        'glyph.package.%s_value = int(bbox_layer.y() + bbox_layer.height())'
                        % metricName)

                elif metricName == 'descender':
                    glyph.package.descender_value = int(bbox_layer.y())

        self.btn_togSelection.setChecked(False)
        self.btn_togBBOX.setChecked(False)

        glyph.update()
        glyph.updateObject(
            glyph.package,
            'Set Font Metrics: %s @ %s.' % (metricName, '; '.join(wLayers)))
Example #9
0
 def _addCustomMenuItems(self, menu):
     menu.addSeparator()
     menu.addAction(u'{Glyph Name}', lambda: self.setText(eGlyph().name))
     menu.addAction(u'_part', lambda: self.smartSetText('_part'))
     menu.addAction(u'_UC', lambda: self.smartSetText('_UC'))
     menu.addAction(u'_LC', lambda: self.smartSetText('_LC'))
     menu.addAction(u'_LAT', lambda: self.smartSetText('_LAT'))
     menu.addAction(u'_CYR', lambda: self.smartSetText('_CYR'))
Example #10
0
    def hobby_get(self):
        glyph = eGlyph()
        selSegment = eCurveEx(
            eNode(glyph.selectedNodes()[0]).getSegmentNodes())
        c0, c1 = selSegment.curve.getHobbyCurvature()

        self.spn_hobby0.setValue(c0.real)
        self.spn_hobby1.setValue(c1.real)
Example #11
0
    def refresh(self, layer=None):
        # - Init
        self.glyph = eGlyph()
        self.edt_glyphName.setText(eGlyph().name)

        self.table_dict = {}
        node_count = 0

        # - Populate layers
        if layer is None:
            self.layer_names = [
                item.name for item in self.glyph.layers()
                if '#' not in item.name
            ]
            self.cmb_layer.clear()
            self.cmb_layer.addItems(self.layer_names)
            self.cmb_layer.setCurrentIndex(
                self.layer_names.index(self.glyph.activeLayer().name))

        # - Populate table
        try:  # Dirty Quick Fix - Solve later
            for sID, shape in enumerate(self.glyph.shapes(layer)):
                for cID, contour in enumerate(shape.contours):
                    for nID, node in enumerate(contour.nodes()):

                        table_values = [
                            node_count, sID, cID,
                            round(node.x, 2),
                            round(node.y, 2), node.type,
                            round(eNode(node).distanceToPrev(), 2)
                        ]

                        self.table_dict[node_count] = OrderedDict(
                            zip(self.table_columns, table_values))
                        node_count += 1

            self.tab_nodes.setTable(self.table_dict, (False, False))
            self.tab_nodes.resizeColumnsToContents()

        except AttributeError:
            pass
Example #12
0
	def removeNode(self):
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)

		'''
		selection = glyph.selectedAtContours()
		for layer in wLayers:
			for cID, nID in reversed(selection):
				glyph.removeNodeAt(cID, nID, layer)
				glyph.contours(layer)[cID].updateIndices()

				#glyph.contours()[cID].clearNodes()
		'''
		
		# Kind of working
		for layer in wLayers:
			selection = glyph.selectedAtContours(False, layer)

			for contour, node in reversed(selection):
				prevNode, nextNode = node.prevNode(), node.nextNode()
				
				if not prevNode.isOn:
					contour.removeOne(prevNode)
			
				if not nextNode.isOn:
					contour.removeOne(nextNode)

				contour.removeOne(node)	
				contour.updateIndices()
		
		'''
		# - Not Working Again!
		from typerig.utils import groupConsecutives		
		selection = glyph.selectedAtContours()
		tempDict = {}

		for cID, nID in selection:
			tempDict.setdefault(cID, []).append(nID)

		for layer in wLayers:
			for cID, nIDlist in tempDict.iteritems():
				nidList = groupConsecutives(nIDlist)

				for pair in reversed(nidList):
					
					nodeA = eNode(glyph.contours(layer)[cID].nodes()[pair[-1] if len(pair) > 1 else pair[0]]).getNextOn()
					nodeB = eNode(glyph.contours(layer)[cID].nodes()[pair[0]]).getPrevOn()

					glyph.contours(layer)[cID].removeNodesBetween(nodeB, nodeA)
									
		'''
		glyph.update()
		glyph.updateObject(glyph.fl, 'Delete Node @ %s.' %'; '.join(wLayers))
Example #13
0
 def drop_guide_nodes(self, flip):
     glyph = eGlyph()
     glyph.dropGuide(layers=pLayers,
                     name=self.edt_guideName.text,
                     tag=self.edt_guideTag.text,
                     color=self.cmb_select_color.currentText,
                     flip=flip)
     glyph.updateObject(
         glyph.fl,
         'Drop Guide <%s> @ %s.' % (self.edt_guideName.text, '; '.join(
             glyph._prepareLayers(pLayers))))
     glyph.update()
Example #14
0
	def closeContour(self):
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)
		selection = glyph.selectedAtContours()

		for layerName in wLayers:
			contours = glyph.contours(layerName)

			for cID, nID in reversed(selection):
				if not contours[cID].closed: contours[cID].closed = True

		glyph.updateObject(glyph.fl, 'Close Contour @ %s.' %'; '.join(wLayers))
		glyph.update()
Example #15
0
    def refresh(self):
        # - Init
        self.a_data = []
        self.glyph = eGlyph()
        self.wLayers = self.glyph._prepareLayers(pLayers)

        # - Prepare
        self.a_data.append(((self.glyph.name, self.wLayers),
                            [(layer, anchor.name) for layer in self.wLayers
                             for anchor in self.glyph.anchors(layer)]))
        self.tree_anchors.clear()
        self.tree_anchors.setTree((self.columns, self.a_data))
        '''
Example #16
0
	def insertNode(self):
		glyph = eGlyph()
		selection = glyph.selectedAtContours(True)
		wLayers = glyph._prepareLayers(pLayers)

		for layer in wLayers:
			nodeMap = glyph._mapOn(layer)
			
			for cID, nID in reversed(selection):
				glyph.insertNodeAt(cID, nodeMap[cID][nID] + float(self.edt_time.text), layer)

		glyph.updateObject(glyph.fl, 'Insert Node @ %s.' %'; '.join(wLayers))
		glyph.update()
Example #17
0
    def get_coordArrays(self):
        glyph = eGlyph()
        self.data_coordArrays.update({
            glyph.name: {
                master_name: glyph._getCoordArray(master_name)
                for master_name in self.active_font.masters()
            }
        })

        self.cmb_infoArrays.clear()
        self.cmb_infoArrays.addItems(sorted(self.data_coordArrays.keys()))

        print 'Done:\t| Delta Machine | Updated CoordArrays.\tGlyph:%s' % glyph.name
Example #18
0
	def pasteSlope(self, mode):
		from typerig.brain import Line
		
		if self.btn_copy.isChecked() or self.btn_italic.isChecked():
			glyph = eGlyph()
			wLayers = glyph._prepareLayers(pLayers)
			italicAngle = glyph.package.italicAngle_value
			control = (True, False)
			
			for layer in wLayers:
				selection = [eNode(node) for node in glyph.selectedNodes(layer)]
				srcLine = self.copyLine[layer] if not self.btn_italic.isChecked() else None

				if mode == 'MinY':
					dstLine = Line(min(selection, key=lambda item: item.y).fl, max(selection, key=lambda item: item.y).fl)
					
					if not self.btn_italic.isChecked():
						dstLine.slope = srcLine.getSlope()
					else:
						dstLine.setAngle(-1*italicAngle)

				elif mode == 'MaxY':
					dstLine = Line(max(selection, key=lambda item: item.y).fl, min(selection, key=lambda item: item.y).fl)
					
					if not self.btn_italic.isChecked():
						dstLine.slope = srcLine.getSlope()
					else:
						dstLine.setAngle(-1*italicAngle)

				elif mode == 'FLMinY':
					dstLine = Line(min(selection, key=lambda item: item.y).fl, max(selection, key=lambda item: item.y).fl)
					
					if not self.btn_italic.isChecked():
						dstLine.slope = -1.*srcLine.getSlope()
					else:
						dstLine.setAngle(italicAngle)

				elif mode == 'FLMaxY':
					dstLine = Line(max(selection, key=lambda item: item.y).fl, min(selection, key=lambda item: item.y).fl)
					
					if not self.btn_italic.isChecked():
						dstLine.slope = -1.*srcLine.getSlope()
					else:
						dstLine.setAngle(italicAngle)
				
				for node in selection:
					node.alignTo(dstLine, control)

			glyph.updateObject(glyph.fl, 'Paste Slope @ %s.' %'; '.join(wLayers))
			glyph.update()
Example #19
0
	def cornerTrap(self):
		from typerig.node import eNode
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)
		parameters = tuple([float(value.strip()) for value in self.edt_trap.text.split(',')])
		
		for layer in wLayers:
			selection = glyph.selectedNodes(layer, filterOn=True, extend=eNode, deep=True)
			
			for node in reversed(selection):
				node.cornerTrapInc(*parameters)

		glyph.update()
		glyph.updateObject(glyph.fl, '%s @ %s.' %('Trap Corner', '; '.join(wLayers)))
Example #20
0
    def get_ratio(self, target=False):
        glyph = eGlyph()
        if target:
            self.ratio_target = {
                layerName: glyph.getBounds(layerName)
                for layerName in self.active_font.masters()
            }
        else:
            self.ratio_source = {
                layerName: glyph.getBounds(layerName)
                for layerName in self.active_font.masters()
            }

        print 'Done:\t| Delta Machine | Stored BBOX data for Glyph: %s' % glyph.name
Example #21
0
	def capture(self):
		# - Init
		process_angles = {}
		active_workspace = pWorkspace()
		
		# - Rebuild
		self.__clear()
		self.__build()
				
		# - Collect process glyphs
		if pMode == 0: self.process_glyphs.append(eGlyph()) # Current Active Glyph
		if pMode == 1: self.process_glyphs = [eGlyph(glyph) for glyph in active_workspace.getTextBlockGlyphs()] # All glyphs in current window
		if pMode == 2: self.process_glyphs = self.active_font.selectedGlyphs(extend=eGlyph) # Selected glyphs in font window
		if pMode > 2: return

		# - Get nodes grouped by smart angle value
		if len(self.process_glyphs):
			for glyph in self.process_glyphs:
				#wLayers = glyph._prepareLayers(pLayers)
				layer = None
				pNodes = glyph.nodes(layer=layer, extend=pNode)
				
				for node in pNodes:
					smart_angle = node.getSmartAngle()
					
					if smart_angle[0]:
						process_angles.setdefault(smart_angle[1], []).append(node)

		# - Build sliders
		for angle_value, angle_nodes in process_angles.iteritems():
			new_slider = trSliderCtrl('0', '100', angle_value, 5)
			new_slider.sld_axis.valueChanged.connect(self.__processNodes)
			self.addLayout(new_slider)
			self.sliders.append([new_slider, angle_value, angle_nodes])

		# - Set undo snapshot
		self.update_glyphs(self.process_glyphs, True)
Example #22
0
    def refresh(self):
        # - Init
        layerBanList = ['#', 'img']
        self.glyph = eGlyph()
        self.head.edt_glyphName.setText(eGlyph().name)
        self.italic_angle = pFont().getItalicAngle()

        self.layers = sorted([
            layer.name for layer in self.glyph.layers()
            if all([item not in layer.name for item in layerBanList])
        ])

        self.head.cmb_0.clear()
        self.head.cmb_1.clear()
        self.head.cmb_0.addItems(self.layers)
        self.head.cmb_1.addItems(self.layers)
        self.head.cmb_0.setCurrentIndex(0)
        self.head.cmb_1.setCurrentIndex(0)
        self.axis = []

        self.head.edt_stemV0.setText('1')
        self.head.edt_stemV1.setText('2')
        self.head.edt_stemH0.setText('1')
        self.head.edt_stemH1.setText('2')

        self.tail.edt_width_0.clear()
        self.tail.edt_width_1.clear()
        self.tail.edt_width_t.clear()
        self.tail.edt_height_0.clear()
        self.tail.edt_height_1.clear()
        self.tail.edt_height_t.clear()

        self.mixer_dx.reset()
        self.mixer_dy.reset()
        self.scaler_dx.reset()
        self.scaler_dy.reset()
Example #23
0
def dropAnchors(glyph, control):
    # - Init
    work_name = glyph.name.split('.')[0]

    # - Process
    if work_name in control.keys():

        work_glyph = eGlyph(font.fg, glyph)
        #work_glyph.clearAnchors(work_layer)

        for ctr_tuple in control[work_name]:
            work_glyph.dropAnchor(*ctr_tuple)

        work_glyph.update()
        work_glyph.updateObject(work_glyph.fl,
                                'Drop anchors: %s.' % work_glyph.name)
Example #24
0
	def convertHobby(self):
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)
		selection = glyph.selected()

		for layerName in wLayers:
			pNodes = [glyph.nodes(layerName)[nID] for nID in selection]
			
			for node in pNodes:
				if not node.hobby:
					node.hobby = True
				else:
					node.hobby = False
				node.update()

		glyph.updateObject(glyph.fl, 'Convert to Hobby @ %s.' %'; '.join(wLayers))
		glyph.update()
Example #25
0
    def drop_guide_H(self):
        glyph = eGlyph()
        wLayers = glyph._prepareLayers(pLayers)
        italicAngle = 0  #glyph.package.italicAngle_value

        for layerName in wLayers:
            metrics = pFontMetrics(glyph.package)

            if 'BBox' in self.cmb_select_H.currentText:
                height = glyph.layer(layerName).boundingBox.height()
                origin = glyph.layer(layerName).boundingBox.y()

            elif 'Adv' in self.cmb_select_H.currentText:
                height = glyph.layer(layerName).advanceHeight
                origin = 0.

            elif 'X-H' in self.cmb_select_H.currentText:
                height = metrics.getXHeight(layerName)
                origin = 0.

            elif 'Caps' in self.cmb_select_H.currentText:
                height = metrics.getCapsHeight(layerName)
                origin = 0.

            elif 'Ascender' in self.cmb_select_H.currentText:
                height = metrics.getAscender(layerName)
                origin = 0.

            elif 'Descender' in self.cmb_select_H.currentText:
                height = metrics.getDescender(layerName)
                origin = 0.

            guidePos = (0, float(height) * self.spb_prc_H.value / 100 +
                        origin + self.spb_unit_H.value)
            glyph.addGuideline(guidePos,
                               layer=layerName,
                               angle=90,
                               name=self.edt_guideName.text,
                               tag=self.edt_guideTag.text,
                               color=self.cmb_select_color.currentText)

        glyph.updateObject(
            glyph.fl,
            'Drop Guide <%s> @ %s.' % (self.edt_guideName.text, '; '.join(
                glyph._prepareLayers(pLayers))))
        glyph.update()
Example #26
0
    def table_execute(self):
        wGlyph = eGlyph()
        process_out = []

        for layerIndex in range(self.tab_masters.rowCount):
            if self.tab_masters.item(layerIndex,
                                     0).checkState() == QtCore.Qt.Checked:
                process_out.append(self.tab_masters.item(layerIndex, 0).text())
                self.process_scale(wGlyph,
                                   layerIndex,
                                   anisotropic=self.chk_single.isChecked(),
                                   live_update=False)

        wGlyph.update()
        wGlyph.updateObject(
            wGlyph.fl, '| Delta Machine | Glyph: %s\tLayers procesed: %s' %
            (wGlyph.name, '; '.join(process_out)))
Example #27
0
	def copySlope(self):
		from typerig.brain import Line

		if self.btn_copy.isChecked():
			self.btn_copy.setText('Reset Slope')
			self.btn_italic.setChecked(False)

			glyph = eGlyph()
			wLayers = glyph._prepareLayers(pLayers)
			
			for layer in wLayers:
				selection = glyph.selectedNodes(layer)
				self.copyLine[layer] = Line(selection[0], selection[-1])
				#print self.copyLine[layer].getAngle(), self.copyLine[layer].getSlope()
		else:
			self.btn_copy.setText('Copy Slope')
			self.btn_italic.setChecked(False)
Example #28
0
	def getBuilder(self):
		if self.btn_getBuilder.isChecked():
			if len(self.edt_glyphName.text):
				builder_glyph = self.active_font.glyph(self.edt_glyphName.text)
			else:
				builder_glyph = eGlyph()
				self.edt_glyphName.setText(builder_glyph.name)

			if builder_glyph is not None:
				temp_builder = builder_glyph.getBuilders()

				if len(temp_builder.keys()) and filter_name in temp_builder.keys():
					self.builder = temp_builder[filter_name][0]
					self.btn_getBuilder.setText('Release')
		else:
			self.builder = None
			self.edt_glyphName.clear()
			self.btn_getBuilder.setText('Set Builder')	
Example #29
0
	def cornerMitre(self, doKnot=False):
		from typerig.node import eNode
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)
		
		for layer in wLayers:
			selection = glyph.selectedNodes(layer, filterOn=True, extend=eNode, deep=True)
			
			for node in reversed(selection):
				if not doKnot:
					node.cornerMitre(float(self.edt_radius.text))
				else:
					node.cornerMitre(-float(self.edt_radius.text), True)


		action = 'Mitre Corner' if not doKnot else 'Overlap Corner'
		glyph.update()
		glyph.updateObject(glyph.fl, '%s @ %s.' %(action, '; '.join(wLayers)))
Example #30
0
	def cornerRebuild(self):
		from typerig.node import eNode
		glyph = eGlyph()
		wLayers = glyph._prepareLayers(pLayers)
		
		for layer in wLayers:
			selection = glyph.selectedNodes(layer, filterOn=True, extend=eNode, deep=True)
			
			if len(selection) > 1:
				node_first = selection[0]
				node_last = selection[-1]
				
				line_in = node_first.getPrevLine() if node_first.getPrevOn(False) not in selection else node_first.getNextLine()
				line_out = node_last.getNextLine() if node_last.getNextOn(False) not in selection else node_last.getPrevLine()

				crossing = line_in & line_out

				node_first.smartReloc(*crossing)
				node_first.parent.removeNodesBetween(node_first.fl, node_last.getNextOn())

		glyph.update()
		glyph.updateObject(glyph.fl, 'Rebuild corner: %s nodes reduced; At layers: %s' %(len(selection), '; '.join(wLayers)))