本文整理汇总了Python中mojo.roboFont.CurrentFont类的典型用法代码示例。如果您正苦于以下问题:Python CurrentFont类的具体用法?Python CurrentFont怎么用?Python CurrentFont使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CurrentFont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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'
示例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
示例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
示例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'
示例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
示例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
示例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
示例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
示例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
示例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
示例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"
示例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