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())
32 for elt in html.findall(".//*[@class='expected'][@ft:id]", namespaces):
34 name = elt.get(ns('ft:id'))
35 text = elt.get(ns('ft:render'))
36 font = elt.get(ns('ft:font'))
37 variations = elt.get(ns('ft:var'), '').replace(':', '=').replace(';', ',')
39 for use in elt.findall(".//use"):
42 href = use.get(ns('xlink:href'))
44 glyphname = '.'.join(href[1:].split('/')[1].split('.')[1:])
45 glyphs.append((glyphname, x, y))
46 opts = '--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft'
48 opts = opts + ' --variations=%s' % variations
49 print ("../fonts/%s:%s:%s:%s" % (font, opts, unistr(text), glyphstr(glyphs)))
51 for elt in html.findall(".//*[@class='expected-no-crash'][@ft:id]", namespaces):
53 name = elt.get(ns('ft:id'))
54 text = elt.get(ns('ft:render'))
55 font = elt.get(ns('ft:font'))
56 variations = elt.get(ns('ft:var'), '').replace(':', '=').replace(';', ',')
59 opts = '--variations=%s' % variations
60 print ("../fonts/%s:%s:%s:*" % (font, opts, unistr(text)))
62 sys.exit(0 if found else 1)