from playwright.sync_api import sync_playwright

html = """<!doctype html><html><head><meta charset="utf-8">
<link href="https://fonts.googleapis.com/css2?family=Archivo:wdth,wght@62..125,700..900&display=block" rel="stylesheet">
<style>
html,body{margin:0;background:#333}
.l{font-family:Archivo;font-weight:900;font-size:89px;line-height:1;color:#fff;
   mask-image:radial-gradient(circle,#fff 1.15px,transparent 1.35px);mask-size:4px 4px;
   -webkit-mask-image:radial-gradient(circle,#fff 1.15px,transparent 1.35px);-webkit-mask-size:4px 4px;margin:0 0 10px 0}
.s62{font-stretch:62%}
.s70{font-stretch:70%}
.s78{font-stretch:78%}
</style></head><body>
<div class="l s62">TATE</div>
<div class="l s70">TATE</div>
<div class="l s78">TATE</div>
</body></html>"""
open("/home/ubuntu/standalone/builds/23-tate-2/work/logo_test.html", "w").write(html)
with sync_playwright() as p:
    b = p.chromium.launch()
    pg = b.new_page(viewport={"width": 500, "height": 400})
    pg.goto("file:///home/ubuntu/standalone/builds/23-tate-2/work/logo_test.html")
    pg.wait_for_function("document.fonts.status === 'loaded'")
    pg.wait_for_timeout(500)
    pg.screenshot(path="/home/ubuntu/standalone/builds/23-tate-2/work/logo_test.png")
    print(pg.evaluate("""() => [...document.querySelectorAll('.l')].map(e => {
      const r = document.createRange(); r.selectNodeContents(e);
      const b = r.getBoundingClientRect(); return [e.className, b.width, b.height];
    })"""))
    b.close()
