I'm trying to convert a collection of Windows Postscript files to OTF on OSX. For that, I decided to go with Fontforge because I can batch-process them with scripts in the terminal. I know little bash-scripting and no Python, but have been able to modify a script on the Fontforge site to do this: http://fontforge.sourceforge.net/scripting-tutorial.html
However, as it is, I need to modify a lot of the files by hand to get the Style to display as I like it, like "Bold Italic" instead of "BoldItalic" with no spaces. So, I've looked into the documentation and tried to use the GetTTFName() and SetTTFName() functions to do this. I can get it to set the Style (subfamily) just fine, but I get an empty string when trying to read the existing style. Opening the font in the GUI, it displays the Style under the TTF section, so it is there. What I am experimenting with:
style = GetTTFName(0x409,2)
Fontfamily=GetTTFName(0x409,1)
Print(Fontfamily)
Print(style)
if (style!="") #use 'case' ?
if (style=="BoldItalic")
style="Bold Italic"
elseif (style=="BoldCondensed")
style="Bold Condensed"
elseif (style=="BoldCondItalic")
style="Bold Italic Condensed")
elseif (style=="SemiBoldItalic")
style="SemiBold Italic"
elseif (style=="BlackItalic")
style="Black Italic"
elseif (style=="ExtraBoldItalic")
style="ExtraBold Italic"
elseif (style=="MediumItalic")
style="Medium Italic"
elseif (style=="LightItalic")
style="Light Italic"
elseif (style=="HeavyItalic")
style="Heavy Italic"
endif
SetTTFName(0x409,2,style)
endif
Generate($argv[i]:r + format)
I'm aware there would be cleaner ways of doing it, like using Case, if Bash supports it, or converting it to Python, but for now I'm keeping it simple. Ideally, the script would look for a capital letter in the Style string and add a space before it where it isn't the first letter.
In any case, the above doesn't work, as GetTTFName() always returns an empty string. The parameters for the Set and GetTTFName() function is referring to is
http://partners.adobe.com/public/developer/opentype/index_name.html#lang3
and
http://partners.adobe.com/public/developer/opentype/index_name.html#enc4
Does anyone here know enough Bash scripting, in particularly with Fontforge, to see the problem?