canvas-hypertxt
canvas-hypertxt copied to clipboard
Cannot use textwrapping function
function renderWrappedText(ctx, value, width, x, y, fontSize, lineHeight) {
ctx.font = "600 " + fontSize + "px sans-serif";
let lines = split(ctx, value, fontSize + "px sans-serif", width, true);
for (const line of lines) {
ctx.fillText(line, x, y);
y += lineHeight;
}
}
I use this code to make my project, and if I don't setctx.font = "600 " + fontSize + "px sans-serif";
the font will be very small. But that can make the wrapping function work.