当前位置: 首页>>代码示例>>Python>>正文


Python CurrentFont.update方法代码示例

本文整理汇总了Python中mojo.roboFont.CurrentFont.update方法的典型用法代码示例。如果您正苦于以下问题:Python CurrentFont.update方法的具体用法?Python CurrentFont.update怎么用?Python CurrentFont.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mojo.roboFont.CurrentFont的用法示例。


在下文中一共展示了CurrentFont.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         glyph_names = get_glyphs(f)
         if len(glyph_names) > 0:
             # get parameters
             old = self.w._old_name_value.get()
             new = self.w._new_name_value.get()
             boolstring = (False, True)
             # print info
             print 'renaming anchors in glyphs...\n'
             print '\told name: %s' % old
             print '\tnew name: %s' % new
             print
             print '\t',
             # change anchors names
             for glyph_name in glyph_names:
                 print glyph_name,
                 # rename anchor
                 f[glyph_name].prepareUndo('rename anchor')
                 has_name = rename_anchor(f[glyph_name], old, new)
                 f[glyph_name].performUndo()
                 f[glyph_name].update()
             # done
             f.update()
             print
             print '\n...done.\n'
         # no glyph selected
         else:
             print no_glyph_selected
     # no font open
     else:
         print no_font_open
开发者ID:jackjennings,项目名称:hTools2_extension,代码行数:35,代码来源:anchors_rename.py

示例2: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         boolstring = [ 'False', 'True' ]
         # get parameters
         _left = self.w.left_checkbox.get()
         _left_mode = self.w.left_mode.get()
         _right = self.w.right_checkbox.get()
         _right_mode = self.w.right_mode.get()
         # iterate over glyphs
         glyph_names = get_glyphs(f)
         if len(glyph_names) > 0:
             # print info
             print 'setting margins for selected glyphs...\n'
             print '\tleft: %s %s [%s]' % (self._modes[_left_mode], self._left_value, boolstring[_left])
             print '\tright: %s %s [%s]' % (self._modes[_right_mode], self._right_value, boolstring[_right])
             print
             print '\t\t',
             # set margins
             for glyph_name in glyph_names:
                 print glyph_name,
                 self.set_margins(f[glyph_name],
                             (_left, self._left_value, _left_mode),
                             (_right, self._right_value, _right_mode))
             f.update()
             print '\n...done.\n'
         # no glyph selected
         else:
             print no_glyph_selected
     # no font open
     else:
         print no_font_open
开发者ID:miguelsousa,项目名称:hTools2,代码行数:34,代码来源:set_margins.py

示例3: _rasterize_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _rasterize_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         glyph_names = get_glyphs(font)
         if len(glyph_names) > 0:
             gridsize = int(self.w.spinner.value.get())
             res = (gridsize, gridsize)
             self.w.bar.start()
             print "rasterizing glyphs...\n"
             for glyph_name in glyph_names:
                 glyph = font[glyph_name]
                 print '\tscanning %s...' % glyph_name
                 glyph.prepareUndo('rasterize glyph')
                 R = RasterGlyph(glyph)
                 R.rasterize(res=res)
                 glyph.update()
                 glyph.performUndo()
             # done
             font.update()
             self.w.bar.stop()
             print "\n...done.\n"
         # no glyph selected
         else:
             print no_glyph_selected
     # no font open
     else:
         print no_font_open
开发者ID:gferreira,项目名称:hTools2_extension,代码行数:29,代码来源:elements_rasterize.py

示例4: _flip_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _flip_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         glyph_names = get_glyphs(font)
         # get foreground anchors
         anchors_dict = get_anchors(font, glyph_names)
         for glyph_name in glyph_names:
             # flip layers (including anchors)
             font[glyph_name].prepareUndo('flip mask')
             font[glyph_name].flipLayers('foreground', self.mask_layer)
             # keep anchors from source layer in foreground
             if not self.w.flip_anchors.get():
                 if anchors_dict.has_key(glyph_name):
                     for anchor in anchors_dict[glyph_name]:
                         anchor_name, anchor_pos = anchor
                         font[glyph_name].appendAnchor(anchor_name, anchor_pos)
                         font[glyph_name].update()
                 # remove anchors from dest layer
                 dest_glyph = font[glyph_name].getLayer(self.mask_layer)
                 dest_glyph.clearAnchors()
             # done with glyph
             font[glyph_name].performUndo()
         # done with font
         font.update()
     else:
         print no_font_open
