@pixldocs/canvas-renderer 0.5.239 → 0.5.240
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-DSRobH-5.js → index-B2H1tQ0S.js} +34 -5
- package/dist/index-B2H1tQ0S.js.map +1 -0
- package/dist/{index-BScjmXRG.cjs → index-DBOS1ouN.cjs} +34 -5
- package/dist/index-DBOS1ouN.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{vectorPdfExport-DydXa9jD.js → vectorPdfExport-CHVrwSi7.js} +4 -4
- package/dist/{vectorPdfExport-DydXa9jD.js.map → vectorPdfExport-CHVrwSi7.js.map} +1 -1
- package/dist/{vectorPdfExport-ChKqZ9Rs.cjs → vectorPdfExport-D1yCN3sm.cjs} +4 -4
- package/dist/{vectorPdfExport-ChKqZ9Rs.cjs.map → vectorPdfExport-D1yCN3sm.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BScjmXRG.cjs.map +0 -1
- package/dist/index-DSRobH-5.js.map +0 -1
|
@@ -7460,6 +7460,31 @@ function buildRoundedRectPath2D(ctx, x, y, w, h, rTL, rTR, rBR, rBL) {
|
|
|
7460
7460
|
if (tl > 0) ctx.quadraticCurveTo(x, y, x + tl, y);
|
|
7461
7461
|
ctx.closePath();
|
|
7462
7462
|
}
|
|
7463
|
+
function measureLineGlyphWidth(obj, lineIndex) {
|
|
7464
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
7465
|
+
try {
|
|
7466
|
+
const rawLine = (_a2 = obj == null ? void 0 : obj._textLines) == null ? void 0 : _a2[lineIndex];
|
|
7467
|
+
const lineText = Array.isArray(rawLine) ? rawLine.join("") : String(rawLine ?? "");
|
|
7468
|
+
if (!lineText) return 0;
|
|
7469
|
+
const fontSize = Number(((_b = obj.getValueOfPropertyAt) == null ? void 0 : _b.call(obj, lineIndex, 0, "fontSize")) ?? obj.fontSize ?? 0);
|
|
7470
|
+
if (!fontSize) return 0;
|
|
7471
|
+
const fontStyle = String(((_c = obj.getValueOfPropertyAt) == null ? void 0 : _c.call(obj, lineIndex, 0, "fontStyle")) ?? obj.fontStyle ?? "normal");
|
|
7472
|
+
const fontWeight = String(((_d = obj.getValueOfPropertyAt) == null ? void 0 : _d.call(obj, lineIndex, 0, "fontWeight")) ?? obj.fontWeight ?? "400");
|
|
7473
|
+
const fontFamily = String(((_e = obj.getValueOfPropertyAt) == null ? void 0 : _e.call(obj, lineIndex, 0, "fontFamily")) ?? obj.fontFamily ?? "sans-serif");
|
|
7474
|
+
const charSpacing = Number(((_f = obj.getValueOfPropertyAt) == null ? void 0 : _f.call(obj, lineIndex, 0, "charSpacing")) ?? obj.charSpacing ?? 0);
|
|
7475
|
+
if (typeof document === "undefined") return 0;
|
|
7476
|
+
const off = document.createElement("canvas");
|
|
7477
|
+
const ctx = off.getContext("2d");
|
|
7478
|
+
if (!ctx) return 0;
|
|
7479
|
+
ctx.font = `${fontStyle} normal ${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
7480
|
+
const measured = ctx.measureText(lineText).width;
|
|
7481
|
+
const graphemeCount = Array.from(lineText).length;
|
|
7482
|
+
const spacingWidth = graphemeCount > 1 ? charSpacing / 1e3 * fontSize * (graphemeCount - 1) : 0;
|
|
7483
|
+
return Math.max(0, measured + spacingWidth);
|
|
7484
|
+
} catch {
|
|
7485
|
+
return 0;
|
|
7486
|
+
}
|
|
7487
|
+
}
|
|
7463
7488
|
function applyTextBackground(obj, cfg) {
|
|
7464
7489
|
var _a2;
|
|
7465
7490
|
obj[PD_BG_KEY] = { ...cfg };
|
|
@@ -8064,6 +8089,10 @@ function computeBgRects(obj, w, h, pT, pR, pB, pL, fit, lineFullWidth = false) {
|
|
|
8064
8089
|
} catch {
|
|
8065
8090
|
lineH = 0;
|
|
8066
8091
|
}
|
|
8092
|
+
if (fit && !lineFullWidth) {
|
|
8093
|
+
const measured = measureLineGlyphWidth(obj, i);
|
|
8094
|
+
if (measured > 0) lineW = measured;
|
|
8095
|
+
}
|
|
8067
8096
|
const rawSlotH = i === lines.length - 1 ? lineH / lineHeightRatio : lineH;
|
|
8068
8097
|
const usedH = cursorY + halfH;
|
|
8069
8098
|
const remaining = h - usedH;
|
|
@@ -21139,9 +21168,9 @@ function captureFabricCanvasSvgForPdf(fabricInstance, canvasWidth, canvasHeight)
|
|
|
21139
21168
|
}
|
|
21140
21169
|
return svgString;
|
|
21141
21170
|
}
|
|
21142
|
-
const resolvedPackageVersion = "0.5.
|
|
21171
|
+
const resolvedPackageVersion = "0.5.240";
|
|
21143
21172
|
const PACKAGE_VERSION = resolvedPackageVersion;
|
|
21144
|
-
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.
|
|
21173
|
+
const DEPLOYMENT_VERSION_MARKER = "__PIXLDOCS_CANVAS_RENDERER_VERSION__:0.5.240";
|
|
21145
21174
|
const roundParityValue = (value) => {
|
|
21146
21175
|
if (typeof value !== "number") return value;
|
|
21147
21176
|
return Number.isFinite(value) ? Number(value.toFixed(3)) : value;
|
|
@@ -21888,7 +21917,7 @@ class PixldocsRenderer {
|
|
|
21888
21917
|
await this.waitForCanvasScene(container, cloned, i);
|
|
21889
21918
|
}
|
|
21890
21919
|
console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
|
|
21891
|
-
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
21920
|
+
const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-D1yCN3sm.cjs"));
|
|
21892
21921
|
const prepared = preparePagesForExport(
|
|
21893
21922
|
cloned.pages,
|
|
21894
21923
|
canvasWidth,
|
|
@@ -24208,7 +24237,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
|
|
|
24208
24237
|
if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
|
|
24209
24238
|
sanitizeSvgTreeForPdf(svgToDraw);
|
|
24210
24239
|
try {
|
|
24211
|
-
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-
|
|
24240
|
+
const { bakeTextAnchorPositionsFromLiveSvg, logTextMeasurementDiagnostic } = await Promise.resolve().then(() => require("./vectorPdfExport-D1yCN3sm.cjs"));
|
|
24212
24241
|
try {
|
|
24213
24242
|
await logTextMeasurementDiagnostic(svgToDraw);
|
|
24214
24243
|
} catch {
|
|
@@ -24605,4 +24634,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
|
|
|
24605
24634
|
exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
|
|
24606
24635
|
exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
|
|
24607
24636
|
exports.warmTemplateFromForm = warmTemplateFromForm;
|
|
24608
|
-
//# sourceMappingURL=index-
|
|
24637
|
+
//# sourceMappingURL=index-DBOS1ouN.cjs.map
|