Files
erp/test/emoji2png.ts
T

17 lines
760 B
TypeScript

// Rend un emoji en PNG transparent via Chromium, qui sait lire Apple Color
// Emoji là où weasyprint échoue (format bitmap sbix, non géré).
import { chromium } from "playwright";
const [outDir, ...emojis] = Deno.args;
const b = await chromium.launch({ headless: true });
const p = await (await b.newContext({ deviceScaleFactor: 8 })).newPage();
for (const [i, e] of emojis.entries()) {
await p.setContent(
`<body style="margin:0"><span id="g" style="font-family:'Apple Color Emoji';` +
`font-size:64px;line-height:1;display:inline-block">${e}</span></body>`);
const el = p.locator("#g");
const f = `${outDir}/emoji-${i + 1}.png`;
await el.screenshot({ path: f, omitBackground: true });
console.log(` ${e} -> ${f}`);
}
await b.close();