开发者ID:gferreira,项目名称:hTools2_extension,代码行数:28,代码来源:mask.py

示例5: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     # get font
     font = CurrentFont()
     if font is not None:
         # get glyphs
         glyph_names = font.selection
         if len(glyph_names) > 0:
             # get values
             esize = get_esize(font)
             self.rand_min = self.w.spinner_min.value.get()
             self.rand_max = self.w.spinner_max.value.get()
             # randomize elements
             for glyph_name in glyph_names:
                 w = font[glyph_name].width
                 g = RasterGlyph(font[glyph_name])
                 g.rasterize()
                 randomize_elements(font[glyph_name], esize, (self.rand_min, self.rand_max))
                 font[glyph_name].width = w
             font.update()
         # no glyph selected
         else:
             print no_glyph_selected
     # no font open
     else:
         print no_font_open
开发者ID:gferreira,项目名称:hTools2_extension,代码行数:27,代码来源:elements_randomize.py

示例6: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         # get layer name
         layer_name_option = self.w.layer_name.get()
         # mask layer
         if not layer_name_option:
             layer_name = 'background'
         # font name
         else:
             layer_name = os.path.split(self.ufo_path)[1]
         # import layer
         print 'importing .ufo...\n'
         print '\ttarget layer: %s\n' % layer_name
         ufo = RFont(self.ufo_path, showUI=False)
         for glyph_name in f.keys():
             if ufo.has_key(glyph_name):
                 layer_glyph = f[glyph_name].getLayer(layer_name)
                 pen = layer_glyph.getPointPen()
                 ufo[glyph_name].drawPoints(pen)
                 f[glyph_name].update()
         f.update()
         print '...done.\n'
     # no font open
     else:
         print no_font_open
开发者ID:jackjennings,项目名称:hTools2_extension,代码行数:28,代码来源:layer_import.py

示例7: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         if len(f.selection) > 0:
             # get parameters
             _old = self.w._old_name_value.get()
             _new = self.w._new_name_value.get()
             boolstring = (False, True)
             # print info
             print 'renaming anchors in glyphs...\n'
             print '\told name: %s' % _old
             print '\tnew name: %s' % _new
             print
             print '\t',
             # batch change anchors names
             glyph_names = get_glyphs(f)
             for glyph_name in glyph_names:
                 print glyph_name,
                 # rename anchor
                 f[glyph_name].prepareUndo('rename anchor')
                 has_name = rename_anchor(f[glyph_name], _old, _new)
                 f[glyph_name].performUndo()
                 f[glyph_name].update()
             # done
             f.update()
             print
             print '\n...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'
开发者ID:miguelsousa,项目名称:hTools2,代码行数:35,代码来源:rename_anchors.py

示例8: _clear_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
    def _clear_callback(self, sender):
        font = CurrentFont()
        if font is not None:
            for glyph_name in get_glyphs(font):

                font[glyph_name].prepareUndo('clear mask')
                mask_layer = font[glyph_name].getLayer(self.background_layer)
                mask_layer.clear()
                font[glyph_name].performUndo()

                # RF 2.0
                if version[0] == '2':
                    font[glyph_name].changed()
                # RF 1.8.X
                else:
                    font[glyph_name].update()

            # RF 2.0
            if version[0] == '2':
                font.changed()
            # RF 1.8.X
            else:
                font.update()

        else:
            print no_font_open
开发者ID:gferreira,项目名称:hTools2,代码行数:28,代码来源:mask.py

示例9: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
    def apply_callback(self, sender):

        f = CurrentFont()

        if f is not None:

            # iterate over glyphs
            glyph_names = get_glyphs(f)
            if len(glyph_names) > 0:

                # get parameters
                width  = int(self.w.spinner.value.get())
                center = self.w.center_checkbox.get()
                split  = self.w.split_checkbox.get()
                split_relative = self.w.split_relative_checkbox.get()

                boolstring = (False, True)

                # set sidebearings mode
                if center:
                    w_mode = 'center'
                elif split:
                    w_mode = 'split difference'
                elif split_relative:
                    w_mode = 'split relative'
                else:
                    w_mode = 'default'

                # print info
                print 'setting character widths...\n'
                print '\t%s %s' % (self._modes[self._mode], width)
                print '\tmode: %s' % w_mode
                print
                print '\t',

                for glyph_name in glyph_names:
                    print glyph_name,
                    self.set_width(f[glyph_name], width, w_mode)

                # RF 2.0
                if version[0] == '2':
                    f.changed()
                # RF 1.8.X
                else:
                    f.update()

                print
                print '\n...done.\n'

            # no glyph selected
            else:
                print no_glyph_selected

        # no font open
        else:
            print no_font_open
