Last active
October 18, 2024 20:19
-
-
Save connordavenport/ebc4c229a9aa1498dbca95fcb0f890fb to your computer and use it in GitHub Desktop.
a fontparts add on to allow one to mark a glyph by the color name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mojo.roboFont import RGlyph | |
| from mojo.UI import getDefault | |
| ''' | |
| g = CurrentGlyph() | |
| g.markColorName = "Red" | |
| ''' | |
| def _setColorName(self, color=None): | |
| if not isinstance(color, str): | |
| raise TypeError("markColorName must be a string, not %s." | |
| % type(color).__name__) | |
| m = {name:tuple(clr) for clr,name in getDefault("markColors")} | |
| item = m.get(color) | |
| if item: | |
| self.markColor = item | |
| def _getColorName(self): | |
| for c in getDefault("markColors"): | |
| clr, name = c | |
| if clr == self.markColor: | |
| return name | |
| markColorName = property(_getColorName, _setColorName) | |
| RGlyph.markColorName = markColorName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment