diff options
author | Rasmus Andersson <rasmus@notion.se> | 2019-01-02 07:47:16 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2019-01-02 07:47:16 +0300 |
commit | 2b53ffc2fb76464be70b22640bb9c1860867bde6 (patch) | |
tree | 694a1c43899e3ed1965247646f1d2b0fe6dc8138 /misc/tools/gen-metrics-and-svgs.py | |
parent | d5165bc6711689fdb310fa96fde40356f0c0666e (diff) | |
download | inter-2b53ffc2fb76464be70b22640bb9c1860867bde6.tar.xz |
tooling update
Diffstat (limited to 'misc/tools/gen-metrics-and-svgs.py')
-rwxr-xr-x | misc/tools/gen-metrics-and-svgs.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/misc/tools/gen-metrics-and-svgs.py b/misc/tools/gen-metrics-and-svgs.py index aaea74da6..34d5d3458 100755 --- a/misc/tools/gen-metrics-and-svgs.py +++ b/misc/tools/gen-metrics-and-svgs.py @@ -3,8 +3,6 @@ # # Sync glyph shapes between SVG and UFO, creating a bridge between UFO and Figma. # -from __future__ import print_function - import os, sys from os.path import dirname, basename, abspath, relpath, join as pjoin sys.path.append(abspath(pjoin(dirname(__file__), 'tools'))) @@ -293,8 +291,8 @@ svgtext = '\n'.join(svgLines) glyphsHtmlFilename = os.path.join(BASEDIR, 'docs', 'glyphs', 'index.html') html = u'' -with open(glyphsHtmlFilename, 'r') as f: - html = f.read().decode('utf8') +with open(glyphsHtmlFilename, 'r', encoding="utf-8") as f: + html = f.read() startMarker = u'<div id="svgs">' startPos = html.find(startMarker) @@ -317,17 +315,17 @@ metaJson += '"kerning":' + fmtJsonList(kerning) + '\n' metaJson += '}' # metaHtml = '<script>var fontMetaData = ' + metaJson + ';</script>' -html = html[:startPos + len(startMarker)] + '\n' + svgtext.decode('utf8') + '\n' + html[endPos:] +html = html[:startPos + len(startMarker)] + '\n' + svgtext + '\n' + html[endPos:] print('write', relfilename) -with open(glyphsHtmlFilename, 'w') as f: - f.write(html.encode('utf8')) +with open(glyphsHtmlFilename, 'w', encoding="utf-8") as f: + f.write(html) # JSON jsonFilename = os.path.join(BASEDIR, 'docs', 'glyphs', 'metrics.json') jsonFilenameRel = os.path.relpath(jsonFilename, os.getcwd()) print('write', jsonFilenameRel) -with open(jsonFilename, 'w') as f: +with open(jsonFilename, 'w', encoding="utf-8") as f: f.write(metaJson) metaJson
\ No newline at end of file |