( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
const fs = require('fs');
const puppeteer = require('puppeteer');
(async () => {
// Your SVG content as a string
const svgContent = `
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" style="background-color: #F5B069;">
<foreignObject x="0" y="0" width="200" height="200">
<div xmlns="http://www.w3.org/1999/xhtml" style="
width: 170px;
height: 122.4px;
margin: 0;
position: absolute;
top: 38.8px;
left: 15px;
display: flex;
align-items: center;
justify-content: center;
">
<svg style="background-color: #F5B069;" xmlns="http://www.w3.org/2000/svg" class="autocenter" viewBox="0 0 250 180" preserveAspectRatio="xMidYMid meet"><g transform="translate(0,50%)">
<defs xmlns:default="http://www.w3.org/2000/svg">
<style type="text/css">
@font-face {
font-family: 'Orbitron';
src: url('https://fonts.gstatic.com/s/orbitron/v19/yMJMMIlzdpvBhQQL_SC3X9yhF25-T1nyxSmxpmIyXjU1pg.ttf') format('woff');
}
.google-font-3 {
font-family: 'Orbitron', sans-serif;
font-size: 58px;
line-height:1.09;
fill: #4F0D28;
letter-spacing:0.02;
}
.google-font-slogan-3 {
font-family: 'Orbitron', sans-serif;
font-size: 38px;
line-height:-18.91;
fill: #4F0D28;
letter-spacing:0.02;
}
</style>
</defs><g xmlns:default="http://www.w3.org/2000/svg" transform="translate(10,20) scale(0.25)"><svg style="background-color: #F5B069;" xmlns="http://www.w3.org/2000/svg" fill="#4F0D28" viewBox="0 0 24 24" id="airplane" data-name="Flat Color" class="icon flat-color"><g transform="translate(24/2,24/2)"><path id="primary" d="M11.92,19.58,15.84,14H20a2,2,0,0,0,0-4H15.84L11.92,4.42A1,1,0,0,0,11.11,4h-.93a1,1,0,0,0-1,1.16L10,10H6.38L4.68,8.29A1.05,1.05,0,0,0,4,8H3a1,1,0,0,0-.89,1.45L3.38,12,2.11,14.55A1,1,0,0,0,3,16H4a1.05,1.05,0,0,0,.71-.29L6.38,14H10l-.81,4.84a1,1,0,0,0,1,1.16h.93A1,1,0,0,0,11.92,19.58Z" style="fill: rgb(0, 0, 0);"></path></g></svg></g><text fill="#6900AA" style="fill:#4F0D28;fill:#6900AA;" xmlns:default="http://www.w3.org/2000/svg" x="10" y="120" text-anchor="left" font-size="30" class="google-font-3">newx</text><text fill="#6900AA" style="fill:#4F0D28;fill:#6900AA;" xmlns:default="http://www.w3.org/2000/svg" x="10" y="154" text-anchor="left" font-size="7" class="google-font-slogan-3"></text></g></svg>
</div>
</foreignObject>
</svg>
`;
// Launch Puppeteer
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
// Set viewport to SVG size
await page.setViewport({ width: 1000, height: 1000 });
// Create a data URL for the SVG content
const svgDataUrl = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgContent);
// Navigate to the SVG data URL
await page.goto(svgDataUrl);
// Wait for fonts to load (important for @font-face)
await page.evaluate(async () => {
const fonts = document.fonts;
if (fonts.status !== 'loaded') {
await fonts.ready;
}
});
// Take a screenshot of the page (which is the SVG)
await page.screenshot({ path: 'tmp/output.png' });
await browser.close();
console.log('SVG has been converted to output.png');
})();