fabric 5.4.0 → 5.4.1-browser

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.
package/package.json CHANGED
@@ -1,92 +1,89 @@
1
1
  {
2
- "name": "fabric",
3
- "description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
4
- "homepage": "http://fabricjs.com/",
5
- "version": "5.4.0",
6
- "author": "Juriy Zaytsev <kangax@gmail.com>",
7
- "contributors": [
8
- {
9
- "name": "Andrea Bogazzi",
10
- "email": "andreabogazzi79@gmail.com"
11
- },
12
- {
13
- "name": "Steve Eberhardt",
14
- "email": "melchiar2@gmail.com"
15
- }
16
- ],
17
- "keywords": [
18
- "canvas",
19
- "graphic",
20
- "graphics",
21
- "SVG",
22
- "node-canvas",
23
- "parser",
24
- "HTML5",
25
- "object model"
26
- ],
27
- "browser": {
28
- "canvas": false,
29
- "fs": false,
30
- "jsdom": false,
31
- "jsdom/lib/jsdom/living/generated/utils": false,
32
- "jsdom/lib/jsdom/utils": false,
33
- "http": false,
34
- "https": false,
35
- "xmldom": false,
36
- "url": false
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "https://github.com/fabricjs/fabric.js"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/fabricjs/fabric.js/issues"
44
- },
45
- "license": "MIT",
46
- "scripts": {
47
- "changelog": "auto-changelog -o change-output.md --unreleased-only",
48
- "build": "node build.js modules=ALL requirejs exclude=gestures,accessors,erasing",
49
- "build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors,erasing",
50
- "build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
51
- "link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link",
52
- "build_with_gestures": "node build.js modules=ALL exclude=accessors",
53
- "build_export": "npm run build:fast && npm run export_dist_to_site",
54
- "test:single": "qunit test/node_test_setup.js test/lib",
55
- "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit",
56
- "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual",
57
- "coverage:report": "nyc report --reporter=lcov --reporter=text",
58
- "test": "qunit --require ./test/node_test_setup.js test/lib test/unit",
59
- "test:visual": "qunit test/node_test_setup.js test/lib test/visual",
60
- "test:visual:single": "qunit test/node_test_setup.js test/lib",
61
- "test:all": "npm run test && npm run test:visual",
62
- "lint": "eslint --config .eslintrc.json src",
63
- "lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
64
- "export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js",
65
- "export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
66
- "export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib",
67
- "all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
68
- "testem": "testem .",
69
- "testem:ci": "testem ci"
70
- },
71
- "optionalDependencies": {
72
- "canvas": "^2.8.0",
73
- "jsdom": "^19.0.0"
74
- },
75
- "devDependencies": {
76
- "auto-changelog": "^2.3.0",
77
- "chalk": "^2.4.1",
78
- "deep-object-diff": "^1.1.7",
79
- "eslint": "4.18.x",
80
- "nyc": "^15.1.0",
81
- "onchange": "^7.1.0",
82
- "pixelmatch": "^4.0.2",
83
- "qunit": "^2.17.2",
84
- "testem": "^3.2.0",
85
- "uglify-js": "3.3.x"
86
- },
87
- "engines": {
88
- "node": ">=14.0.0"
89
- },
90
- "main": "./dist/fabric.js",
91
- "dependencies": {}
92
- }
2
+ "name": "fabric",
3
+ "description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
4
+ "homepage": "http://fabricjs.com/",
5
+ "version": "5.4.1-browser",
6
+ "author": "Juriy Zaytsev <kangax@gmail.com>",
7
+ "contributors": [
8
+ {
9
+ "name": "Andrea Bogazzi",
10
+ "email": "andreabogazzi79@gmail.com"
11
+ },
12
+ {
13
+ "name": "Steve Eberhardt",
14
+ "email": "melchiar2@gmail.com"
15
+ }
16
+ ],
17
+ "keywords": [
18
+ "canvas",
19
+ "graphic",
20
+ "graphics",
21
+ "SVG",
22
+ "node-canvas",
23
+ "parser",
24
+ "HTML5",
25
+ "object model"
26
+ ],
27
+ "browser": {
28
+ "canvas": false,
29
+ "fs": false,
30
+ "jsdom": false,
31
+ "jsdom/lib/jsdom/living/generated/utils": false,
32
+ "jsdom/lib/jsdom/utils": false,
33
+ "http": false,
34
+ "https": false,
35
+ "xmldom": false,
36
+ "url": false
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/fabricjs/fabric.js"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/fabricjs/fabric.js/issues"
44
+ },
45
+ "license": "MIT",
46
+ "scripts": {
47
+ "changelog": "auto-changelog -o change-output.md --unreleased-only",
48
+ "build": "node build.js modules=ALL requirejs exclude=gestures,accessors,erasing",
49
+ "build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors,erasing",
50
+ "build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export",
51
+ "link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link",
52
+ "build_with_gestures": "node build.js modules=ALL exclude=accessors",
53
+ "build_export": "npm run build:fast && npm run export_dist_to_site",
54
+ "test:single": "qunit test/node_test_setup.js test/lib",
55
+ "test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit",
56
+ "test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual",
57
+ "coverage:report": "nyc report --reporter=lcov --reporter=text",
58
+ "test": "qunit --require ./test/node_test_setup.js test/lib test/unit",
59
+ "test:visual": "qunit test/node_test_setup.js test/lib test/visual",
60
+ "test:visual:single": "qunit test/node_test_setup.js test/lib",
61
+ "test:all": "npm run test && npm run test:visual",
62
+ "lint": "eslint --config .eslintrc.json src",
63
+ "lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests",
64
+ "export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js",
65
+ "export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/",
66
+ "export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib",
67
+ "all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site",
68
+ "testem": "testem .",
69
+ "testem:ci": "testem ci"
70
+ },
71
+ "optionalDependencies": {},
72
+ "devDependencies": {
73
+ "auto-changelog": "^2.3.0",
74
+ "chalk": "^2.4.1",
75
+ "deep-object-diff": "^1.1.7",
76
+ "eslint": "4.18.x",
77
+ "nyc": "^15.1.0",
78
+ "onchange": "^7.1.0",
79
+ "pixelmatch": "^4.0.2",
80
+ "qunit": "^2.17.2",
81
+ "testem": "^3.2.0",
82
+ "uglify-js": "3.3.x"
83
+ },
84
+ "engines": {
85
+ "node": ">=14.0.0"
86
+ },
87
+ "main": "./dist/fabric.js",
88
+ "dependencies": {}
89
+ }
@@ -1,6 +1,9 @@
1
1
  /* _TO_SVG_START_ */
