customized-fabric 1.6.4 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|
},
|
@@ -54,6 +54,7 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
54
54
|
});
|
55
55
|
if (options?.isOriginal) {
|
56
56
|
this.rectObject?.set({ strokeWidth: 0 });
|
57
|
+
this.textObject?.set({ fontFamily: text?.fontFamily });
|
57
58
|
}
|
58
59
|
else {
|
59
60
|
if (options?.hideStroke) {
|
@@ -146,14 +147,13 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
146
147
|
},
|
147
148
|
setSizes: function (options) {
|
148
149
|
const { width, height } = options;
|
149
|
-
if (width
|
150
|
+
if (width) {
|
150
151
|
this.set({ width });
|
151
|
-
this.textObject.set({ width });
|
152
152
|
}
|
153
|
-
if (height
|
153
|
+
if (height) {
|
154
154
|
this.set({ height });
|
155
155
|
}
|
156
|
-
this.
|
156
|
+
this.fire("scaling");
|
157
157
|
},
|
158
158
|
setTextAttributes: function (options) {
|
159
159
|
this.textObject.set(options);
|