customized-fabric 1.8.6 → 1.8.8
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.
@@ -17,7 +17,7 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
17
17
|
objectCaching: false,
|
18
18
|
...constants_1.TEXT_INPUT_OBJECT_ATTRIBUTES.stroke,
|
19
19
|
});
|
20
|
-
const { prefix = "", infix = "A", suffix = "", isAllCapital } = text ?? {};
|
20
|
+
const { prefix = "", infix = "A", suffix = "", isAllCapital, lineHeight = 1, charSpacing = 0, } = text ?? {};
|
21
21
|
const fullText = prefix + infix + suffix;
|
22
22
|
this.textObject = new fabric_1.fabric.IText("", {
|
23
23
|
originX: "center",
|
@@ -28,6 +28,8 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
28
28
|
text: isAllCapital ? fullText.toUpperCase() : fullText,
|
29
29
|
fontFamily: "",
|
30
30
|
paintFirst: "stroke",
|
31
|
+
lineHeight,
|
32
|
+
charSpacing,
|
31
33
|
});
|
32
34
|
const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
|
33
35
|
this.set(group);
|
@@ -69,22 +71,24 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
69
71
|
this.fire("scaling");
|
70
72
|
},
|
71
73
|
autoChangeFontSize: function (changeSpeed) {
|
72
|
-
|
73
|
-
|
74
|
-
while (this.width <=
|
74
|
+
let maxLineWidth = Math.max(...this.textObject.__lineWidths);
|
75
|
+
if (this.width <= maxLineWidth || this.height <= this.textObject.height) {
|
76
|
+
while (this.width <= maxLineWidth ||
|
75
77
|
this.height <= this.textObject.height) {
|
76
78
|
this.textObject.set({
|
77
79
|
fontSize: this.textObject.fontSize - changeSpeed,
|
78
80
|
});
|
81
|
+
maxLineWidth = Math.max(...this.textObject.__lineWidths);
|
79
82
|
}
|
80
83
|
}
|
81
84
|
else {
|
82
85
|
while (this.textObject.maxFontSize > this.textObject.fontSize &&
|
83
|
-
this.width >
|
86
|
+
this.width > maxLineWidth &&
|
84
87
|
this.height > this.textObject.height) {
|
85
88
|
this.textObject.set({
|
86
89
|
fontSize: this.textObject.fontSize + changeSpeed,
|
87
90
|
});
|
91
|
+
maxLineWidth = Math.max(...this.textObject.__lineWidths);
|
88
92
|
}
|
89
93
|
}
|
90
94
|
},
|
@@ -126,8 +130,8 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
126
130
|
this.textObject.set({
|
127
131
|
fontSize,
|
128
132
|
});
|
129
|
-
|
130
|
-
|
133
|
+
const maxLineWidth = Math.max(...this.textObject.__lineWidths);
|
134
|
+
if (maxLineWidth < this.width && this.textObject.height < this.height) {
|
131
135
|
}
|
132
136
|
else {
|
133
137
|
this.autoChangeFontSize(1);
|
@@ -209,6 +213,8 @@ const toTextInputObject = (object) => {
|
|
209
213
|
infix: textObject?.infix,
|
210
214
|
suffix: textObject?.suffix,
|
211
215
|
isAllCapital: textObject?.isAllCapital,
|
216
|
+
lineHeight: textObject?.lineHeight,
|
217
|
+
charSpacing: textObject?.charSpacing,
|
212
218
|
},
|
213
219
|
};
|
214
220
|
};
|