aboutsummaryrefslogtreecommitdiffstats
path: root/equalize_sidebearings.py
AgeCommit message (Collapse)Author
2015-12-23equalize_sidebearings.py: Rename `center` method to `equalize`Teddy Wing
Because the term is not exactly appropriate in this context. Equalising and centering are really 2 different things and this method does the former.
2015-12-23equalize_sidebearings.py: Remove old debugging codeTeddy Wing
This code opened a GUI object browser for better inspection (still wasn't perfect, but it was decent enought for a start. Remote-Pdb really saved the day.). We no longer need this block now that we've figured out how to get it to work.
2015-12-23equalize_sidebearings.py: Remove old side bearing equalisation codeTeddy Wing
Remove old commented code that's irrelevant now that we're using this better method of equalising side bearings.
2015-12-23equalize_sidebearings.py: Get rid of proprietary codeTeddy Wing
Remove RoboFont's proprietary `getDefault` and `equalSideBearings_` code since the extension now works without them and we shouldn't be using this code in an extension that we plan to open source. Sorry for even including this in the repo! It did end up being useful for testing, just to see that it was possible.
2015-12-23equalize_sidebearings.py: Remove debugging statementsTeddy Wing
Figured out 36e8ed7f276923b4b3e4115a209ea79d961496a1.
2015-12-23equalize_sidebearings.py: Pass "naked" glyph to Space Center MenuTeddy Wing
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).
2015-12-23equalize_sidebearings.py: Add remote debugging with Remote-PDBTeddy Wing
Temporarily add remote debugging facilities via Remote-PDB (https://pypi.python.org/pypi/remote-pdb). This allows us to actually debug our script to see what on earth is going on. Injected Remote-PDB via another script that may become another RoboFont extension at some point. Once the package was injected, all I had to do was import `RemotePdb` and set an address and port, and I could telnet into the pdb session to try and figure out what's going on to make it so that undo functionality doesn't work.
2015-12-06equalize_sidebearings.py: Call RoboFont implementation instead of copyTeddy Wing
Comment out the copied RoboFont implementation and call the existing implementation instead. We do this by subclassing `SpaceCenterMenuForGlyph` and overriding the `__init__` method. This allows us to bypass `SpaceCenterMenuForGlyph`'s `__init__` method (notice that we call its super `__init__` but not its `__init__`), allowing us to create an instance without needing to specify the required `event`, `view`, and `callback` parameters that the original class requires. This also allows us to not include proprietary code in the project. Undo functionality _still_ doesn't work. Can't figure out what the problem is. This change is really from shortly after the last commit, but I didn't bother committing because I wanted to resolve the undo problems first. Since it's been a while, deciding now to commit what's here and continue working.
2015-11-20equalize_sidebearings.py: Copy RoboFont implementationTeddy Wing
Copy `equalize_sidebearings` method and `getDefault` function from RoboFont after uncompiling the `lib/UI/spaceCenter/*.pyc`, `lib/doodleMenus.pyc`, and `lib/tools/defaults.pyc` files. This gives us the exact same functionality that happens when choosing "Equalize sidebearings" from the contextual menu in the Space Center. Including the code directly instead of referencing it because the `SpaceCenterMenuForGlyph` class opens a contextual menu on init, which we really don't want, and the `equalizeSideBearings_` method that it defined is an instance method, so I would need an instance of the class but don't want to trigger the contextual menu. So I figured I'd just copy the code directly to speed things up. Unfortunately undo functionality doesn't work with the method I copied, and I can't seem to figure out how to get it sorted out.
2015-11-19equalize_sidebearings.py: Add undo capabilityTeddy Wing
Allow centering to be undone.
2015-11-19equalize_sidebearings.py: Remove unused importTeddy Wing
From the inspection code that I removed in 76e0ea2b4dab01bef29e9a18589a32897b49de45.
2015-11-19equalize_sidebearings.py: Remove commented inspection codeTeddy Wing
2015-11-19Rename observer_test.py to equalize_sidebearings.pyTeddy Wing