kfb-view 3.1.3 → 3.1.5
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
|
@@ -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
|
/**
|
|
@@ -33,6 +33,7 @@ export class Tailoring extends ViewerCommon {
|
|
|
33
33
|
suffix: 'jpeg',
|
|
34
34
|
quality: 0.92,
|
|
35
35
|
resolution: 1200,
|
|
36
|
+
shape: true,
|
|
36
37
|
...this.options,
|
|
37
38
|
};
|
|
38
39
|
}
|
|
@@ -331,7 +332,7 @@ export class Tailoring extends ViewerCommon {
|
|
|
331
332
|
copyCtx.fillRect(0, 0, copyCanvas.width, copyCanvas.height);
|
|
332
333
|
copyCtx.putImageData(imageData, 0, 0, 0, 0, disWidth, disHeight);
|
|
333
334
|
const shapeCanvas = this.kv.shape?.canvas;
|
|
334
|
-
if (shapeCanvas) {
|
|
335
|
+
if (shapeCanvas && this.options.shape) {
|
|
335
336
|
copyCtx.drawImage(shapeCanvas, startPoint.x * radioX,
|
|
336
337
|
startPoint.y * radioY, disWidth, disHeight, 0, 0, disWidth,
|
|
337
338
|
disHeight);
|
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
|
}
|