Not quite sure how to word this properly, but if I run my script within the directory of files it works on, all is fine. If I point the script to the files from another directory, it fails. I'm sure it's some sort of path expansion or something, but I just can't seem to make it work.
Here is the fontforge script.
#!/usr/bin/fontforge
Open($1)
fname = ($1:r)
Print(fname)
SetTTFName(0x409,2,"")
SetFontNames(fname,fname,fname,"")
Print($fullname)
Print($familyname)
Print(GetTTFName(0x409,2))
Generate($1:r + ".ttf")
and the command that fails:
./fix_font_names ~/Fonts_Other/*
and the error:
SetFontNames: Invalid character in PostScript name token (probably fontname): : /home/akovia/Fonts_Other/Al Fresco Bold
Called from...
./fix_font_names: line 7
The errors change if for example I put $1 in quotes or fname, but the script works perfectly if I call it from within the working directory.
I know I'm missing something obvious, but I just can't figure it out. Thanks for any help.
I don't know anything about fontforge but the syntax looks somewhat similar to shell so I'll have a shot:
Could it be a problem with spaces in variable names? If you run the script from within the directory then the directory name is just ./
, no spaces. However if you run it from elsewhere the directory name is /home/akovia/Fonts_Other/Al Fresco Bold
, which contains spaces. Try quoting every occurrence of all your variables in the script?
edit: just had a quick skim of the language tutorial and it doesn't mention any issues with spaces.
Here's another idea: if you are not in the directory then your fname
variable contains more than just the font name (it also contains the directory name). Try removing the extra information somehow.