• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python roboFont.CurrentFont类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: apply_callback

 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,代码行数:33,代码来源:anchors_rename.py


示例2: apply_callback

 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,代码行数:25,代码来源:elements_randomize.py


示例3: apply_callback

 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,代码行数:32,代码来源:set_margins.py


示例4: select_callback

 def select_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         glyph_names = get_glyphs(f)
         if len(glyph_names) > 0:
             glyph_name = get_glyphs(f)[0]
             color = f[glyph_name].mark
             print 'selecting glyphs:\n'
             print '\t',
             # print '\tcolor: %s %s %s %s' % color
             glyph_names = []
             for glyph in f:
                 if glyph.mark == color:
                     print glyph.name,
                     glyph_names.append(glyph.name)
             #print '\tglyphs: %s' % glyph_names
             f.selection = glyph_names
             print
             print '\n...done.\n'
         # no glyph selected
         else:
             print 'please select a glyph first.\n'
     # no font open
     else:
         print 'please open a font first.\n'
开发者ID:jeremymickel,项目名称:hTools2,代码行数:25,代码来源:glyphs_paint.py


示例5: _rasterize_callback

 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,代码行数:27,代码来源:elements_rasterize.py


示例6: apply_callback

 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,代码行数:26,代码来源:layer_import.py


示例7: apply_callback

 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,代码行数:33,代码来源:rename_anchors.py


示例8: _flip_callback

 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,代码行数:26,代码来源:mask.py


示例9: _clear_callback

    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,代码行数:26,代码来源:mask.py


示例10: apply_callback

    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,代码行数:56,代码来源:width_set.py


示例11: apply_callback

 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,代码行数:10,代码来源:delete_layer.py


示例12: _copy_callback

 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,代码行数:10,代码来源:mask.py


示例13: _flip_callback

 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,代码行数:10,代码来源:mask.py


示例14: _print_callback

 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,代码行数:10,代码来源:rasterize.py


示例15: _clear_callback

 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,代码行数:11,代码来源:mask.py


示例16: _saveImage

    def _saveImage(self, path, multipage):
        # extract glyph name and layername for the path
        # full syntax: 'a(background).glyph'
        # draw in glyph with name 'a' in the 'background' layer
        glyphName, ext = os.path.splitext(os.path.basename(path))
        # extract the layername
        layerName = layerNameRE.findall(glyphName)
        # replace the layername by nothing
        glyphName = layerNameRE.sub("", glyphName)
        # layer name found
        if layerName:
            layerName = layerName[0]
        else:
            layerName = None
        # if there is an extension --> there is a glyph name
        # get the glyph from the CurrentFont
        # otherwise draw in the CurrentGlyph
        if ext:
            font = CurrentFont()
            if glyphName not in font:
                dest = font.newGlyph(glyphName)
                if dest is None:
                    raise GlyphDrawBotError("No font available to draw in")
                dest.width = 500
            else:
                dest = font[glyphName]
        else:
            dest = CurrentGlyph()
        # can not found a proper glyph to draw in
        if dest is None:
            raise GlyphDrawBotError("No glyph available to draw in")
        dest.clear()
        multiplePages = len(self._glyphs) > 1

        for count, glyph in enumerate(self._glyphs):
            if layerName:
                if multiplePages:
                    n = "%s_%s" % (layerName, count + 1)
                else:
                    n = layerName
                destLayer = dest.getLayer(n)
            else:
                destLayer = dest
                layerName = "drawBot"
            destLayer.appendGlyph(glyph)

            if glyph.image:
                image = glyph.image
                destImage = destLayer.addImage(image.data)
                destImage.transformation = image.transformation
                destImage.brightness = image.brightness
开发者ID:typemytype,项目名称:drawBotRoboFontExtension,代码行数:51,代码来源:glyphContext.py


