x4js 1.4.32 → 1.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/drawtext.d.ts +1 -0
- package/lib/drawtext.js +9 -3
- package/package.json +1 -1
package/lib/drawtext.d.ts
CHANGED
package/lib/drawtext.js
CHANGED
|
@@ -200,7 +200,8 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
202
|
//print all lines of text
|
|
203
|
-
let idx = 1, yy = 0;
|
|
203
|
+
//let idx = 1, yy = 0;
|
|
204
|
+
let maxw = 0;
|
|
204
205
|
textarray.some(line => {
|
|
205
206
|
//console.log( idx++, yy );
|
|
206
207
|
line.space = spaceW;
|
|
@@ -208,6 +209,7 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
208
209
|
_justify(line, col_width, spaceW);
|
|
209
210
|
}
|
|
210
211
|
let x = col_left;
|
|
212
|
+
let cw = 0;
|
|
211
213
|
if (align == 1) {
|
|
212
214
|
x += col_width - line.width;
|
|
213
215
|
}
|
|
@@ -234,9 +236,13 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
234
236
|
ctx.stroke( );*/
|
|
235
237
|
ctx.fillText(w.text, x, y);
|
|
236
238
|
x += w.width + line.space;
|
|
239
|
+
cw += w.width + line.space;
|
|
237
240
|
});
|
|
238
241
|
y += lineHeight;
|
|
239
|
-
yy += lineHeight;
|
|
242
|
+
//yy += lineHeight;
|
|
243
|
+
if (maxw < cw) {
|
|
244
|
+
maxw = cw;
|
|
245
|
+
}
|
|
240
246
|
if (y > (rc.bottom + lineHeight)) {
|
|
241
247
|
y = col_top;
|
|
242
248
|
col_left += col_width + gap;
|
|
@@ -248,7 +254,7 @@ function drawText(ctx, input_Text, rc, drawStyle) {
|
|
|
248
254
|
ctx.restore();
|
|
249
255
|
//console.timeEnd( 'drawtext' );
|
|
250
256
|
// todo autogrow + multi-columns
|
|
251
|
-
return { height: (textarray.length + 0.3) * lineHeight };
|
|
257
|
+
return { width: maxw, height: (textarray.length + 0.3) * lineHeight };
|
|
252
258
|
}
|
|
253
259
|
exports.drawText = drawText;
|
|
254
260
|
// Calculate Height of the font
|