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


Python CurrentFont.newGlyph方法代码示例

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


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

示例1: set_element_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import newGlyph [as 别名]
 def set_element_callback(self, sender):
     font = CurrentFont()
     if font is not None:
         # get parameters
         shape = self.shapes[self.w.shape.get()]
         scale = float(self.w.spinner_size.value.get())
         magic = float(self.w.spinner_magic.value.get())
         # create element glyph
         if not font.has_key(self.element_glyph):
             font.newGlyph(self.element_glyph)
         # draw element shape
         font[self.element_glyph].prepareUndo('set element')
         set_element(font, scale, type=shape, magic=magic, element_=self.element_glyph)
         font[self.element_glyph].performUndo()
     # no font open
     else:
         print no_font_open
开发者ID:jackjennings,项目名称:hTools2_extension,代码行数:19,代码来源:set_element.py

示例2: _saveImage

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import newGlyph [as 别名]
    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,代码行数:53,代码来源:glyphContext.py

示例3: createSpaceGlyphsDialog

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import newGlyph [as 别名]

#.........这里部分代码省略.........
                    self.text_height),
                    "0 width",
                    sizeStyle=self.size_style)
        x += self.column_1
        self.w.zerowidth_value = EditText(
                    (x, y,
                    -self.padding_x,
                    self.text_height),
                    text='0',
                    readOnly=self.read_only,
                    sizeStyle=self.size_style)
        # buttons
        x = self.padding_x
        y += self.text_height + self.padding_y
        self.w.button_apply = SquareButton(
                    (x, y,
                    -self.padding_x,
                    self.button_height),
                    "create",
                    sizeStyle=self.size_style,
                    callback=self.apply_callback)
        # bind
        self.w.bind("became key", self.update_callback)
        self.w.bind("close", self.on_close_window)
        # observers
        addObserver(self, "update_callback", "fontDidOpen")
        addObserver(self, "update_callback", "fontDidClose")
        # open window
        self.w.open()
        # get current font
        self.get_font()

    def get_font(self):
        self.font = CurrentFont()
        if self.font is not None:
            self.w.box.font_name.set(get_full_name(self.font))
            self.w.hairspace_value.set(int(self.font.info.unitsPerEm * self.hairspace_factor))
            self.w.thickspace_value.set(int(self.font.info.unitsPerEm * self.thickspace_factor))
            self.w.thinspace_value.set(int(self.font.info.unitsPerEm * self.thinspace_factor))
            self.w.figurespace_value.set(int(self.font.info.unitsPerEm * self.figurespace_factor))
        else:
            self.w.box.font_name.set('(None)')
            self.w.hairspace_value.set('')
            self.w.thickspace_value.set('')
            self.w.thinspace_value.set('')
            self.w.figurespace_value.set('')
            print no_font_open

    def apply_callback(self, sender):
        hairspace = int(self.w.hairspace_value.get())
        thinspace = int(self.w.thinspace_value.get())
        thickspace = int(self.w.thickspace_value.get())
        figurespace = int(self.w.figurespace_value.get())
        # boolstring = (False, True)
        if self.font is not None:
            # print info
            print 'creating space glyphs...\n'
            print '\thair space: %s units' % hairspace
            print '\tthin space: %s units' % thinspace
            print '\tthick space: %s units' % thickspace
            print '\tfigure space: %s units' % figurespace
            print '\tzero-width space: 0'
            # hair space
            self.font.newGlyph('hairspace')
            self.font['hairspace'].width = hairspace
            self.font['hairspace'].unicode = unicode_hexstr_to_int('uni200A')
            self.font['hairspace'].update()
            # thin space
            self.font.newGlyph('thinspace')
            self.font['thinspace'].width = thinspace
            self.font['thinspace'].unicode = unicode_hexstr_to_int('uni2009')
            self.font['thinspace'].update()
            # thick space
            self.font.newGlyph('thickspace')
            self.font['thickspace'].width = thickspace
            self.font['thickspace'].unicode = unicode_hexstr_to_int('uni2004')
            self.font['thickspace'].update()
            # figure space
            self.font.newGlyph('figurespace')
            self.font['figurespace'].width = figurespace
            self.font['figurespace'].unicode = unicode_hexstr_to_int('uni2007')
            self.font['figurespace'].update()
            # zero-width space
            self.font.newGlyph('zerowidthspace')
            self.font['zerowidthspace'].width = 0
            self.font['zerowidthspace'].unicode = unicode_hexstr_to_int('uni200B')
            self.font['zerowidthspace'].update()
            # done
            self.font.update()
            print
            print '...done.\n'
        else:
            print no_font_open

    def update_callback(self, sender):
        self.get_font()

    def on_close_window(self, sender):
        removeObserver(self, "fontDidOpen")
        removeObserver(self, "fontDidClose")
