@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 CHANGED
@@ -14546,19 +14546,21 @@ function convertTextDecorationsToLines(svg) {
14546
14546
  const fontFamily = tspan.getAttribute("font-family") || textEl.getAttribute("font-family") || "sans-serif";
14547
14547
  const fontWeight = tspan.getAttribute("font-weight") || textEl.getAttribute("font-weight") || "normal";
14548
14548
  const fill = tspan.getAttribute("fill") || textEl.getAttribute("fill") || "#000000";
14549
- let textWidth;
14550
- if (ctx) {
14551
- ctx.font = `${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
14552
- textWidth = ctx.measureText(content).width;
14553
- } else {
14554
- textWidth = content.length * fontSize * 0.6;
14555
- }
14549
+ let textWidth = 0;
14556
14550
  if (typeof tspan.getComputedTextLength === "function") {
14557
14551
  try {
14558
- textWidth = Math.max(textWidth, tspan.getComputedTextLength());
14552
+ textWidth = tspan.getComputedTextLength();
14559
14553
  } catch {
14560
14554
  }
14561
14555
  }
14556
+ if (!Number.isFinite(textWidth) || textWidth <= 0) {
14557
+ if (ctx) {
14558
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily.replace(/'/g, "")}`;
14559
+ textWidth = ctx.measureText(content).width;
14560
+ } else {
14561
+ textWidth = content.length * fontSize * 0.6;
14562
+ }
14563
+ }
14562
14564
  const underlineY = y + fontSize * 0.15;
14563
14565
  const thickness = Math.max(0.5, fontSize * 0.066667);
14564
14566
  const line = doc.createElementNS("http://www.w3.org/2000/svg", "line");