def apply_callback(self, sender): self.font = CurrentFont() if self.font is not None: gNames = getGlyphs(self.font) if len(gNames) > 0: # print info if self._verbose: print 'rounding glyphs to grid...\n' print '\tgrid size: %s' % self._gridsize print '\tpoints: %s' % self._points print '\tanchors: %s' % self._anchors print '\tside-bearings: %s' % self._sidebearings print '\tmark: %s' % self._mark print print '\t', # batch process glyphs for gName in gNames: print gName, if self._points: roundPointsToGrid(self.font[gName], (self._gridsize, self._gridsize)) if self._anchors: roundAnchorsToGrid(self.font[gName], (self._gridsize, self._gridsize)) if self._sidebearings: roundMargins(self.font[gName], self._gridsize, left=True, right=True) if self._mark: self.font[gName].mark = self._mark_color self.font[gName].update() # done print self.font.update() if self._verbose: print '\n...done.\n' # no glyphs selected else: print 'no glyph to process, please select one or more glyphs and try again.\n' # no font open else: print 'please open a font and try again.\n'
def apply_Callback(self, sender): f = CurrentFont() if f is not None: print 'processing selected glyphs...\n' # get options boolstring = [False, True] _points = self.w._points_checkBox.get() _sidebearings = self.w._sidebearings_checkBox.get() _anchors = self.w._anchors_checkBox.get() # get color _gridsize = int(self.w._gridsize_value.get()) _mark = self.w._mark_checkBox.get() _mark_color = self.w._mark_color.get() _mark_color = (_mark_color.redComponent(), _mark_color.greenComponent(), _mark_color.blueComponent(), _mark_color.alphaComponent()) print '\tgrid size: %s' % _gridsize print '\talign points to grid: %s' % boolstring[_points] print '\talign side-bearings: %s' % boolstring[_sidebearings] print '\talign anchors: %s' % boolstring[_anchors] print '\tmark glyphs: %s (%s)' % (boolstring[_mark], _mark_color) print print '\t', # batch do stuff for gName in f.selection: print gName, f[gName].prepareUndo('align to grid') if _points: roundPointsToGrid(f[gName], (_gridsize, _gridsize)) if _anchors: roundAnchorsToGrid(f[gName], (_gridsize, _gridsize)) if _sidebearings: roundMargins(f[gName], _gridsize, left=True, right=True) if _mark: f[gName].mark = _mark_color f[gName].update() f[gName].performUndo() # done print f.update() print '\n...done.\n'