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/lib/kfb-view.js +1 -1
- package/package.json +1 -1
- package/src/components/common/common.js +3 -1
- package/src/tool/Font.js +4 -1
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
}
|