Question: Batch import EPS in Fontlab

kateliev's picture

Hi everybody,
Is there a Python script that can batch import multiple EPS files in Fontlab. Searched all over the internet, and found nothing. I need just basic functionality - start from a new empty typeface and import EPS files in sequential mode, no encoding just in index mode. Any ideas! Thank you in advance!

Mark Simonson's picture

Not sure exactly how your EPS files are set up, but ScanFont works great for moving art from .ai or .eps files into FontLab. Unfortunately, it doesn't work on Mac running Lion or Mountain Lion yet. They do have options for those in that boat, though.

twardoch's picture

This will ask you for a folder, find all ".eps" files in it and import them sequentially into the current font, using the basename of each file (without the ".eps" extension) as the glyph name. Should be enough to get you started, I hope.

#FLM: Import EPS glyphs from folder
import os.path, glob
f = fl.font
folder = fl.GetPathName("Choose folder with EPS files...")
pathmask = "*.eps"
paths = []
for globmask in [pathmask, pathmask.upper()]: 
  paths += glob.glob(os.path.join(folder, globmask))
paths = sorted(list(set(paths)))
print "Importing EPS files from %s..." % (folder)
for path in paths: 
  basename = os.path.splitext(os.path.split(path)[1])[0]
  try: 
    g = Glyph()
    g = g.LoadEPS(path)
    g.name = basename
    g.mark = 33
    f.glyphs.append(g)
    print "%s.eps imported" % (basename)
  except: 
    print "%s.eps IGNORED" % (basename)
fl.UpdateFont(fl.ifont)
print "Finished."
kateliev's picture

Thank you Adam! You are great! I will test it right away!

kateliev's picture

Oh it works like charm! Thank you again!

oldnick's picture

Vassil,

You needn't add to Adam's sense of self-worth: the jaunty hat says it all…

twardoch's picture

Oh Nick,
very deep inside, I am...
;)

empireoflight's picture

twardoch,
Can you explain how to use the script you posted? I want to batch import a bunch of eps files into fontlab, but I'm not sure how to use that script. Thanks for any direction you can give.

empireoflight's picture

frankrolf the link is broken :(

empireoflight's picture

Mark Simonson Scanfont runs as a WINE version, but I've tried several different EPS files and none seem to be able to import into the program.

jasonc's picture

all you need to do is paste Adam's code into a macro window and hit the "run" button.
There's some instruction on basic script use in the manual, I believe.

Jason C

empireoflight's picture

Thanks Jason, I got it to work.

Syndicate content Syndicate content