@pixldocs/canvas-renderer 0.5.140 → 0.5.142

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.
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jspdf = require("jspdf");
4
4
  const svg2pdf_js = require("svg2pdf.js");
5
5
  const fabric = require("fabric");
6
- const index = require("./index-DhQsu_MH.cjs");
7
- const pdfFonts = require("./pdfFonts-BU2Lqz_O.cjs");
6
+ const index = require("./index-CBXAcuts.cjs");
7
+ const pdfFonts = require("./pdfFonts-BTEVnYX8.cjs");
8
8
  function _interopNamespaceDefault(e) {
9
9
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
10
10
  if (e) {
@@ -31,7 +31,7 @@ async function embedFontsForSvg(pdf, svgStr) {
31
31
  FONT_FALLBACK_SYMBOLS: FONT_FALLBACK_SYMBOLS2,
32
32
  FONT_FALLBACK_DEVANAGARI: FONT_FALLBACK_DEVANAGARI2,
33
33
  FONT_FALLBACK_MATH: FONT_FALLBACK_MATH2
34
- } = await Promise.resolve().then(() => require("./pdfFonts-BU2Lqz_O.cjs"));
34
+ } = await Promise.resolve().then(() => require("./pdfFonts-BTEVnYX8.cjs"));
35
35
  const parser = new DOMParser();
36
36
  const doc = parser.parseFromString(svgStr, "image/svg+xml");
37
37
  const textEls = Array.from(doc.querySelectorAll("text, tspan, textPath"));
@@ -1126,7 +1126,28 @@ async function bakeTextAnchorPositionsFromLiveSvg(svg) {
1126
1126
  }
1127
1127
  if (!needsBake) return;
1128
1128
  try {
1129
- if ((_a = document.fonts) == null ? void 0 : _a.ready) await document.fonts.ready;
1129
+ if (document.fonts) {
1130
+ const loadKeys = /* @__PURE__ */ new Set();
1131
+ for (const tn of svg.querySelectorAll("text, tspan, textPath")) {
1132
+ const ff = tn.getAttribute("data-source-font-family") || tn.getAttribute("font-family");
1133
+ if (!ff) continue;
1134
+ const fw = tn.getAttribute("data-source-font-weight") || tn.getAttribute("font-weight") || "400";
1135
+ const fs = tn.getAttribute("data-source-font-style") || tn.getAttribute("font-style") || "normal";
1136
+ const cleanFamily = ff.replace(/['"]/g, "").trim();
1137
+ if (!cleanFamily) continue;
1138
+ loadKeys.add(`${fs} ${fw} 16px "${cleanFamily}"`);
1139
+ }
1140
+ const loads = [];
1141
+ for (const spec of loadKeys) {
1142
+ try {
1143
+ loads.push(document.fonts.load(spec).catch(() => {
1144
+ }));
1145
+ } catch {
1146
+ }
1147
+ }
1148
+ if (loads.length > 0) await Promise.all(loads);
1149
+ if ((_a = document.fonts) == null ? void 0 : _a.ready) await document.fonts.ready;
1150
+ }
1130
1151
  } catch {
1131
1152
  }
1132
1153
  const tempContainer = document.createElement("div");
@@ -2246,7 +2267,7 @@ async function fetchSvgAsElement(imageUrl, colorMap) {
2246
2267
  async function getRecoloredSvgDataUrl(imageUrl, colorMap) {
2247
2268
  if (!colorMap || Object.keys(colorMap).length === 0) return null;
2248
2269
  try {
2249
- const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-DhQsu_MH.cjs")).then((n) => n.canvasImageLoader);
2270
+ const { getNormalizedSvgUrl } = await Promise.resolve().then(() => require("./index-CBXAcuts.cjs")).then((n) => n.canvasImageLoader);
2250
2271
  return await getNormalizedSvgUrl(imageUrl, colorMap);
2251
2272
  } catch {
2252
2273
  return null;
@@ -3027,7 +3048,7 @@ async function fetchImageAsBase64(imageUrl, opts = {}) {
3027
3048
  }
3028
3049
  let fetchUrl = imageUrl;
3029
3050
  if (imageUrl.startsWith("http://") || imageUrl.startsWith("https://")) {
3030
- const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-DhQsu_MH.cjs")).then((n) => n.canvasImageLoader);
3051
+ const { isPrivateUrl } = await Promise.resolve().then(() => require("./index-CBXAcuts.cjs")).then((n) => n.canvasImageLoader);
3031
3052
  if (isPrivateUrl(imageUrl)) return null;
3032
3053
  const proxyUrl = new URL(`${index.API_URL}/image-proxy`);
3033
3054
  proxyUrl.searchParams.set("url", imageUrl);
@@ -5008,4 +5029,4 @@ exports.exportFabricCanvasToVectorPdf = exportFabricCanvasToVectorPdf;
5008
5029
  exports.exportMultiPagePdf = exportMultiPagePdf;
5009
5030
  exports.preparePagesForExport = preparePagesForExport;
5010
5031
  exports.rewriteSvgFontsForJsPDFWithSourceMeta = rewriteSvgFontsForJsPDFWithSourceMeta;
5011
- //# sourceMappingURL=vectorPdfExport-uR2FxMCo.cjs.map
5032
+ //# sourceMappingURL=vectorPdfExport-fTlcySFg.cjs.map