@pixldocs/canvas-renderer 0.5.22 → 0.5.24
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 +15 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12571,8 +12571,8 @@ class PixldocsRenderer {
|
|
|
12571
12571
|
return;
|
|
12572
12572
|
}
|
|
12573
12573
|
const exportCanvas = document.createElement("canvas");
|
|
12574
|
-
exportCanvas.width =
|
|
12575
|
-
exportCanvas.height =
|
|
12574
|
+
exportCanvas.width = Math.round(canvasWidth * pixelRatio);
|
|
12575
|
+
exportCanvas.height = Math.round(canvasHeight * pixelRatio);
|
|
12576
12576
|
const exportCtx = exportCanvas.getContext("2d");
|
|
12577
12577
|
if (!exportCtx) {
|
|
12578
12578
|
cleanup();
|
|
@@ -12580,10 +12580,10 @@ class PixldocsRenderer {
|
|
|
12580
12580
|
return;
|
|
12581
12581
|
}
|
|
12582
12582
|
exportCtx.save();
|
|
12583
|
-
exportCtx.scale(
|
|
12583
|
+
exportCtx.scale(exportCanvas.width / canvasWidth, exportCanvas.height / canvasHeight);
|
|
12584
12584
|
this.paintPageBackground(exportCtx, config.pages[pageIndex], canvasWidth, canvasHeight);
|
|
12585
12585
|
exportCtx.restore();
|
|
12586
|
-
exportCtx.drawImage(sourceCanvas, 0, 0);
|
|
12586
|
+
exportCtx.drawImage(sourceCanvas, 0, 0, exportCanvas.width, exportCanvas.height);
|
|
12587
12587
|
const mimeType = format === "jpeg" ? "image/jpeg" : format === "webp" ? "image/webp" : "image/png";
|
|
12588
12588
|
const dataUrl = exportCanvas.toDataURL(mimeType, quality);
|
|
12589
12589
|
cleanup();
|
|
@@ -12599,7 +12599,7 @@ class PixldocsRenderer {
|
|
|
12599
12599
|
createElement(PreviewCanvas2, {
|
|
12600
12600
|
config,
|
|
12601
12601
|
pageIndex,
|
|
12602
|
-
zoom:
|
|
12602
|
+
zoom: 1,
|
|
12603
12603
|
absoluteZoom: true,
|
|
12604
12604
|
onReady
|
|
12605
12605
|
})
|
|
@@ -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");
|