开发者ID:gferreira,项目名称:hTools2,代码行数:58,代码来源:width_set.py

示例10: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     font = CurrentFont()
     _layer_name = self.w._layer_name.get()
     if _layer_name in font.layerOrder:
         print 'deleting layer %s...' % _layer_name
         font.removeLayer(_layer_name)
         print '...done.\n'
         font.update()
     else:
         print 'font does not have layer %s.' % _layer_name
开发者ID:miguelsousa,项目名称:hTools2,代码行数:12,代码来源:delete_layer.py

示例11: _copy_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _copy_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         for glyph_name in get_glyphs(font):
             font[glyph_name].prepareUndo('copy to mask')
             font[glyph_name].copyToLayer(self.mask_layer, clear=False)
             font[glyph_name].performUndo()
         font.update()
     else:
         print no_font_open
开发者ID:hblackett,项目名称:hTools2,代码行数:12,代码来源:mask.py

示例12: _flip_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _flip_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         for glyph_name in get_glyphs(font):
             font[glyph_name].prepareUndo('flip mask')
             font[glyph_name].flipLayers('foreground', self.mask_layer)
             font[glyph_name].performUndo()
         font.update()
     else:
         print no_font_open
开发者ID:hblackett,项目名称:hTools2,代码行数:12,代码来源:mask.py

示例13: _print_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _print_callback(self, sender):
     f = CurrentFont()
     glyph_names = get_glyphs(f)
     if len(glyph_names) > 0:
         print "printing glyphs...\n"
         for glyph_name in glyph_names:
             g = RasterGlyph(f[glyph_name])
             g._print(res=self._gridsize)
         f.update()
         print "...done.\n"
开发者ID:miguelsousa,项目名称:hTools2,代码行数:12,代码来源:rasterize.py

示例14: _clear_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def _clear_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         for glyph_name in get_glyphs(font):
             font[glyph_name].prepareUndo('clear mask')
             clear_mask = font[glyph_name].getLayer(self.mask_layer, clear=True)
             font[glyph_name].update()
             font[glyph_name].performUndo()
         font.update()
     else:
         print no_font_open
开发者ID:gferreira,项目名称:hTools2_extension,代码行数:13,代码来源:mask.py

示例15: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import update [as 别名]
 def apply_callback(self, sender):
     boolstring = [ False, True ]
     f = CurrentFont()
     if f is not None:
         if len(f.selection) > 0:
             # print info
             print 'changing glyph name suffixes...\n'
             print '\told suffix: %s' % self._old_suffix
             print '\tnew suffix: %s' % self._new_suffix
             print '\toverwrite: %s' % boolstring[self._overwrite]
             print
             # batch change glyph names
             for glyph_name in get_glyphs(f):
                 g = f[glyph_name]
                 # get glyphs with matching suffix
                 if has_suffix(g, self._old_suffix):
                     # make new name
                     if len(self._new_suffix) > 0:
                         _new_name = change_suffix(g, self._old_suffix, self._new_suffix)
                     else:
                         _new_name = change_suffix(g, self._old_suffix, None)
                     # if new name not in font, rename
                     if not f.has_key(_new_name):
                         print '\trenaming %s to %s...' % (glyph_name, _new_name)
                         g.name = _new_name
                     # new name in font
                     else:
                         # overwrite existing
                         if self._overwrite:
                             print "\toverwriting '%s' with '%s'" % (_new_name, glyph_name)
                             f.removeGlyph(_new_name)
                             f.update()
                             g.name = _new_name
                             g.update()
                         # do not overwrite
                         else:
                             print "\t'%s' already exists in font, skipping '%s'" % (_new_name, glyph_name)
                 # glyph name does not have suffix
                 else:
                     pass
                 # done glyph
             # done font
             f.update()
             print
             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'
     pass
开发者ID:miguelsousa,项目名称:hTools2,代码行数:54,代码来源:change_suffix.py


注:本文中的mojo.roboFont.CurrentFont.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。