x4js 1.4.31 → 1.4.32
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/package.json +1 -1
- package/src/drawtext.ts +12 -3
- package/tsconfig.json +2 -2
package/package.json
CHANGED
package/src/drawtext.ts
CHANGED
|
@@ -261,7 +261,9 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
//print all lines of text
|
|
264
|
-
let idx = 1, yy = 0;
|
|
264
|
+
//let idx = 1, yy = 0;
|
|
265
|
+
|
|
266
|
+
let maxw = 0;
|
|
265
267
|
textarray.some( line => {
|
|
266
268
|
|
|
267
269
|
//console.log( idx++, yy );
|
|
@@ -272,6 +274,8 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
let x = col_left;
|
|
277
|
+
let cw = 0;
|
|
278
|
+
|
|
275
279
|
if (align == 1) {
|
|
276
280
|
x += col_width - line.width;
|
|
277
281
|
}
|
|
@@ -302,10 +306,15 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
302
306
|
|
|
303
307
|
ctx.fillText(w.text, x, y);
|
|
304
308
|
x += w.width + line.space;
|
|
309
|
+
cw += w.width + line.space;
|
|
305
310
|
});
|
|
306
311
|
|
|
307
312
|
y += lineHeight;
|
|
308
|
-
yy += lineHeight;
|
|
313
|
+
//yy += lineHeight;
|
|
314
|
+
|
|
315
|
+
if( maxw<cw ) {
|
|
316
|
+
maxw = cw;
|
|
317
|
+
}
|
|
309
318
|
|
|
310
319
|
if (y > (rc.bottom+lineHeight) ) {
|
|
311
320
|
y = col_top;
|
|
@@ -321,7 +330,7 @@ export function drawText(ctx: CanvasRenderingContext2D, input_Text: string, rc:
|
|
|
321
330
|
//console.timeEnd( 'drawtext' );
|
|
322
331
|
|
|
323
332
|
// todo autogrow + multi-columns
|
|
324
|
-
return { height: (textarray.length+0.3) * lineHeight };
|
|
333
|
+
return { width: maxw, height: (textarray.length+0.3) * lineHeight };
|
|
325
334
|
}
|
|
326
335
|
|
|
327
336
|
// Calculate Height of the font
|