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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.4.1]
4
+
5
+ - fix() Fix the svg export of text with path [`#10268`](https://github.com/fabricjs/fabric.js/pull/10268)
6
+
3
7
  ## [5.4.0]
4
8
 
5
9
  - fix() fix an issue with offScreen detection and background/overlay Vpt setting [`#8896`](https://github.com/fabricjs/fabric.js/pull/8896)
package/HEADER.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
2
2
 
3
- var fabric = fabric || { version: '5.4.0' };
3
+ var fabric = fabric || { version: '5.4.1' };
4
4
  if (typeof exports !== 'undefined') {
5
5
  exports.fabric = fabric;
6
6
  }
package/dist/fabric.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* build: `node build.js modules=ALL exclude=gestures,accessors,erasing requirejs minifier=uglifyjs` */
2
2
  /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */
3
3
 
4
- var fabric = fabric || { version: '5.4.0' };
4
+ var fabric = fabric || { version: '5.4.1' };
5
5
  if (typeof exports !== 'undefined') {
6
6
  exports.fabric = fabric;
7
7
  }
@@ -30392,6 +30392,9 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
30392
30392
  /* _TO_SVG_START_ */
30393
30393
  (function() {
30394
30394
  var toFixed = fabric.util.toFixed,
30395
+ radiansToDegrees = fabric.util.radiansToDegrees,
30396
+ calcRotateMatrix = fabric.util.calcRotateMatrix,
30397
+ transformPoint = fabric.util.transformPoint,
30395
30398
  multipleSpacesRegex = / +/g;
30396
30399
 
30397
30400
  fabric.util.object.extend(fabric.Text.prototype, /** @lends fabric.Text.prototype */ {
@@ -30413,10 +30416,20 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
30413
30416
  * @return {String} svg representation of an instance
30414
30417
  */
30415
30418
  toSVG: function(reviver) {
30416
- return this._createBaseSVGMarkup(
30419
+ var textSvg = this._createBaseSVGMarkup(
30417
30420
  this._toSVG(),
30418
30421
  { reviver: reviver, noStyle: true, withShadow: true }
30419
30422
  );
30423
+ if (this.path) {
30424
+ return (
30425
+ textSvg +
30426
+ this._createBaseSVGMarkup(this.path._toSVG(), {
30427
+ reviver: reviver,
30428
+ withShadow: true,
30429
+ })
30430
+ );
30431
+ }
30432
+ return textSvg;
30420
30433
  },
30421
30434
 
30422
30435
  /**
@@ -30482,19 +30495,31 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
30482
30495
  /**
30483
30496
  * @private
30484
30497
  */
30485
- _createTextCharSpan: function(_char, styleDecl, left, top) {
30498
+ _createTextCharSpan: function(_char, styleDecl, left, top, charBox) {
30486
30499
  var shouldUseWhitespace = _char !== _char.trim() || _char.match(multipleSpacesRegex),
30487
30500
  styleProps = this.getSvgSpanStyles(styleDecl, shouldUseWhitespace),
30488
30501
  fillStyles = styleProps ? 'style="' + styleProps + '"' : '',
30489
30502
  dy = styleDecl.deltaY, dySpan = '',
30490
- NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS;
30503
+ NUM_FRACTION_DIGITS = fabric.Object.NUM_FRACTION_DIGITS,
30504
+ angleAttr = '';
30491
30505
  if (dy) {
30492
30506
  dySpan = ' dy="' + toFixed(dy, NUM_FRACTION_DIGITS) + '" ';
30493
30507
  }
30508
+ if (charBox.renderLeft !== undefined) {
30509
+ var angle = charBox.angle;
30510
+ angleAttr = ' rotate="' + toFixed(radiansToDegrees(angle), fabric.Object.NUM_FRACTION_DIGITS) + '" ';
30511
+ var wBy2 = charBox.width / 2,
30512
+ m = calcRotateMatrix({ angle: radiansToDegrees(angle) });
30513
+ m[4] = charBox.renderLeft;
30514
+ m[5] = charBox.renderTop;
30515
+ var renderPoint = transformPoint({ x: -wBy2, y: 0 }, m);
30516
+ left = renderPoint.x;
30517
+ top = renderPoint.y;
30518
+ }
30494
30519
  return [
30495
30520
  '<tspan x="', toFixed(left, NUM_FRACTION_DIGITS), '" y="',
30496
30521
  toFixed(top, NUM_FRACTION_DIGITS), '" ', dySpan,
30497
- fillStyles, '>',
30522
+ fillStyles, angleAttr, '>',
30498
30523
  fabric.util.string.escapeXml(_char),
30499
30524
  '</tspan>'
30500
30525
  ].join('');
@@ -30514,7 +30539,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
30514
30539
 
30515
30540
  textTopOffset += lineHeight * (1 - this._fontSizeFraction) / this.lineHeight;
30516
30541
  for (var i = 0, len = line.length - 1; i <= len; i++) {
30517
- timeToRender = i === len || this.charSpacing;
30542
+ timeToRender = i === len || this.charSpacing || this.path;
30518
30543
  charsToRender += line[i];
30519
30544
  charBox = this.__charBounds[lineIndex][i];
30520
30545
  if (boxWidth === 0) {
@@ -30537,7 +30562,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
30537
30562
  }
30538
30563
  if (timeToRender) {
30539
30564
  style = this._getStyleDeclaration(lineIndex, i) || { };
30540
- textSpans.push(this._createTextCharSpan(charsToRender, style, textLeftOffset, textTopOffset));
30565
+ textSpans.push(this._createTextCharSpan(charsToRender, style, textLeftOffset, textTopOffset, charBox));
30541
30566
  charsToRender = '';
30542
30567
  actualStyle = nextStyle;
30543
30568
  textLeftOffset += boxWidth;