Пример #1
0
 def apply_callback(self, sender):
     boolstring = [False, True]
     # source font
     _source_font_index = self.w._source_value.get()
     _source_font = self._all_fonts[_source_font_index]
     _source_font_name = self._all_fonts_names[_source_font_index]
     _source_mark = self.w.mark_source_checkbox.get()
     _source_mark_color = self.w.mark_source_color.get()
     _source_mark_color = (_source_mark_color.redComponent(),
             _source_mark_color.greenComponent(),
             _source_mark_color.blueComponent(),
             _source_mark_color.alphaComponent())
     # dest font
     _dest_font_index = self.w._dest_value.get()            
     _dest_font = self._all_fonts[_dest_font_index]
     _dest_font_name = self._all_fonts_names[_dest_font_index]
     _dest_mark = self.w.mark_dest_checkbox.get()
     _dest_mark_color = self.w.mark_dest_color.get()
     _dest_mark_color = (_dest_mark_color.redComponent(),
             _dest_mark_color.greenComponent(),
             _dest_mark_color.blueComponent(),
             _dest_mark_color.alphaComponent())
     # center
     _center = self.w.center_checkbox.get()
     # print info
     print 'copying widths...\n'
     print '\tsource font: %s' % _source_font_name
     print '\ttarget font: %s' % _dest_font_name
     print
     print '\tcenter: %s' % boolstring[_center]
     print
     # batch copy side-bearings
     for gName in _source_font.selection:
         try:
             # set undo
             _source_font[gName].prepareUndo('copy width')
             _dest_font[gName].prepareUndo('copy width')
             # copy
             print '\t%s' % gName,
             _dest_font[gName].width = _source_font[gName].width
             # center
             if _center:
                 centerGlyph(_dest_font[gName])
             # mark
             if _source_mark:
                 _source_font[gName].mark = _source_mark_color
                 _source_font[gName].update()
             if _dest_mark:
                 _dest_font[gName].mark = _dest_mark_color
                 _dest_font[gName].update()
             # call undo
             _dest_font.performUndo()
             _dest_font.update()
             _dest_font.performUndo()
             _dest_font.update()
         except:
             print '\tcannot process %s' % gName
     print
     print '\n...done.\n'
Пример #2
0
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         if len(f.selection) > 0:
             # get parameters
             _width = self.w.width_value.get()
             _mark = self.w.mark_checkbox.get()
             _mark_color = self.w.mark_color.get()
             _center = self.w.center_checkbox.get()
             _gNames = f.selection
             boolstring = (False, True)
             # print info
             print 'setting character widths...\n'
             print '\twidth: %s' % _width
             print '\tmark: %s' % boolstring[_mark]
             print '\tmark color: %s' % _mark_color
             print '\tcenter: %s' % boolstring[_center]
             print '\tglyphs: %s' % _gNames
             print
             # batch set width for glyphs
             _mark_color = (_mark_color.redComponent(),
                            _mark_color.greenComponent(),
                            _mark_color.blueComponent(),
                            _mark_color.alphaComponent())
             for gName in _gNames:
                 try:
                     f[gName].prepareUndo('set glyph width')
                     f[gName].width = int(_width)
                     if _center:
                         centerGlyph(f[gName])
                     if _mark:
                         f[gName].mark = _mark_color
                     f[gName].performUndo()
                     f[gName].update()
                 except:
                     print '\tcannot transform %s' % gName
                 # done
                 print
                 f.update()
                 print '...done.\n'
             # no glyph selected
         else:
             print 'please select one or more glyphs before running the script.\n'
     # no glyph selected
     else:
         print 'please open a font first.\n'
Пример #3
0
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         if len(f.selection) > 0:
             # get parameters
             _width = self.w.width_value.get()
             _mark = self.w.mark_checkbox.get()
             _mark_color = self.w.mark_color.get()
             _center = self.w.center_checkbox.get()
             _gNames = f.selection
             boolstring = (False, True)
             # print info
             print 'setting character widths...\n'
             print '\twidth: %s' % _width
             print '\tmark: %s' % boolstring[_mark]
             print '\tmark color: %s' % _mark_color
             print '\tcenter: %s' % boolstring[_center]
             print '\tglyphs: %s' % _gNames
             print         
             # batch set width for glyphs
             _mark_color = (_mark_color.redComponent(),
                 _mark_color.greenComponent(),
                 _mark_color.blueComponent(),
                 _mark_color.alphaComponent())
             for gName in _gNames:
                 try:
                     f[gName].prepareUndo('set glyph width')
                     f[gName].width = int(_width)
                     if _center:
                         centerGlyph(f[gName])
                     if _mark:
                         f[gName].mark = _mark_color
                     f[gName].performUndo()
                     f[gName].update()
                 except:
                     print '\tcannot transform %s' % gName
                 # done
                 print 
                 f.update()
                 print '...done.\n'
             # no glyph selected
         else:
             print 'please select one or more glyphs before running the script.\n'
     # no glyph selected
     else:
         print 'please open a font first.\n'
Пример #4
0
 def apply_callback(self, sender):
     boolstring = [False, True]
     # source font
     _source_font_index = self.w._source_value.get()
     _source_font = self._all_fonts[_source_font_index]
     _source_font_name = self._all_fonts_names[_source_font_index]
     _source_mark = self.w.mark_source_checkbox.get()
     _source_mark_color = self.w.mark_source_color.get()
     _source_mark_color = (
         _source_mark_color.redComponent(),
         _source_mark_color.greenComponent(),
         _source_mark_color.blueComponent(),
         _source_mark_color.alphaComponent(),
     )
     # dest font
     _dest_font_index = self.w._dest_value.get()
     _dest_font = self._all_fonts[_dest_font_index]
     _dest_font_name = self._all_fonts_names[_dest_font_index]
     _dest_mark = self.w.mark_dest_checkbox.get()
     _dest_mark_color = self.w.mark_dest_color.get()
     _dest_mark_color = (
         _dest_mark_color.redComponent(),
         _dest_mark_color.greenComponent(),
         _dest_mark_color.blueComponent(),
         _dest_mark_color.alphaComponent(),
     )
     # center
     _center = self.w.center_checkbox.get()
     # print info
     print "copying widths...\n"
     print "\tsource font: %s" % _source_font_name
     print "\ttarget font: %s" % _dest_font_name
     print
     print "\tcenter: %s" % boolstring[_center]
     print
     # batch copy side-bearings
     for gName in _source_font.selection:
         try:
             # set undo
             _source_font[gName].prepareUndo("copy width")
             _dest_font[gName].prepareUndo("copy width")
             # copy
             print "\t%s" % gName,
             _dest_font[gName].width = _source_font[gName].width
             # center
             if _center:
                 centerGlyph(_dest_font[gName])
             # mark
             if _source_mark:
                 _source_font[gName].mark = _source_mark_color
                 _source_font[gName].update()
             if _dest_mark:
                 _dest_font[gName].mark = _dest_mark_color
                 _dest_font[gName].update()
             # call undo
             _dest_font.performUndo()
             _dest_font.update()
             _dest_font.performUndo()
             _dest_font.update()
         except:
             print "\tcannot process %s" % gName
     print
     print "\n...done.\n"