refactor: move registerFont call outside of wrapText function in meme.js

This commit is contained in:
Fd
2026-02-20 16:38:09 +07:00
parent 30d7d298df
commit d9c67e6cfe
+2 -2
View File
@@ -1,10 +1,10 @@
import Canvas, { registerFont} from "canvas";
const wrapText = (ctx, text, maxWidth) => {
registerFont(`./assets/fonts/Impact.ttf`, {
family: "Impact",
});
const wrapText = (ctx, text, maxWidth) => {
if(ctx.measureText(text).width < maxWidth) return [text];
if(ctx.measureText("W").width > maxWidth) return null;
const words = text.split(" ");