customized-fabric 1.6.3 → 1.6.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.
@@ -52,6 +52,7 @@ export default class CurvedText extends fabric.Group {
|
|
52
52
|
setMaxFontSize?: (fontSize: string) => void;
|
53
53
|
setFontFamily?: (fontName: string, fontUrl?: string) => void;
|
54
54
|
setTextAttributes?: (options: fabric.ITextOptions) => void;
|
55
|
+
setTextWidth?: (width: number) => void;
|
55
56
|
getTextAttribute?: (attribute: string) => any;
|
56
57
|
getSettings?: (attribute: string) => any;
|
57
58
|
setSizes?: (options: {
|
@@ -24,6 +24,7 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
|
|
24
24
|
textAlign: "center",
|
25
25
|
objectCaching: false,
|
26
26
|
...text,
|
27
|
+
fontFamily: "",
|
27
28
|
});
|
28
29
|
const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
|
29
30
|
this.set(group);
|
@@ -50,8 +51,6 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
|
|
50
51
|
objectCaching: false,
|
51
52
|
pathVisible: !(options?.isOriginal || options?.hideStroke),
|
52
53
|
});
|
53
|
-
this.autoChangeFontSize(0.1);
|
54
|
-
this.calculateTextPath(this.width, this.height);
|
55
54
|
if (options?.isOriginal) {
|
56
55
|
this.rectObject?.set({ strokeWidth: 0 });
|
57
56
|
}
|
@@ -59,12 +58,9 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
|
|
59
58
|
if (options?.hideStroke) {
|
60
59
|
this.rectObject?.set({ strokeWidth: 0 });
|
61
60
|
}
|
62
|
-
|
63
|
-
(0, utils_1.loadFontFromUrl)(options?.fontUrl, text?.fontFamily ?? "").then(() => {
|
64
|
-
this.canvas?.renderAll?.();
|
65
|
-
});
|
66
|
-
}
|
61
|
+
this.setFontFamily(text?.fontFamily ?? "", options?.fontUrl);
|
67
62
|
}
|
63
|
+
this.fire("scaling");
|
68
64
|
},
|
69
65
|
autoChangeFontSize: function (changeSpeed) {
|
70
66
|
if (this.textObject.curvedWidth <= this.textObject.__lineWidths) {
|
@@ -142,19 +138,20 @@ const CurvedTextClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group,
|
|
142
138
|
const { width, height } = options;
|
143
139
|
if (width) {
|
144
140
|
this.set({ width });
|
145
|
-
this.rectObject.set({ width });
|
146
141
|
}
|
147
142
|
if (height) {
|
148
143
|
this.set({ height });
|
149
|
-
this.rectObject.set({ height });
|
150
144
|
}
|
151
|
-
this.
|
152
|
-
this.canvas?.renderAll?.();
|
145
|
+
this.fire("scaling");
|
153
146
|
},
|
154
147
|
setTextAttributes: function (options) {
|
155
148
|
this.textObject.set(options);
|
156
149
|
this.canvas?.renderAll?.();
|
157
150
|
},
|
151
|
+
setTextWidth: function (width) {
|
152
|
+
this.textObject.set({ curvedWidth: width });
|
153
|
+
this.autoChangeFontSize(0.1);
|
154
|
+
},
|
158
155
|
getTextAttribute: function (attribute) {
|
159
156
|
return this.textObject.get(attribute);
|
160
157
|
},
|
@@ -23,6 +23,7 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
23
23
|
textAlign: "center",
|
24
24
|
objectCaching: false,
|
25
25
|
...text,
|
26
|
+
fontFamily: "",
|
26
27
|
});
|
27
28
|
const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
|
28
29
|
this.set(group);
|
@@ -58,9 +59,7 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
58
59
|
if (options?.hideStroke) {
|
59
60
|
this.rectObject?.set({ strokeWidth: 0 });
|
60
61
|
}
|
61
|
-
|
62
|
-
(0, utils_1.loadFontFromUrl)(options?.fontUrl, text?.fontFamily ?? "");
|
63
|
-
}
|
62
|
+
this.setFontFamily(text?.fontFamily ?? "", options?.fontUrl);
|
64
63
|
}
|
65
64
|
this.fire("scaling");
|
66
65
|
},
|
@@ -147,14 +146,13 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
147
146
|
},
|
148
147
|
setSizes: function (options) {
|
149
148
|
const { width, height } = options;
|
150
|
-
if (width
|
149
|
+
if (width) {
|
151
150
|
this.set({ width });
|
152
|
-
this.textObject.set({ width });
|
153
151
|
}
|
154
|
-
if (height
|
152
|
+
if (height) {
|
155
153
|
this.set({ height });
|
156
154
|
}
|
157
|
-
this.
|
155
|
+
this.fire("scaling");
|
158
156
|
},
|
159
157
|
setTextAttributes: function (options) {
|
160
158
|
this.textObject.set(options);
|