3 from __future__ import print_function, division, absolute_import
6 import xml.etree.ElementTree as ET
8 # Can we extract this from HTML element itself? I couldn't.
10 'ft': 'https://github.com/OpenType/fonttest',
11 'xlink': 'http://www.w3.org/1999/xlink',
15 return '{%s}%s' % (namespaces[ns], s)
18 return ','.join('U+%04X' % ord(c) for c in s)
22 for glyphname,x,y in glyphs:
24 out.append('%s@%d,%d' % (glyphname, x, y))
27 return '['+'|'.join(out)+']'
29 html = ET.fromstring(sys.stdin.read())
31 for elt in html.findall(".//*[@class='expected'][@ft:id]", namespaces):
33 name = elt.get(ns('ft:id'))
34 text = elt.get(ns('ft:render'))
35 font = elt.get(ns('ft:font'))
36 vars = elt.get(ns('ft:var'), '').replace(':', '=').replace(';', ',')
38 for use in elt.findall(".//use"):
41 href = use.get(ns('xlink:href'))
43 glyphname = '.'.join(href[1:].split('/')[1].split('.')[1:])
44 glyphs.append((glyphname, x, y))
45 opts = '--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft'
47 opts = opts + ' --variations=%s' % vars
48 print ("../fonts/%s:%s:%s:%s" % (font, opts, unistr(text), glyphstr(glyphs)))
50 sys.exit(0 if found else 1)