2
2
  (function() {
3
3
  var toFixed = fabric.util.toFixed,
4
+ radiansToDegrees = fabric.util.radiansToDegrees,
5
+ calcRotateMatrix = fabric.util.calcRotateMatrix,
6
+ transformPoint = fabric.util.transformPoint,
4
7
  multipleSpacesRegex = / +/g;
5
8
 
6
9
  fabric.util.object.extend(fabric.Text.prototype, /** @lends fabric.Text.prototype */ {
@@ -22,10 +25,20 @@
22
25
  * @return {String} svg representation of an instance
23
26
  */
24
27
  toSVG: function(reviver) {
25
- return this._createBaseSVGMarkup(
28
+ var textSvg = this._createBaseSVGMarkup(
26
29
  this._toSVG(),
27
30
  { reviver: reviver, noStyle: true, withShadow: true }
28
31
  );
32
+ if (this.path) {
33
+ return (
34
+ textSvg +
35
+ this._createBaseSVGMarkup(this.path._toSVG(), {
36
+ reviver: reviver,
37
+ withShadow: true,
38
+ })
39
+ );
40
+ }
41
+ return textSvg;
29
42
  },
30
43
 
31
44
  /**
@@ -91,19 +104,31 @@
91
104
  /**
92
105
  * @private
93
106
  */
94
- _createTextCharSpan: function(_char, styleDecl, left, top) {
107
+ _createTextCharSpan: function(_char, styleDecl, left, top, charBox) {
95
108
  var shouldUseWhitespace = _char !== _char.trim() || _char.match(multipleSpacesRegex),
96
109
  styleProps = this.getSvgSpanStyles(styleDecl, shouldUseWhitespace),
97
110
  fillStyles = styleProps ? 'style="' + styleProps + '"' : '',
98
111
  dy = styleDecl.deltaY, dySpan = '',
99
- NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
112
+ NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS,
113
+ angleAttr = '';
100
114
  if (dy) {
101
115
  dySpan = ' dy="' + toFixed(dy, NUM_FRACTION_DIGITS) + '" ';
102
116
  }
117
+ if (charBox.renderLeft !== undefined) {
118
+ var angle = charBox.angle;
119
+ angleAttr = ' rotate="' + toFixed(radiansToDegrees(angle), fabric.Object.NUM_FRACTION_DIGITS) + '" ';
120
+ var wBy2 = charBox.width / 2,
121
+ m = calcRotateMatrix({ angle: radiansToDegrees(angle) });
122
+ m[4] = charBox.renderLeft;
123
+ m[5] = charBox.renderTop;
124
+ var renderPoint = transformPoint({ x: -wBy2, y: 0 }, m);
125
+ left = renderPoint.x;
126
+ top = renderPoint.y;
127
+ }
103
128
  return [
104
129
  '<tspan x="', toFixed(left, NUM_FRACTION_DIGITS), '" y="',
105
130
  toFixed(top, NUM_FRACTION_DIGITS), '" ', dySpan,
106
- fillStyles, '>',
131
+ fillStyles, angleAttr, '>',
107
132
  fabric.util.string.escapeXml(_char),
108
133
  '</tspan>'
109
134
  ].join('');
@@ -123,7 +148,7 @@
123
148
 
124
149
  textTopOffset += lineHeight * (1 - this._fontSizeFraction) / this.lineHeight;
125
150
  for (var i = 0, len = line.length - 1; i <= len; i++) {
126
- timeToRender = i === len || this.charSpacing;
151
+ timeToRender = i === len || this.charSpacing || this.path;
127
152
  charsToRender += line[i];
128
153
  charBox = this.__charBounds[lineIndex][i];
129
154
  if (boxWidth === 0) {
@@ -146,7 +171,7 @@
146
171
  }
147
172
  if (timeToRender) {
148
173
  style = this._getStyleDeclaration(lineIndex, i) || { };
149
- textSpans.push(this._createTextCharSpan(charsToRender, style, textLeftOffset, textTopOffset));
174
+ textSpans.push(this._createTextCharSpan(charsToRender, style, textLeftOffset, textTopOffset, charBox));
150
175
  charsToRender = '';
151
176
  actualStyle = nextStyle;
152
177
  textLeftOffset += boxWidth;