SOLVED Mass-import ligatures/svgs
-
Hi, i am new to RoboFont, not sure if this is possible.
I have a list of ligature definitions (e.g.
a_b.liga
), and i want to use a script to import the list and then insert a glyph for each ligature (from svg files, e.g.a_b.svg
).Can i do that with RoboFont? Is there a similar project/tutorial that can point me in the right direction?
Thanks a lot!
Flo
-
@gferreira I was able to get it to work once I downloaded additional module files. thanks!
-
hello @kylelynah,
the script uses simple_svg_parser, you need to download it separately. save
simple_svg_parser.py
next to your script, or add the module with code:import sys libFolder = '/someFolder/importSVG/simple_svg_parser' if not libFolder in sys.path: sys.path.insert(0, libFolder) # ...
good luck!
-
Hey @gferreira! Could you help me understand how I could get this script to work in RF 3.4? I can't seem to figure out how to be sure all the right python modules are installed. When I attempted the script it gave me:
AttributeError: module 'simple_svg_parser' has no attribute 'parse'
-
hello @flo, happy to hear that the import script worked.
you can add features to a font using the Features Editor or with a script:
feaCode = '''\ # language statements etc. feature liga { sub a b by a_b.liga; sub ... } liga; ''' f = CurrentFont() f.features.text = feaCode
good luck!
-
That worked great, thanks a lot!
Now, simply importing the glyph names as
a_b.liga
does not result in substitution, as i understand i need to add them to the features like this:feature liga { sub a b by a_b.liga; sub ... } liga;
How do i do that with a script?
-
That looks great, will try it and let you know!
Thanks a lot!
-
hello @flo,
I’ve had to do something similar in the past, it can be solved with a bit of scripting.
see svg2robofont.py and the included example.
let me know if you need some help to get it to work… cheers!
edit: here’s an example script which imports all SVGs in a folder into glyphs:
import glob, os from svg2robofont import SVGPen svgs = glob.glob('tests2/*.svg') f = NewFont() for svg in svgs: name = os.path.splitext(os.path.basename(svg))[0] g = f.newGlyph(name) svgPen = SVGPen(svg, g.getPen()) g.width = svgPen.handler.width