WIP: Letters are now inside canvas, and multiline support is functional. There is a small bug where when there are a lot of multiple lines, the font gets smaller.

This commit is contained in:
Dimitrios Kaitantzidis 2023-10-08 15:58:23 +03:00
parent a71e813e82
commit b0f8f56650

View file

@ -210,12 +210,14 @@ select#font-select, select#font-select option {
const textWidth = ctx.measureText(sigText).width;
const textHeight = fontSize;
canvas.width = textWidth;
canvas.height = textHeight*1.35; //for tails
// ctx.font = `${fontSize / 2}px ${font}`;
ctx.font = `${fontSize / 2}px ${font}`;
let paragraphs = sigText.split(/\r?\n/);
canvas.width = textWidth;
canvas.height = paragraphs.length * textHeight*1.35; //for tails
// ctx.font = `${fontSize / 2}px ${font}`;
ctx.font = `${fontSize}px ${font}`;
ctx.textBaseline = 'top';
// let y = fontSize;
@ -227,10 +229,9 @@ select#font-select, select#font-select option {
paragraphs.forEach(paragraph => {
// ctx.letterSpacing = "50px";
ctx.fillText(paragraph, 0, y);
y += 24;
y += fontSize;
});
// ctx.fillText(sigText, 0, fontSize);
const dataURL = canvas.toDataURL();