tooling update

This commit is contained in:
Rasmus Andersson 2019-01-01 21:47:16 -07:00
parent d5165bc671
commit 2b53ffc2fb
4 changed files with 9 additions and 17 deletions

View file

@ -3,8 +3,6 @@
#
# Generates JSON-encoded information about fonts
#
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')))
@ -343,7 +341,7 @@ def genFontInfo(fontpath, outputType, withGlyphs=True):
if 'panose' in os2:
panose = {}
for k,v in sstructTableToDict(os2['panose'], panoseFormat).iteritems():
for k,v in sstructTableToDict(os2['panose'], panoseFormat).items():
if k[0:1] == 'b' and k[1].isupper():
k = k[1].lower() + k[2:]
# bFooBar => fooBar
@ -369,7 +367,7 @@ def genFontInfo(fontpath, outputType, withGlyphs=True):
if 'meta' in tt:
meta = {}
for k,v in tt['meta'].data.iteritems():
for k,v in tt['meta'].data.items():
try:
v.decode('utf8')
meta[k] = v

View file

@ -3,8 +3,6 @@
#
# Grab http://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt
#
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')))
@ -14,7 +12,7 @@ import json, re
import time
from argparse import ArgumentParser
from collections import OrderedDict
from ConfigParser import RawConfigParser
from configparser import RawConfigParser
# from robofab.objects.objectsRF import OpenFont
from unicode_util import parseUnicodeDataFile
from defcon import Font

View file

@ -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

View file

@ -3,8 +3,6 @@
#
# Updates the "?v=x" in docs/inter-ui.css
#
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')))