Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Programmatically accessing Pythonista default fonts
-
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.
-
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).
-
Thank you! That worked like a charm!