From 889013e427d7065a362816b68024320248bdf111 Mon Sep 17 00:00:00 2001 From: Aviad Sofer Date: Thu, 1 Apr 2021 15:54:52 +0300 Subject: [PATCH] Add direction option --- lib/textToImage.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/textToImage.js b/lib/textToImage.js index f90fb21..d5546c0 100644 --- a/lib/textToImage.js +++ b/lib/textToImage.js @@ -18,6 +18,7 @@ const defaults = { const createTextData = ( text, + direction, maxWidth, fontSize, lineHeight, @@ -43,6 +44,9 @@ const createTextData = ( } textContext.textAlign = textAlign; + // set direction + textContext.direction = direction; + // make background the color passed in textContext.fillStyle = bgColor; textContext.fillRect(0, 0, textCanvas.width, textCanvas.height); @@ -108,6 +112,7 @@ const createTextData = ( const createCanvas = (content, conf) => { const textData = createTextData( content, + conf.direction, conf.maxWidth - conf.margin, conf.fontSize, conf.lineHeight,