本文整理汇总了Python中mojo.roboFont.CurrentFont.changed方法的典型用法代码示例。如果您正苦于以下问题:Python CurrentFont.changed方法的具体用法?Python CurrentFont.changed怎么用?Python CurrentFont.changed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mojo.roboFont.CurrentFont
的用法示例。
在下文中一共展示了CurrentFont.changed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [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].changed()
# done
f.changed()
print
print '\n...done.\n'
# no glyph selected
else:
print no_glyph_selected
# no font open
else:
print no_font_open
示例2: _clear_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [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
示例3: apply_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [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
示例4: _flip_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [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(self.foreground_layer, self.background_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)
# RF 2.0
if version[0] == '2':
font[glyph_name].changed()
# RF 1.8.X
else:
font[glyph_name].update()
# remove anchors from dest layer
dest_glyph = font[glyph_name].getLayer(self.background_layer)
dest_glyph.clearAnchors()
# done with glyph
font[glyph_name].performUndo()
# done with font
# RF 2.0
if version[0] == '2':
font.changed()
# RF 1.8.X
else:
font.update()
else:
print no_font_open
示例5: apply_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
def apply_callback(self, sender):
f = CurrentFont()
if f is not None:
_top = self.w.top.get()
_bottom = self.w.bottom.get()
_top_pos = int(self.w.spinner_top.value.get())
_bottom_pos = int(self.w.spinner_bottom.value.get())
_accent = self.w.accent.get()
_clear = self.w.clear.get()
glyph_names = get_glyphs(f)
if len(glyph_names) > 0:
if _clear:
print 'removing anchors...\n'
clear_anchors(f, glyph_names)
print '...done.\n'
print 'creating anchors in glyphs...\n'
print '\t',
for glyph_name in glyph_names:
print glyph_name,
f[glyph_name].prepareUndo('create anchors')
create_anchors(f[glyph_name],
top=_top,
bottom=_bottom,
accent=_accent,
top_pos=_top_pos,
bottom_pos=_bottom_pos)
f[glyph_name].performUndo()
f.changed()
print
print "\n...done.\n"
else:
print no_glyph_selected
else:
print no_font_open
示例6: apply_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [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()
left_value = int(self.w.spinner_left.value.get())
right = self.w.right_checkbox.get()
right_mode = self.w.right_mode.get()
right_value = int(self.w.spinner_right.value.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], left_value, boolstring[left])
print '\tright: %s %s [%s]' % (self.modes[right_mode], right_value, boolstring[right])
print
print '\t',
# set margins
for glyph_name in glyph_names:
print glyph_name,
self.set_margins(f[glyph_name],
(left, left_value, left_mode),
(right, right_value, right_mode)
)
f.changed()
print
print '\n...done.\n'
# no glyph selected
else:
print no_glyph_selected
# no font open
else:
print no_font_open
示例7:
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
# mirror active layer only
else:
self._mirror_glyph(f[glyph_name], (scale_x, scale_y))
# RF 2.0
if version[0] == '2':
f[glyph_name].changed()
# RF 1.8.X
else:
f[glyph_name].update()
# done with font
# 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
示例8: adjustVerticalMetrics
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
#.........这里部分代码省略.........
self.w.descender_minus_01 = SquareButton(
(x4, y, self.nudge_button, self.nudge_button),
'-',
sizeStyle=self.size_style,
callback=self.descender_minus_01_callback)
self.w.descender_plus_01 = SquareButton(
(x5, y, self.nudge_button, self.nudge_button),
'+',
sizeStyle=self.size_style,
callback=self.descender_plus_01_callback)
self.w.descender_minus_10 = SquareButton(
(x6, y, self.nudge_button, self.nudge_button),
'-',
sizeStyle=self.size_style,
callback=self.descender_minus_10_callback)
self.w.descender_plus_10 = SquareButton(
(x7, y, self.nudge_button, self.nudge_button),
'+',
sizeStyle=self.size_style,
callback=self.descender_plus_10_callback)
# open window
self.w.open()
else:
print no_font_open
# updates
def xheight_update(self, value):
self.w.xheight_value.set(value)
self.w.xheight_slider.set(value)
self.font.info.xHeight = value
# RF 2.0
if version[0] == '2':
self.font.changed()
# RF 1.8.X
else:
self.font.update()
def capheight_update(self, value):
self.w.capheight_value.set(value)
self.w.capheight_slider.set(value)
self.font.info.capHeight = value
# RF 2.0
if version[0] == '2':
self.font.changed()
# RF 1.8.X
else:
self.font.update()
def descender_update(self, value):
self.w.descender_value.set(abs(value))
self.w.descender_slider.set(abs(value))
self.font.info.descender = -abs(value)
# RF 2.0
if version[0] == '2':
self.font.changed()
# RF 1.8.X
else:
self.font.update()
def ascender_update(self, value):
self.w.ascender_value.set(value)
self.w.ascender_slider.set(value)
self.font.info.ascender = value
# RF 2.0
if version[0] == '2':
示例9: shiftPointsDialog
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
#.........这里部分代码省略.........
sides = ['top', 'bottom']
# print info
print 'shifting points in glyphs...\n'
print '\tposition: %s' % self.pos
print '\tdelta: %s' % delta
print '\taxis: %s' % axes[self.axis]
print '\tmode: %s' % modes[mode]
print '\tside: %s' % sides[self.side]
print '\tlayers: %s' % boolstring[self.layers]
print
print '\t',
# transform
for glyph_name in glyph_names:
print glyph_name,
# get glyph
g = self.font[glyph_name]
#---------
# shift y
#---------
if self.axis:
# all layers
if self.layers:
for layer_name in self.font.layerOrder:
layer_glyph = g.getLayer(layer_name)
layer_glyph.prepareUndo('shift points y')
deselect_points(layer_glyph)
select_points_y(layer_glyph, self.pos, side=sides[self.side])
shift_selected_points_y(layer_glyph, delta)
layer_glyph.performUndo()
# RF 2.0
if version[0] == '2':
layer_glyph.changed()
# RF 1.8.X
else:
layer_glyph.update()
# active layer only
else:
g.prepareUndo('shift points y')
deselect_points(g)
select_points_y(g, self.pos, side=sides[self.side])
shift_selected_points_y(g, delta)
g.performUndo()
# RF 2.0
if version[0] == '2':
g.changed()
# RF 1.8.X
else:
g.update()
#---------
# shift x
#---------
else:
# all layers
if self.layers:
for layer_name in self.font.layerOrder:
layer_glyph = g.getLayer(layer_name)
layer_glyph.prepareUndo('shift points x')
deselect_points(layer_glyph)
select_points_x(layer_glyph, self.pos, side=sides[self.side])
shift_selected_points_x(layer_glyph, delta)
layer_glyph.performUndo()
# RF 2.0
if version[0] == '2':
layer_glyph.changed()
示例10: roundToGridDialog
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
#.........这里部分代码省略.........
# width
y += self.text_height
self.w._width_checkBox = CheckBox(
(x, y, -self.padding_x, self.text_height),
"width",
value=self.glyph_width,
sizeStyle=self.size_style)
# anchors
y += self.text_height
self.w._anchors_checkBox = CheckBox(
(x, y, -self.padding_x, self.text_height),
"anchors",
value=self.anchors,
sizeStyle=self.size_style)
# all layers
y += self.text_height
self.w._layers_checkBox = CheckBox(
(x, y, -self.padding_x, self.text_height),
"all layers",
value=self.layers,
sizeStyle=self.size_style)
# open
self.w.open()
def gridfit(self, g, options):
gridsize = options['gridsize']
# all layers
if options['layers']:
# align layers data
_layers = self.font.layerOrder
for layer_name in _layers:
glyph = g.getLayer(layer_name)
glyph.prepareUndo('align to grid')
if options['bpoints']:
round_bpoints(glyph, (gridsize, gridsize))
if options['points']:
round_points(glyph, (gridsize, gridsize))
if options['anchors']:
round_anchors(glyph, (gridsize, gridsize))
glyph.performUndo()
# align metrics
if options['margins']:
round_margins(g, gridsize, left=True, right=True)
if options['width']:
round_width(g, gridsize)
# active layers only
else:
g.prepareUndo('align to grid')
if options['bpoints']:
round_bpoints(g, (gridsize, gridsize))
if options['points']:
round_points(g, (gridsize, gridsize))
if options['anchors']:
round_anchors(g, (gridsize, gridsize))
if options['margins']:
round_margins(g, gridsize, left=True, right=True)
if options['width']:
round_width(g, gridsize)
g.performUndo()
def apply_callback(self, sender):
self.font = CurrentFont()
if self.font is not None:
glyph_names = get_glyphs(self.font)
if len(glyph_names) > 0:
print 'gridfitting glyphs...\n'
# get options
options = {
'bpoints' : self.w._b_points_checkBox.get(),
'points' : self.w._points_checkBox.get(),
'margins' : self.w._margins_checkBox.get(),
'width' : self.w._width_checkBox.get(),
'anchors' : self.w._anchors_checkBox.get(),
'layers' : self.w._layers_checkBox.get(),
'gridsize' : int(self.w.spinner.value.get()),
}
# print info
boolstring = [False, True]
print '\tgrid size: %s' % options['gridsize']
print '\tbPoints: %s' % boolstring[options['bpoints']]
print '\tpoints: %s' % boolstring[options['points']]
print '\tmargins: %s' % boolstring[options['margins']]
print '\twidth: %s' % boolstring[options['width']]
print '\tanchors: %s' % boolstring[options['anchors']]
print '\tlayers: %s' % boolstring[options['layers']]
print
print '\t',
for glyph_name in glyph_names:
print glyph_name,
self.gridfit(self.font[glyph_name], options)
# done
self.font.changed()
print
print '\n...done.\n'
# no glyph selected
else:
print no_glyph_selected
# no font open
else:
print no_font_open
示例11: apply_callback
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
def apply_callback(self, sender):
# get font
f = CurrentFont()
if f is not None:
glyph_names = get_glyphs(f)
if len(glyph_names) > 0:
boolstring = [False, True]
# get parameters
self.old_suffix = self.w.old_suffix_value.get()
self.new_suffix = self.w.new_suffix_value.get()
self.overwrite = self.w.overwrite_checkbox.get()
# 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 glyph_names:
g = f[glyph_name]
# get glyphs with matching suffix
if has_suffix(g, self.old_suffix):
# switch suffixes : one.osf -> one.onum
if len(self.old_suffix) > 0 and len(self.new_suffix) > 0:
new_name = change_suffix(g, self.old_suffix, self.new_suffix)
# remove suffix : one.osf -> one
elif len(self.old_suffix) > 0 and len(self.new_suffix) == 0:
new_name = change_suffix(g, self.old_suffix, None)
# add suffix : one -> one.onum
elif len(self.old_suffix) == 0 and len(self.new_suffix) > 0:
new_name = '%s.%s' % (glyph_name, self.new_suffix)
else:
new_name = glyph_name
# new name not in font (rename)
if new_name != glyph_name:
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
if self._overwrite:
print "\toverwriting '%s' with '%s'" % (new_name, glyph_name)
f.removeGlyph(_new_name)
f.changed()
g.name = new_name
g.changed()
# do not overwrite
else:
print "\t'%s' already exists in font, skipping '%s'" % (new_name, glyph_name)
# glyph does not have suffix
else:
pass
# done glyph
# done font
f.changed()
print
print '...done.\n'
# no glyph selected
else:
print no_glyph_selected
# no font open
else:
print no_font_open
示例12: deleteLayerDialog
# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import changed [as 别名]
class deleteLayerDialog(hDialog):
'''A dialog to delete a layer in a font.
.. image:: imgs/font/delete-layer.png
'''
#: The font which is currently selected.
font = None
#: A list of all layers in the current font.
layers = []
def __init__(self):
self.get_font()
# window
self.title = 'layers'
self.height = self.button_height + (self.padding_y*3) + (self.text_height*8)
self.w = HUDFloatingWindow((self.width, self.height), self.title)
x = self.padding_x
y = self.padding_y
self.w.layers = List(
(x, y,
-self.padding_x,
self.text_height*8),
self.layers)
y += self.padding_y + self.text_height*8
self.w.button_apply = SquareButton(
(x, y,
-self.padding_x,
self.button_height),
"delete",
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", "fontBecameCurrent")
# open
self.w.open()
# callbacks
def get_font(self):
self.font = CurrentFont()
if self.font is not None:
self.layers = self.font.layerOrder
else:
self.layers = []
def update_ui(self):
self.layers = self.font.layerOrder
self.w.layers.set(self.layers)
def update_callback(self, sender):
self.get_font()
self.update_ui()
def apply_callback(self, sender):
# no font open
if self.font is None:
print no_font_open
# delete layer
else:
layers_index = self.w.layers.getSelection()
layers = [self.layers[i] for i in layers_index]
if len(layers):
print 'deleting layers...\n'
for layer in layers:
if layer in self.font.layerOrder:
print '\tdeleting %s...' % layer
self.font.removeLayer(layer)
self.font.changed()
print
print '...done.\n'
# update UI
self.get_font()
self.update_ui()
else:
print 'no layer selected.'
def on_close_window(self, sender):
removeObserver(self, "fontBecameCurrent")