kfb-view 3.1.3 → 3.1.4

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,7 +1,7 @@
1
1
  {
2
2
  "name": "kfb-view",
3
3
  "description": "一个在线kfb的阅片软件",
4
- "version": "3.1.3",
4
+ "version": "3.1.4",
5
5
  "author": "qifeng.fan <qifeng.fan@hzztai.com>",
6
6
  "license": "MIT",
7
7
  "main": "lib/kfb-view.js",
@@ -369,7 +369,9 @@ export class ViewerCommon extends EventEmitter {
369
369
  const ctx = this.canvas.getContext('2d');
370
370
  ctx.beginPath();
371
371
  ctx.font = `${size}px Arial`;
372
- return ctx.measureText(text).width;
372
+ const texts = text.split('\n');
373
+ const maxText = texts.sort((a, b) => a.length > b.length ? -1 : 1)[0];
374
+ return ctx.measureText(maxText).width;
373
375
  }
374
376
 
375
377
  /**
package/src/tool/Font.js CHANGED
@@ -30,7 +30,10 @@ class Font extends Brush {
30
30
  ctx.rotate(angle / 180 * Math.PI);
31
31
  ctx.scale(scale, scale);
32
32
  ctx.font = `${this.options.fontSize}px Arial`;
33
- ctx.fillText(text, 0, 0);
33
+ const texts = text.split('\n');
34
+ texts.forEach((v, index) => {
35
+ ctx.fillText(v, 0, 0 + index * this.options.fontSize);
36
+ });
34
37
  ctx.restore();
35
38
  }
36
39
  }