customized-fabric 2.0.19 → 2.0.21
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.
@@ -48,14 +48,27 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
|
|
48
48
|
pathVisible: !(options?.isOriginal || options?.hideStroke),
|
49
49
|
});
|
50
50
|
this.on("scaling", () => {
|
51
|
-
|
52
|
-
let height = this.height * this.scaleY;
|
51
|
+
const { width, height, scaleX, scaleY } = this;
|
53
52
|
const attributes = {
|
54
53
|
scaleX: 1,
|
55
54
|
scaleY: 1,
|
56
|
-
width,
|
57
|
-
height,
|
55
|
+
width: width * scaleX,
|
56
|
+
height: height * scaleY,
|
58
57
|
};
|
58
|
+
const { fontSize, maxFontSize, fontSizeScalable, strokeWidth } = this.textObject;
|
59
|
+
if (fontSizeScalable) {
|
60
|
+
// font scaling
|
61
|
+
const fontSizeRatio = maxFontSize / Math.min(width, height);
|
62
|
+
const newMaxFontSize = fontSizeRatio * Math.min(attributes.width, attributes.height);
|
63
|
+
// stroke width scaling
|
64
|
+
const strokeWidthRatio = strokeWidth / Math.min(width, height);
|
65
|
+
const newStrokeWidth = strokeWidthRatio * Math.min(attributes.width, attributes.height);
|
66
|
+
this.textObject.set({
|
67
|
+
maxFontSize: newMaxFontSize,
|
68
|
+
fontSize: Math.min(fontSize, newMaxFontSize),
|
69
|
+
strokeWidth: newStrokeWidth,
|
70
|
+
});
|
71
|
+
}
|
59
72
|
this.set(attributes);
|
60
73
|
this.rectObject.set(attributes);
|
61
74
|
this.calculateTextPath(width, height);
|
@@ -42,13 +42,18 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
42
42
|
width: width * scaleX,
|
43
43
|
height: height * scaleY,
|
44
44
|
};
|
45
|
-
const { fontSize, maxFontSize, fontSizeScalable } = this.textObject;
|
45
|
+
const { fontSize, maxFontSize, fontSizeScalable, strokeWidth } = this.textObject;
|
46
46
|
if (fontSizeScalable) {
|
47
|
+
// font scaling
|
47
48
|
const fontSizeRatio = maxFontSize / Math.min(width, height);
|
48
49
|
const newMaxFontSize = fontSizeRatio * Math.min(attributes.width, attributes.height);
|
50
|
+
// stroke width scaling
|
51
|
+
const strokeWidthRatio = strokeWidth / Math.min(width, height);
|
52
|
+
const newStrokeWidth = strokeWidthRatio * Math.min(attributes.width, attributes.height);
|
49
53
|
this.textObject.set({
|
50
54
|
maxFontSize: newMaxFontSize,
|
51
55
|
fontSize: Math.min(fontSize, newMaxFontSize),
|
56
|
+
strokeWidth: newStrokeWidth,
|
52
57
|
});
|
53
58
|
}
|
54
59
|
this.set(attributes);
|