Programmatically accessing Pythonista default fonts
fitzlarold last edited by fitzlarold
I know this is a strange idea and normally this wouldn't be a thought, but I tried, had trouble, and it became a sort of quest.
My question is this: is there, with the new capabilities of Pythonista, a way to use a custom font I have installed in the editor? I've tried editing a theme file and adding the custom font, but the editor font seems to override this. Any help is appreciated.
omz last edited by
This may not work for all fonts, but here' something you can try:
#coding: utf-8 from objc_util import * NSUserDefaults = ObjCClass('NSUserDefaults') NSNotificationCenter = ObjCClass('NSNotificationCenter') @on_main_thread def set_editor_font(name): defaults = NSUserDefaults.standardUserDefaults() center = NSNotificationCenter.defaultCenter() defaults.setObject_forKey_(name, 'EditorFontName') n = 'EditorDisplaySettingsChangedNotification' center.postNotificationName_object_(n, None) set_editor_font('AmericanTypewriter')
If you see Helvetica instead of your font, it probably means that you didn't use the correct name (sometimes the internal name of a font is different from what's shown in UI).
fitzlarold last edited by
Thank you! That worked like a charm!