Untitled

 avatar
unknown
plain_text
a year ago
662 B
5
Indexable
const canvas = document.createElement('canvas');
canvas.width = 400;
canvas.height = 200;

const ctx = canvas.getContext('2d');
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, canvas.width, canvas.height);

ctx.font = '30px Arial';
ctx.fillStyle = 'black';

const banglaText = 'বাংলায় চু;

const textWidth = ctx.measureText(banglaText).width;
const x = (canvas.width - textWidth) / 2;
const y = canvas.height / 2;

ctx.fillText(banglaText, x, y);

const dataURL = canvas.toDataURL();
const a = document.createElement('a');
a.href = dataURL;
a.download = 'bangla_text_image.png';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
Editor is loading...
Leave a Comment