RoboFont › Forums › Enhancements › Observers and events
This topic contains 8 replies, has 2 voices, and was last updated by frederik 8 years, 7 months ago.
- 
		AuthorPosts
- 
		
			
				
March 13, 2012 at 14:20 #3782Is it possible to add an observer that watches the edit field in the Space Center? I can read the contents of the current Space Center manually, but I want to be able to react whenever the user types or edits the sample text in the edit field. March 13, 2012 at 15:01 #3784This is a feature planned feature for the next version. 
 Something similar like tools and his observers for the Glyph View but enhanced for Space Center.(see http://cl.ly/ExxK :) It is possible but it will be with some detours…. March 13, 2012 at 19:56 #3798Okay, plan B then. Is there a way to go back and forth between a list of glyphs and a string? For example, Go from this: [‘H’, ‘e’, ‘l’, ‘l’, ‘o’, ‘exclam’] to this: “Hello!” and back again? Seems like there should be something like this built into one of the included packages, but I don’t know where to start looking. March 13, 2012 at 21:44 #3800Everything is depending on the font you want to use and the character unicode mapping inside that font. you can use something similar: ## this is used internally to split inputted text to a list of glyph names based on the current font from lib.UI.spaceCenter.glyphSequenceEditText import splitText from robofab.interface.all.dialogs import AskString ## get some text text = AskString("input") print "input:", text font = CurrentFont() ## the character map cmap = font.getCharacterMapping() ## split the text based on the camp in to a list of glyph names glyphNameList = splitText(text, cmap) print "as glyph names list:", glyphNameList ## loop over the glyph names asks for their unicode value in the current font ## convert it back to text based on that unicode value backToText = u"" for glyphName in glyphNameList: if glyphName in font: glyph = font[glyphName] if glyph.unicode is not None: backToText += u"%s" %(unichr(glyph.unicode)) else: backToText += "/%s " %glyphName else: backToText += "/%s " %glyphName print "backtoText:", backToTexthope this makes sense. March 13, 2012 at 21:51 #3801Ah, okay. I may be able to work from this. Essentially, though, I have a little window built with vanilla with a textEditor in it, and I want to get and set the text in the Space Center text field. This is in the form of a list of glyph names, while the vanilla textEditor field is in the form of a string. The font I’m using is whatever the default is in the vanilla textEditor field (Helvetica of some kind). March 13, 2012 at 22:23 #3806mmmm, oke Im kind of guessing what you want to achieve but maybe this can help to. A SpaceCenter object also has a setRaw and getRaw methods, expecting a string, text as input or return. from robofab.interface.all.dialogs import AskString from mojo.UI import CurrentSpaceCenter sp = CurrentSpaceCenter() text = AskString("input") sp.setRaw(text)(Ive just updated http://doc.robofont.com/api/mojo/mojo-ui/ with getRaw and setRaw) March 13, 2012 at 22:28 #3807Yes, that will work! Thanks! Sorry for not being clearer about what I was trying to accomplish — I could have spared you from writing all that code in your previous response. I appreciate your time. March 14, 2012 at 00:00 #3811Here’s the script I’ve been working on: http://www.ms-studio.com/Robofont/PangrammerHelper.py It’s a little window for composing pangrams. If Space Center is active, it displays them there as well. March 14, 2012 at 08:45 #3815great! 
 thanks
- 
		AuthorPosts
You must be logged in to reply to this topic.