示例17: paste_callback

 def paste_callback(self, sender):
     print 'pasting data from glyph %s:\n' % self.source_glyph.name
     bool_string = ( False, True )
     foreground = self.w.foreground.get()
     layers = self.w.layers.get()
     metrics = self.w.metrics.get()
     anchors = self.w.anchors.get()
     color = self.w.color.get()
     print '\tforeground: %s' % bool_string[foreground]
     print '\tlayers: %s' % bool_string[layers]
     print '\tmetrics: %s' % bool_string[metrics]
     print '\tanchors: %s' % bool_string[anchors]
     print '\tcolor: %s' % bool_string[color]
     print
     print '\tpasting in',
     f = CurrentFont()
     glyph_names = get_glyphs(f)
     if len(glyph_names) > 0:
         for glyph_name in glyph_names:
             print glyph_name,
             # prepare undo
             f[glyph_name].prepareUndo('paste from glyph')
             # copy outlines in foreground layer
             if foreground:
                 target_layer = f[glyph_name].getLayer('foreground')
                 pen = target_layer.getPointPen()
                 self.source_glyph.drawPoints(pen)
             # copy all other layers
             if layers:
                 for layer_name in self.source_font.layerOrder:
                     source_layer = self.source_glyph.getLayer(layer_name)
                     target_layer = f[glyph_name].getLayer(layer_name)
                     pen = target_layer.getPointPen()
                     source_layer.drawPoints(pen)
             # copy glyph width
             if metrics:
                 f[glyph_name].width = self.source_glyph.width
             # copy anchors
             if anchors:
                 transfer_anchors(self.source_glyph, f[glyph_name])
             # copy mark color
             if color:
                 f[glyph_name].mark = self.source_glyph.mark
             # activate undo
             f[glyph_name].performUndo()
             # done with glyph
             f[glyph_name].update()
         # done
         f.update()
     print
     print '\n...done.\n'
开发者ID:hblackett,项目名称:hTools2,代码行数:51,代码来源:copy_paste.py


示例18: apply_callback

 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         # get parameters
         _width = int(self.w.width_value.get())
         _center = self.w.center_checkbox.get()
         _split = self.w.split_checkbox.get()
         _split_relative = self.w.split_relative_checkbox.get()
         _gNames = f.selection
         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 = None
         # print info
         print 'setting character widths...\n'
         print '\t%s %s' % (self._modes[self._mode], _width)
         print '\tmode: %s' % _w_mode
         print
         print '\t',
         # current glyph
         glyph = CurrentGlyph()
         if glyph is not None:
             print glyph.name,
             self.set_width(glyph, _width, _w_mode)
             f.update()
             print
             print '\n...done.\n'
         # selected glyphs
         else:
             glyph_names = f.selection
             if len(glyph_names) > 0:
                 for glyph_name in glyph_names:
                     print glyph_name,
                     self.set_width(f[glyph_name], _width, _w_mode)
                 f.update()
                 print
                 print '\n...done.\n'
             # no glyph selected
             else:
                 print 'please select one or more glyphs first.\n'
     # no font open
     else:
         print 'please open a font first.\n'
开发者ID:jeremymickel,项目名称:hTools2,代码行数:49,代码来源:glyphs_set_width.py


示例19: _rasterize_callback

 def _rasterize_callback(self, sender):
     f = CurrentFont()
     glyph_names = get_glyphs(f)
     if len(glyph_names) > 0:
         self.w.bar.start()
         print "rasterizing glyphs..."
         for glyph_name in glyph_names:
             print '\tscanning %s...' % glyph_name
             f[glyph_name].prepareUndo('rasterize glyph')
             g = RasterGlyph(f[glyph_name])
             g.rasterize(res=self._gridsize)
             f[glyph_name].update()
             f[glyph_name].performUndo()
         f.update()
         self.w.bar.stop()
         print "...done.\n"
开发者ID:miguelsousa,项目名称:hTools2,代码行数:16,代码来源:rasterize.py


示例20: apply_callback

 def apply_callback(self, sender):
     f = CurrentFont()
     if f is not None:
         print 'importing .ufo into layer...'
         ufo = RFont(self.ufo_path, showUI=False)
         layer_name = os.path.split(self.ufo_path)[1]
         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'
     else:
         print 'please open a font first.\n'
开发者ID:hblackett,项目名称:hTools2,代码行数:16,代码来源:import_layer.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python template.template函数代码示例发布时间:2022-05-27
下一篇:
Python extensions.setExtensionDefault函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap