RoboFab Message & Glyphs

Hello Glyphs-Team!

I just installed RoboFab and it dependencies in my /Python/2.6/site-packages/ directory but when I try to get a RoboFab Message like:

from robofab.interface.all.dialogs import Message
Message(“A Message From RoboFab”)

I get this Error:

Traceback (most recent call last):
File “”, line 2, in
File “/Users/petesekan/RoboFab/RoboFab/Lib/robofab/interface/all/dialogs_mac_vanilla.py”, line 184, in Message
vanilla.dialogs.message(messageText=message, informativeText=informativeText)
AttributeError: ‘module’ object has no attribute ‘dialogs’

What have I done wrong?

Greetz,
Pete

BTW When I install your scripts from github into my Glyphs script directory and try to run them, I get this error:

Traceback (most recent call last):
File “Import SVGs2Glyphs.py”, line 9, in
ImportError: No module named objectsGS

But objectGS.py is in the same directory. Should it be somewhere else?

Greetz,
P

  1. objectsGS.py and GSPen.py need to be in the Scripts root, i.e. directly in the Scripts folder, not in any of the subfolders.

  2. And you need to import the objectsGS wrapper, not Robofab directly. So, e.g., the first line of your script could be:

from objectsGS import *

Thank you mekkablue!

This works!

I’m having a hard time with RoboFab in Glyphs. I keep seeing a bunch of different forum posts with instructions on how to install it, and every time I do one of them I find a different set of instructions. Could someone please explain all the steps to have RoboFab in Glyphs.

I’m attaching screengrabs of my folders to show how I installed it. I am still getting errors when I run my scripts. I’m making a switch from RoboFont and I would really like to be able to use my scripts without having to recode them.

Thanks.

Telling from the screenshots, the installation looks good. Did you change the import statements at the beginnings of your scripts? See my post #3 in this thread.

Also, there are problems with Mac OS X Snow Leopard. Which version of the system are you running?

Thanks mekkablue

So that means I have to modify all my scripts to run them on Glyphs? Will that give me 100% RoboFab support?

Still not working 100%, I’m getting this message:

Start
Traceback (most recent call last):
File “Fractional Coordinates - Round All in Current Font.py”, line 9, in
from objectsGS.interface.all.dialogs import Message
ImportError: No module named interface.all.dialogs
End

I’m on 10.8.4

Debugging mileage always varies. Do you have your scripts on github? I’d need to take a closer look.

It’s not a script i wrote, so I don’t feel comfortable sharing. But it might be an issue in general if i have to debug every script/relearn how to use RoboFab for Glyphs.

I was hoping to switch from RoboFont to Glyphs, but since most of my peers are on RoboFont (and I have quite a few scripts I use already) I have to find a way around the scripting issue.

Thanks for your help.

Are you allowed to communicate what the scripts do? For instance, telling from the title, ‘Fractional Coordinates - Round All in Current Font.py’, this script is probably not necessary in Glyphs, because you already have the Round Coordinates function in the Layers menu.

From my experience, many RoboFont scripts merely reduplicate what is built into Glyphs from the start. So it’s worth going through the scripts and judging what you actually need. Step two would be to debug the remaining ones. The error you quote comes from the RoboFab dialogs which are a wrapper for the Vanilla dialogs, which in turn are a wrapper for Cocoa dialogs. Simplest way to rewrite them would be to do this:

import vanilla.dialogs
print vanilla.dialogs.message( messageText=“messageText”, informativeText=“informativeText” )
print vanilla.dialogs.askYesNo( messageText=“messageText”, informativeText=“informativeText” )
print vanilla.dialogs.askYesNoCancel( messageText=“messageText”, informativeText=“informativeText” )
print vanilla.dialogs.getFile( messageText=“messageText” )
print vanilla.dialogs.getFileOrFolder( messageText=“messageText” )
print vanilla.dialogs.getFolder( messageText=“messageText” )
print vanilla.dialogs.putFile( messageText=“messageText” )

These work nicely from within Glyphs.

You should not replace all robofab imports. Just add:

from objectsGS import *

at the top of the script.

I checked it again and with the latest RoboFab version it should work out of the box, no changes required.

First, you should change the import back to the original.

I’m not sure what the problem is here but I only could get it to work after changing one line in the RoboFab code. I put it in my fork of RoboFab in github.

In the file /Users/petesekan/RoboFab/RoboFab/Lib/robofab/interface/all/dialogs_mac_vanilla.py change line from

import vanilla

to

import vanilla.dialogs

And I just updated the objectGS.py wrapper.

Thanks Mekkablue. I have to look into the other script to see how to fix it, but I ran these lines in the macro panel and they all work.

Georg, thanks for making RoboFab easier to work with. I imported CurrentFont without needing the objectGS.py line and it worked perfectly. I’ll keep testing the scripting in Glyphs, it’s very exciting to see this working. Loving the app more and more!

What’s the best place to make feature suggestions? Would be awesome to let the macro panel load and save scripts

The forum is a good place or the bug reporter works well, too. The macro window is only meant for small things. To implement a decent coding environment, I would need to redo TextMate. So I decided to go with the script menu. If you edit the script in TextMate (or whatever text editor you like) you can switch back to Glyphs and hit cmd+opt+R and the script is executed. This works even better then having it in the macro window ;)

And if you find any problem with your scripts, please report here or per mail. I’m happy to fix them.

Thanks for being so good at responding Georg.

I see your point RE: establishing a coding environment. If I can make one last argument (and I’ll put the subject to bed, so don’t worry about responding if it doesn’t convince you): Even just having a load and save feature for the macro panel and no other bells or whistles (maybe the ability to have a few open at the time, but that would just be the cherry on the top) would be helpful with scripts like the one I’m posting here (maybe even a modifier key, like if you press ALT before clicking on the script it will offer to open it in the macro panel but, again, cherry). I could edit it externally in TextMate, or I could do dialog prompts to enter the variables, but if I have a font family and I have it in the macro panel, I can keep the family info untouched and quickly change the font info. I’ve used/seen other instances where it’s helpful to change variable on the fly and it would save time if the script could be loaded directly on the macro panel rather than opening it in TextMate and copy-pasting it (I’m still working with fonts as individual UFOs because I started the project on RoboFont, I’ll try the masters workflow with the next font family).

Alright, I’m done with RoboFab and macro questions for now. Loving Glyphs and raving to my classmates about it.


from robofab.world import CurrentFont

f = CurrentFont()
familyName = "Acapulco"
styleName = “Italic”

f.info.familyName = familyName + " Regular"
f.info.styleName = "Regular"
f.info.styleMapFamilyName = familyName + " Regular"
f.info.styleMapStyleName = "Regular"
f.info.copyright = "© 2013 This Makes Me Happy ;)"
f.info.openTypeNamePreferredFamilyName = familyName
f.info.openTypeNamePreferredSubfamilyName = styleName
f.info.openTypeNameCompatibleFullName = familyName + " " + styleName
f.info.openTypeOS2WidthClass = 5
f.info.openTypeOS2WeightClass = 500
f.info.postscriptWeightName = "Regular"
f.info.postscriptWeightName = familyName + styleName
f.info.fullName = familyName + " " + styleName

I see your point with your workflow but as you will soon see, the built-in handling of all that is much more convenient.

And I would be surprised if you couldn’t set up the interpolation in Glyphs and get the same results much faster :wink: try to get me on skype and I show you.

I am pretty sure nobody can provide better support than you guys.
Thanx a lot!