Skip to content

Instantly share code, notes, and snippets.

@Saigesp
Created June 21, 2016 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saigesp/2a305ac71d4e27a77bd74ad645086767 to your computer and use it in GitHub Desktop.
Save Saigesp/2a305ac71d4e27a77bd74ad645086767 to your computer and use it in GitHub Desktop.
import sys
with open('svg-font.svg', '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>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment