aboutsummaryrefslogtreecommitdiffstats
path: root/equalize_sidebearings.py
diff options
context:
space:
mode:
authorTeddy Wing2015-12-23 03:54:50 -0800
committerTeddy Wing2015-12-23 03:54:50 -0800
commit36e8ed7f276923b4b3e4115a209ea79d961496a1 (patch)
tree5ff32e983a04901bc4030aa731a077a04a6c94f9 /equalize_sidebearings.py
parentae1960f53dd02798bd00bed7fffe58a0db6bb52d (diff)
downloadRoboFont-Equalize-Sidebearings-Key-36e8ed7f276923b4b3e4115a209ea79d961496a1.tar.bz2
equalize_sidebearings.py: Pass "naked" glyph to Space Center Menu
Via the debugger set up in ae1960f53dd02798bd00bed7fffe58a0db6bb52d and some digging around I discovered the source of the problem that prevented undo functionality from working in the `equalSideBearings_` method. This error came up: AttributeError: "'list' object has no attribute 'resetSelectionPath'" one line above the last line of `equalSideBearings_`, where a call is made to `self._glyph.selection.resetSelectionPath()`. This exception prevents further execution, notably short-circuiting before the glyph's `performUndo()` method can be called in order for undo functionality to work. As the error indicates, `self._glyph.selection` (which is a property) returns `[]` when what is expected is likely some kind of object. That object, it turns out, is a `doodleSelection.Selection` object. The reason why we don't have one is because `info['glyph']` is a `RobofabWrapperGlyph` instead of a `DoodleGlyph`. And a `RobofabWrapperGlyph` either doesn't have a `selection` or more likely has a different sort of `selection` property. In order to get a `DoodleGlyph`, we can call `naked()` on the `RobofabWrapperGlyph`. By passing this object to `CustomSpaceCenterMenuForGlyph` (and thereby `SpaceCenterMenuForGlyph`), we can give the `equalSideBearings_` method something it actually expects, and allow it to respond appropriately. Now RoboFont's existing `equalSideBearings_` method is able to do the right thing, namely equalise a glyph's sidebearings and allow that action to be undone (and redone).
Diffstat (limited to 'equalize_sidebearings.py')
-rw-r--r--equalize_sidebearings.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/equalize_sidebearings.py b/equalize_sidebearings.py
index a1eecfc..76ecc2f 100644
--- a/equalize_sidebearings.py
+++ b/equalize_sidebearings.py
@@ -32,7 +32,8 @@ class EqualizeSidebearings(object):
# space_center_menu.equalSideBearings_(self)
# import pdb; pdb.set_trace()
# RemotePdb('127.0.0.1', 4444).set_trace()
- space_center_menu = CustomSpaceCenterMenuForGlyph(info['glyph'])
+ space_center_menu = CustomSpaceCenterMenuForGlyph(
+ info['glyph'].naked())
space_center_menu.equalSideBearings_(self)
# import vanilla