Created
August 10, 2014 17:21
-
-
Save alfredxing/527e07f2d0429f4a063f to your computer and use it in GitHub Desktop.
Replace font ID's for Brick SVG fonts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import re | |
fonts = glob.glob('/Users/alfred/Documents/Git/brick/fonts/*/*.svg') | |
for font in fonts: | |
print 'Processing %s...' % font, | |
font_id = os.path.basename(os.path.dirname(font)) | |
f = open(font, 'r') | |
contents = f.read() | |
contents = contents.replace('<svg>', '<svg version="1.1" xmlns="http://www.w3.org/2000/svg">') | |
contents = re.sub(r'<font id="[a-zA-Z-]+"', '<font id="%s"' % font_id, contents) | |
f.close() | |
f = open(font, 'w') | |
f.write(contents) | |
f.close() | |
print 'done.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment