// Regenerates hp_1234.png: white "HP 1234" on a dark background.
// Usage: swift render_fixture.swift hp_1234.png
// NOTE: on a Retina host, lockFocus renders into a 2x backing store, so the
// output PNG is 640x96 physical pixels — this is the size the e2e test was
// validated against. Regenerating on a 1x display produces 320x48, which
// still recognizes but differs from the committed fixture; prefer
// regenerating on a Retina machine (or scale the output to 640x96).
import AppKit
let w = 320, h = 48
let img = NSImage(size: NSSize(width: w, height: h))
img.lockFocus()
NSColor(calibratedWhite: 0.12, alpha: 1).setFill()
NSRect(x: 0, y: 0, width: w, height: h).fill()
let attrs: [NSAttributedString.Key: Any] = [
.font: NSFont(name: "Helvetica-Bold", size: 30)!,
.foregroundColor: NSColor.white,
]
("HP 1234" as NSString).draw(at: NSPoint(x: 16, y: 6), withAttributes: attrs)
img.unlockFocus()
let tiff = img.tiffRepresentation!
let rep = NSBitmapImageRep(data: tiff)!
let png = rep.representation(using: .png, properties: [:])!
try! png.write(to: URL(fileURLWithPath: CommandLine.arguments[1]))