예제 #1
0
 def _paint_callback(self, sender):
     _crop = self.w.crop_glyphset.get()
     print 'painting groups in font...\n'
     font = hFont(CurrentFont())
     font.order_glyphs()
     font.paint_groups(crop=_crop)
     print '...done.\n'
예제 #2
0
 def test_install_callback(self, sender):
     ufo = CurrentFont()
     if ufo is not None:
         font = hFont(ufo)
         print 'test installing %s...' % font.full_name()
         font.ufo.testInstall()
         print '\n\n...done.\n'
     else:
         print 'please open a font first.\n'
예제 #3
0
 def generate_otf_callback(self, sender):
     ufo = CurrentFont()
     if ufo is not None:
         font = hFont(ufo)
         boolstring = [ False, True ]
         boolstring2 = [ 'No', 'Yes' ]
         self._decompose = self.w._decompose.get()
         self._remove_overlap = self.w._remove_overlap.get()
         self._autohint = self.w._autohint.get()
         self._release_mode = self.w._release_mode.get()
         self._generate_woff = self.w._generate_woff.get()
         self._upload_woff = self.w._upload_woff.get()
         # make otf path
         self._otfs_path = self.w._otfs_path.get()
         if self._otfs_path is 0:
             otf_path = font.otf_path()
         else:
             otf_path = font.otf_path(test=True)
         # print generation info
         print 'generating .otf for %s...\n' % font.full_name()
         print '\tdecompose: %s' % boolstring[self._decompose]
         print '\tremove overlap: %s' % boolstring[self._remove_overlap]
         print '\tautohint: %s' % boolstring[self._autohint]
         print '\trelease mode: %s' % boolstring[self._release_mode]
         print '\tfont path: %s' % otf_path
         print '\tgenerate woff: %s' % boolstring[self._generate_woff]
         print '\tupload woff: %s' % boolstring[self._upload_woff]
         print
         font.ufo.generate(otf_path, 'otf',
                     decompose=self._decompose,
                     autohint=self._autohint,
                     checkOutlines=self._remove_overlap,
                     releaseMode=self._release_mode,
                     glyphOrder=[])
         _generated_otf = os.path.exists(otf_path)
         print '\tgeneration succesfull? %s' % boolstring2[_generated_otf]
         if _generated_otf:
             if self._generate_woff:
                 print '\tgenerating .woff...'
                 font.generate_woff()
                 _generated_woff = os.path.exists(otf_path)
                 print '\tgeneration succesfull? %s' % boolstring2[_generated_woff]
                 if _generated_woff:
                     if self._upload_woff:
                         print '\tuploading .woff to ftp...'
                         font.upload_woff()
         print
         print '...done.\n'
     else:
         print 'please open a font first.\n'
예제 #4
0
 def _import_callback(self, sender):
     print 'importing groups from project...\n'
     font = hFont(CurrentFont())
     font.import_groups_from_encoding()
     print '...done.\n'
예제 #5
0
 def actions_callback(self, sender):
     '''Apply batch actions to selected fonts in project.'''
     # get fonts and actions
     _fonts = self.get_font_selection()
     _actions = self.get_actions(self._actions_checkboxes)
     # apply actions to fonts
     if len(_fonts) > 0:
         self.w.bar.start()
         print 'batch processing selected fonts...\n'
         for font_path in _fonts:
             family, style = get_names_from_path(font_path)
             print '\tprocessing %s %s...\n' % (family, style)
             #---------------------------------
             _action = 'open window'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\topening font window...'
                     font = hFont(RFont(font_path, showUI=True))
                 else:
                     print '\t\topening font...'
                     font = hFont(RFont(font_path, showUI=False))
             #---------------------------------
             _action = 'build accents'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tbuilding accents...'
                     font.build_accents()
             #---------------------------------
             _action = 'build composed'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tbuilding composed glyphs...'
                     font.build_composed()
             #---------------------------------
             _action = 'clear features'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tremoving features...'
                     font.clear_features()
             #---------------------------------
             _action = 'import features'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\timporting features...'
                     font.import_features()
             #---------------------------------
             _action = 'import kerning'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\timporting kerning...'
                     font.import_kern_feature()
             #---------------------------------
             _action = 'set font info'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tsetting font info...'
                     font.set_info()
             #---------------------------------
             _action = 'set foundry info'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tsetting foundry info... [empty]'
             #---------------------------------
             _action = 'set vmetrics'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tsetting vertical metrics...'
                     font.set_vmetrics(verbose=False)
             #---------------------------------
             _action = 'clear colors'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tclear colors...'
                     clear_colors(font.ufo)
             #---------------------------------
             _action = 'create glyphs'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tcreating glyphs...'
                     font.create_glyphs()
             #---------------------------------
             _action = 'import groups'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\timporting glyph groups...'
                     font.import_groups_from_encoding()
             #---------------------------------
             _action = 'paint groups'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tpainting glyph groups...'
                     font.paint_groups(crop=False)
             #---------------------------------
             _action = 'clear colors'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tremoving glyph colors... [empty]'
                     # font.paint_groups(crop=False)
             #---------------------------------
             _action = 'crop glyphset'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tcropping glyph set...'
                     font.order_glyphs()
                     font.crop_glyphset()
             #---------------------------------
             _action = 'spacing groups'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\timporting spacing groups...'
                     font.import_spacing_groups()
             #---------------------------------
             _action = 'paint spacing groups'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tpaint spacing groups...'
                     font.paint_spacing_groups()
             #---------------------------------
             _action = 'remove overlaps'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tremoving overlaps...'
                     font.remove_overlap()
             #---------------------------------
             _action = 'auto unicodes'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tsetting unicodes...'
                     font.auto_unicodes()
             #---------------------------------
             _action = 'autohint PS'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tautohinting PS... [empty]'
             #---------------------------------
             _action = 'test install'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\ttest install...'
                     font.ufo.testInstall()
             #---------------------------------
             _action = 'generate otf'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tgenerating otf...'
                     font.generate_otf(verbose=False)
             #---------------------------------
             _action = 'generate test otf'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tgenerating test otf...'
                     _options = {
                         'decompose' : True,
                         'remove overlap' : True,
                         'autohint' : False,
                         'release mode' : False,
                         'test folder' : True,
                     }
                     font.generate_otf(options=_options)
             #---------------------------------
             _action = 'generate woff'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tgenerating woff...'
                     font.generate_woff()
             #---------------------------------
             _action = 'upload woff'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tuploading woff...'
                     font.upload_woff()
             #---------------------------------
             _action = 'save font'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tsaving font...'
                     font.ufo.save()
             #---------------------------------
             _action = 'close window'
             if _actions.has_key(_action):
                 if _actions[_action]:
                     print '\t\tclosing font window.'
                     font.ufo.close()
             #---------------------------------
             print
             print '\t...done.\n'
         # done with all fonts
         self.w.bar.stop()
         print '...done.\n'
     else:
         print 'please select one or more fonts first.\n'