I'm trying to use these excellent weather glyphs in Inkscape, rather than as a font in a browser. Is there a way I can convert them into regular SVG files that I can import?
Thanks a lot, Alex
I eventually used the method outlined by Gabi at Helpful Sheep. Here is the code I used to split the .svg file into a whole bunch of separate .svg files numbered sequentially:
import sys
if len(sys.argv) < 2:
print 'Usage: python {} webfont-file.svg'.format(sys.argv[0])
sys.exit()
with open(sys.argv[1], 'r') as r:
lines = r.read().split('\n')
glyphs = [x for x in lines if '<glyph' in x]
# for every glyph element in the file
for i in range(0, len(glyphs)):
with open(str(i + 1).rjust(3, '0') + '.svg', 'w') as w:
w.write('<?xml version="1.0" standalone="no"?>\n')
w.write('<svg width="1500px" height="1500px" version="1.1" xmlns="http://www.w3.org/2000/svg">\n')
# replace 'glyph' with 'path' and flip vertically
w.write(glyphs[i].replace('<glyph', '<path transform="scale(1, -1) translate(0, -1500)"') + '\n')
w.write('</svg>')
The biggest problem was that the individual SVGs weren't labeled, so I had to go and manually identify which ones were the ones I wanted. After a while blindly stumbling through the files, I thought it would be a little simpler with a map, so I made a version of the program above that dumps everything to one SVG in a long line so I could back out what file was what:
import sys
if len(sys.argv) < 2:
print 'Usage: python {} webfont-file.svg'.format(sys.argv[0])
sys.exit()
with open(sys.argv[1], 'r') as r:
lines = r.read().split('\n')
glyphs = [x for x in lines if '<glyph' in x]
# for every glyph element in the file
with open(str(1).rjust(3, '0') + '.svg', 'w') as w:
w.write('<?xml version="1.0" standalone="no"?>\n')
w.write('<svg width="1500px" height="1500px" version="1.1" xmlns="http://www.w3.org/2000/svg">\n')
for i in range(0, len(glyphs)):
# replace 'glyph' with 'path' and flip vertically
x = 3000 * i
w.write(glyphs[i].replace('<glyph', '<path transform="scale(1, -1) translate({}, -1500)"'.format(x)) + '\n')
w.write('</svg>')