@pixldocs/canvas-renderer 0.5.22 → 0.5.23
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/dist/index.cjs +10 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14527,19 +14527,21 @@ function convertTextDecorationsToLines(svg) {
|
|
|
14527
14527
|
const fontFamily = tspan.getAttribute("font-family") || textEl.getAttribute("font-family") || "sans-serif";
|
|
14528
14528
|
const fontWeight = tspan.getAttribute("font-weight") || textEl.getAttribute("font-weight") || "normal";
|
|
14529
14529
|
const fill = tspan.getAttribute("fill") || textEl.getAttribute("fill") || "#000000";
|
|
14530
|
-
let textWidth;
|
|
14531
|
-
if (ctx) {
|
|
14532
|
-
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
|
|
14533
|
-
textWidth = ctx.measureText(content).width;
|
|
14534
|
-
} else {
|
|
14535
|
-
textWidth = content.length * fontSize * 0.6;
|
|
14536
|
-
}
|
|
14530
|
+
let textWidth = 0;
|
|
14537
14531
|
if (typeof tspan.getComputedTextLength === "function") {
|
|
14538
14532
|
try {
|
|
14539
|
-
textWidth =
|
|
14533
|
+
textWidth = tspan.getComputedTextLength();
|
|
14540
14534
|
} catch {
|
|
14541
14535
|
}
|
|
14542
14536
|
}
|
|
14537
|
+
if (!Number.isFinite(textWidth) || textWidth <= 0) {
|
|
14538
|
+
if (ctx) {
|
|
14539
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
|
|
14540
|
+
textWidth = ctx.measureText(content).width;
|
|
14541
|
+
} else {
|
|
14542
|
+
textWidth = content.length * fontSize * 0.6;
|
|
14543
|
+
}
|
|
14544
|
+
}
|
|
14543
14545
|
const underlineY = y + fontSize * 0.15;
|
|
14544
14546
|
const thickness = Math.max(0.5, fontSize * 0.066667);
|
|
14545
14547
|
const line = doc.createElementNS("http://www.w3.org/2000/svg", "line");
|