开发者ID:gferreira,项目名称:hTools2,代码行数:104,代码来源:spaces_create.py

示例4: createSpaceGlyphsDialog

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import newGlyph [as 别名]

#.........这里部分代码省略.........
            x += self._column_1
            self.w._figurespace_value = EditText(
                        (x, y,
                        -self._padding,
                        self._row_height),
                        text=int(self.font.info.unitsPerEm * self._figurespace_factor),
                        sizeStyle='small')
            # zero width space
            x = self._padding
            y += self._row_height + self._padding
            self.w._zerowidth_label = TextBox(
                        (x, y,
                        self._column_1,
                        self._row_height),
                        "0 width",
                        sizeStyle='small')
            x += self._column_1
            self.w._zerowidth_value = EditText(
                        (x, y,
                        -self._padding,
                        self._row_height),
                        text='0',
                        readOnly=True,
                        sizeStyle='small')
            # buttons
            x = self._padding
            y += self._row_height + self._padding
            self.w._button_apply = SquareButton(
                        (x, y,
                        -self._padding,
                        self._button_height),
                        "create",
                        sizeStyle='small',
                        callback = self.apply_callback)
            # y += self._button_height + self._padding
            # self.w._button_switch = SquareButton(
            #             (x, y,
            #             -self._padding,
            #             self._button_height),
            #             "update",
            #             sizeStyle='small',
            #             callback=self.update_font_callback)
            # open window
            self.w.open()
        # no font open
        else:
            print 'please open a font first.\n'

    def apply_callback(self, sender):
        _hairspace = int(self.w._hairspace_value.get())
        _thinspace = int(self.w._thinspace_value.get())
        _thickspace = int(self.w._thickspace_value.get())
        _figurespace = int(self.w._figurespace_value.get())
        # boolstring = (False, True)
        if self.font is not None:
            # print info
            print 'creating space glyphs...\n'
            print '\thair space: %s units' % _hairspace
            print '\tthin space: %s units' % _thinspace
            print '\tthick space: %s units' % _thickspace
            print '\tfigure space: %s units' % _figurespace
            print '\tzero-width space: 0'
            # hair space
            self.font.newGlyph('hairspace')
            self.font['hairspace'].width = _hairspace
            self.font['hairspace'].unicode = unicode_hexstr_to_int('uni200A')
            self.font['hairspace'].update()
            # thin space
            self.font.newGlyph('thinspace')
            self.font['thinspace'].width = _thinspace
            self.font['thinspace'].unicode = unicode_hexstr_to_int('uni2009')
            self.font['thinspace'].update()
            # thick space
            self.font.newGlyph('thickspace')
            self.font['thickspace'].width = _thickspace
            self.font['thickspace'].unicode = unicode_hexstr_to_int('uni2004')
            self.font['thickspace'].update()
            # figure space
            self.font.newGlyph('figurespace')
            self.font['figurespace'].width = _figurespace
            self.font['figurespace'].unicode = unicode_hexstr_to_int('uni2007')
            self.font['figurespace'].update()
            # zero-width space
            self.font.newGlyph('zerowidthspace')
            self.font['zerowidthspace'].width = 0
            self.font['zerowidthspace'].unicode = unicode_hexstr_to_int('uni200B')
            self.font['zerowidthspace'].update()
            # done
            self.font.update()
            print
            print '...done.\n'
        else:
            print 'No font selected, please close the dialog and try again.\n'

    def update_font_callback(self, sender):
        self.font = CurrentFont()
        self.w.box.text.set(get_full_name(self.font))

    def close_callback(self, sender):
        self.w.close()
开发者ID:hblackett,项目名称:hTools2,代码行数:104,代码来源:create_spaces.py


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