@postermywall/fabricjs-2 7.4.0-pmw-70 → 7.4.0-pmw-71
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/.vitest-attachments/23b206d0e2c2cbf41ea4d8dd1b0758f9c3447d6f.png +0 -0
- package/CHANGELOG.md +1 -0
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +25 -25
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +25 -25
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +16 -8
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +16 -8
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.min.mjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/src/parser/normalizeValue.d.ts.map +1 -1
- package/dist/src/parser/normalizeValue.min.mjs +1 -1
- package/dist/src/parser/normalizeValue.min.mjs.map +1 -1
- package/dist/src/parser/normalizeValue.mjs +4 -2
- package/dist/src/parser/normalizeValue.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.d.ts.map +1 -1
- package/dist/src/shapes/Text/Text.min.mjs +2 -2
- package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
- package/dist/src/shapes/Text/Text.mjs +11 -5
- package/dist/src/shapes/Text/Text.mjs.map +1 -1
- package/dist-extensions/src/parser/normalizeValue.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__screenshots__/__tmp_real_svg.spec.ts/real-Office-exported-SVG-from-order-42675801-parses--measures-and-renders-its-clipped-text-without-throwing-1.png +0 -0
- package/src/parser/loadSVGFromString.test.ts +26 -0
- package/src/parser/normalizeValue.ts +6 -0
- package/src/shapes/Text/Text.ts +18 -6
- package/src/shapes/Text/glyphOverhang.spec.ts +18 -0
- package/postermywall-fabricjs-2-7.4.0-pmw-70.tgz +0 -0
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## [next]
|
|
4
4
|
|
|
5
|
+
- fix(text): an SVG `letter-spacing: normal` (Office exports) reads as no extra spacing instead of the raw string, and a non-finite glyph reach can no longer size a text cache canvas to 0 and crash the render with `drawImage ... width or height of 0` (pmw-71)
|
|
5
6
|
- feat(text): export list markers as SVG spans where the canvas draws them, write the gradient definitions of per-character fills, and read a right-to-left line's glyph reach by each glyph's own ink (pmw-70)
|
|
6
7
|
- feat(text): measure each glyph's ink reach and size the text and group caches from it, so swashes and descenders of any font are not cut (pmw-69)
|
|
7
8
|
- Upgrade 7.4.0 [#4](https://github.com/fabricjs/fabric.js/pull/4)
|
package/dist/index.js
CHANGED
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
const cache = new Cache();
|
|
453
453
|
//#endregion
|
|
454
454
|
//#region src/constants.ts
|
|
455
|
-
const VERSION = "7.4.0-pmw-
|
|
455
|
+
const VERSION = "7.4.0-pmw-71";
|
|
456
456
|
function noop() {}
|
|
457
457
|
const halfPI = Math.PI / 2;
|
|
458
458
|
const quarterPI = Math.PI / 4;
|
|
@@ -8745,8 +8745,10 @@
|
|
|
8745
8745
|
ouputValue = parseFloat(value);
|
|
8746
8746
|
if (parentAttributes && typeof parentAttributes.opacity !== "undefined") ouputValue *= parentAttributes.opacity;
|
|
8747
8747
|
} else if (attr === "textAnchor") ouputValue = value === "start" ? LEFT : value === "end" ? RIGHT : CENTER;
|
|
8748
|
-
else if (attr === "charSpacing" || attr === "textDecorationThickness")
|
|
8749
|
-
|
|
8748
|
+
else if (attr === "charSpacing" || attr === "textDecorationThickness") {
|
|
8749
|
+
parsed = parseUnit(value, fontSize) / fontSize * 1e3;
|
|
8750
|
+
if (attr === "charSpacing" && !Number.isFinite(parsed)) parsed = 0;
|
|
8751
|
+
} else if (attr === "paintFirst") {
|
|
8750
8752
|
const fillIndex = value.indexOf(FILL);
|
|
8751
8753
|
const strokeIndex = value.indexOf(STROKE);
|
|
8752
8754
|
ouputValue = FILL;
|
|
@@ -16125,6 +16127,12 @@
|
|
|
16125
16127
|
/** Peak rise = (period / 2) × this factor: 6.75 text units at the reference size. */
|
|
16126
16128
|
const SQUIGGLY_LINE_WAVE_RISE_FACTOR = 5 * .45;
|
|
16127
16129
|
/**
|
|
16130
|
+
* *PMW* `Math.max` over the finite candidates only. A NaN or infinite reach (a character
|
|
16131
|
+
* bound poisoned by bad input) must never size a cache canvas: `canvas.width = NaN` is 0 and
|
|
16132
|
+
* the next `drawImage` of that canvas throws.
|
|
16133
|
+
*/
|
|
16134
|
+
const maxFinite = (current, ...candidates) => candidates.reduce((max, candidate) => Number.isFinite(candidate) ? Math.max(max, candidate) : max, current);
|
|
16135
|
+
/**
|
|
16128
16136
|
* Text class
|
|
16129
16137
|
* @see {@link http://fabric5.fabricjs.com/fabric-intro-part-2#text}
|
|
16130
16138
|
*/
|
|
@@ -16347,16 +16355,16 @@
|
|
|
16347
16355
|
for (let charIndex = 0; bounds && charIndex < this._textLines[lineIndex].length; charIndex++) {
|
|
16348
16356
|
const box = bounds[charIndex], ink = box.ink;
|
|
16349
16357
|
if (!ink) continue;
|
|
16350
|
-
horizontal = isRtl ?
|
|
16351
|
-
if (lineIndex === 0) vertical =
|
|
16352
|
-
if (lineIndex === lineCount - 1) vertical =
|
|
16358
|
+
horizontal = isRtl ? maxFinite(horizontal, ink.left, ink.right - box.width) : maxFinite(horizontal, ink.left - box.left - leftOffset, box.left + ink.right - rightEdge);
|
|
16359
|
+
if (lineIndex === 0) vertical = maxFinite(vertical, ink.ascent - box.deltaY - baselineFromTop);
|
|
16360
|
+
if (lineIndex === lineCount - 1) vertical = maxFinite(vertical, ink.descent + box.deltaY - roomBelowBaseline);
|
|
16353
16361
|
}
|
|
16354
16362
|
lineTop += this.getHeightOfLine(lineIndex);
|
|
16355
16363
|
}
|
|
16356
16364
|
const strokeReach = this.stroke ? this.strokeWidth / 2 : 0;
|
|
16357
16365
|
return {
|
|
16358
|
-
horizontal:
|
|
16359
|
-
vertical:
|
|
16366
|
+
horizontal: maxFinite(0, horizontal + strokeReach),
|
|
16367
|
+
vertical: maxFinite(0, vertical + strokeReach)
|
|
16360
16368
|
};
|
|
16361
16369
|
}
|
|
16362
16370
|
/**
|