refactor: move registerFont call outside of wrapText function in meme.js
This commit is contained in:
@@ -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(" ");
|
||||
|
||||
Reference in New Issue
Block a user