Created
June 14, 2017 19:09
-
-
Save frankrolf/36a759625115c86cab3f6822b6fc49ad to your computer and use it in GitHub Desktop.
Export Robofont’s space center as a PNG file
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
| import os | |
| from AppKit import NSBitmapImageRep, NSPNGFileType, NSColor | |
| from mojo.UI import CurrentSpaceCenter | |
| def export_space_center_to_png(url): | |
| sp = CurrentSpaceCenter() | |
| sp_view = sp.glyphLineView.getNSScrollView() | |
| sp_view.lockFocus() | |
| rep = NSBitmapImageRep.alloc().initWithFocusedViewRect_(sp_view.bounds()) | |
| sp_view.unlockFocus() | |
| data = rep.representationUsingType_properties_(NSPNGFileType, {}) | |
| data.writeToFile_atomically_(url, True) | |
| sp_view.setBackgroundColor_(NSColor.whiteColor()) | |
| image_path = os.path.expanduser('~/Desktop/space_center.png') | |
| export_space_center_to_png(image_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment