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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.4.31",
3
+ "version": "1.4.32",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
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
package/tsconfig.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "module": "commonjs",
10
10
  "strict": true//false,
11
11
  },
12
- "include": [
13
- "./src/*",
12
+ "files": [
13
+ "./src/index.ts",
14
14
  ],
15
15
  "typedocOptions": {
16
16
  "entryPoints": ["src/index.ts"],