customized-fabric 1.6.4 → 1.6.5

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
- if (options?.fontUrl) {
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.calculateTextPath(this.width, this.height);
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
  },
@@ -146,14 +146,13 @@ const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
146
146
  },
147
147
  setSizes: function (options) {
148
148
  const { width, height } = options;
149
- if (width && width > this.textObject.__lineWidths) {
149
+ if (width) {
150
150
  this.set({ width });
151
- this.textObject.set({ width });
152
151
  }
153
- if (height && height > this.textObject.height) {
152
+ if (height) {
154
153
  this.set({ height });
155
154
  }
156
- this.canvas?.renderAll?.();
155
+ this.fire("scaling");
157
156
  },
158
157
  setTextAttributes: function (options) {
159
158
  this.textObject.set(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",