@pixldocs/canvas-renderer 0.5.132 → 0.5.133

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.
@@ -5730,7 +5730,8 @@ function applyTextBackground(obj, cfg) {
5730
5730
  const dataAttrs = `data-blur="${blur.toFixed(3)}" data-ox="${ox.toFixed(3)}" data-oy="${oy.toFixed(3)}" data-bx="${bx.toFixed(3)}" data-by="${by.toFixed(3)}" data-bw="${bw.toFixed(3)}" data-bh="${bh.toFixed(3)}" data-color="${escapeXmlAttr(shadowColor)}"`;
5731
5731
  const wrapShadow = (markup) => blur <= 0 ? `<g transform="translate(${ox.toFixed(3)} ${oy.toFixed(3)})">${markup}</g>` : `<g class="__pdShadowRaster" ${dataAttrs}>${markup}</g>`;
5732
5732
  if (hasBg && (bg == null ? void 0 : bg.shadowAffectsBg) !== false) {
5733
- const shadowBgPath = `<path d="${bgD}" fill="${escapeXmlAttr(shadowColor)}" />`;
5733
+ const shadowOpacityAttr = bgOpacity < 1 ? ` fill-opacity="${bgOpacity}"` : "";
5734
+ const shadowBgPath = `<path d="${bgD}" fill="${escapeXmlAttr(shadowColor)}"${shadowOpacityAttr} />`;
5734
5735
  bgShadowMarker = wrapShadow(shadowBgPath);
5735
5736
  }
5736
5737
  if ((bg == null ? void 0 : bg.shadowAffectsText) !== false) {
@@ -14031,7 +14032,8 @@ async function fetchGoogleFontTTF(fontFamily, weight, isItalic = false) {
14031
14032
  async function fetchFontshareTTF(fontFamily, weight, isItalic = false) {
14032
14033
  const cacheKey = `fs:${fontFamily}:${weight}:${isItalic ? "i" : "n"}`;
14033
14034
  if (ttfCache.has(cacheKey)) return ttfCache.get(cacheKey);
14034
- if (fontshareNotFound.has(fontFamily)) return null;
14035
+ const notFoundKey = remoteVariantKey(fontFamily, weight, isItalic);
14036
+ if (fontshareNotFound.has(notFoundKey)) return null;
14035
14037
  const slug = fontFamily.trim().toLowerCase().replace(/\s+/g, "-");
14036
14038
  const proxyBytes = await fetchTtfViaProxy(fontFamily, weight, isItalic, "fontshare");
14037
14039
  if (proxyBytes) {
@@ -14044,13 +14046,13 @@ async function fetchFontshareTTF(fontFamily, weight, isItalic = false) {
14044
14046
  const cssUrl = `https://api.fontshare.com/v2/css?f[]=${slug}@${weight}${styleSuffix}&display=swap`;
14045
14047
  const cssRes = await fetch(cssUrl);
14046
14048
  if (!cssRes.ok) {
14047
- if (cssRes.status === 400 || cssRes.status === 404) fontshareNotFound.add(fontFamily);
14049
+ if (cssRes.status === 400 || cssRes.status === 404) fontshareNotFound.add(notFoundKey);
14048
14050
  return null;
14049
14051
  }
14050
14052
  const css = await cssRes.text();
14051
14053
  const ttMatch = css.match(/url\(([^)]+)\)\s+format\(['"]?truetype['"]?\)/i);
14052
14054
  if (!ttMatch) {
14053
- fontshareNotFound.add(fontFamily);
14055
+ fontshareNotFound.add(notFoundKey);
14054
14056
  return null;
14055
14057
  }
14056
14058
  let ttfUrl = ttMatch[1].replace(/['"]/g, "").trim();
@@ -14097,11 +14099,38 @@ async function embedFontWithGoogleFallback(pdf, fontName, weight = 400, fontBase
14097
14099
  if (ok) return true;
14098
14100
  }
14099
14101
  const resolved = resolveFontWeight(weight);
14100
- const fsB64 = await fetchFontshareTTF(fontName, resolved, isItalic);
14101
- if (fsB64) return registerJsPdfFont(pdf, fontName, resolved, isItalic, fsB64);
14102
- const b64 = await fetchGoogleFontTTF(fontName, resolved, isItalic);
14103
- if (b64) return registerJsPdfFont(pdf, fontName, resolved, isItalic, b64);
14104
- return false;
14102
+ const weightLadder = [resolved];
14103
+ for (const w of [400, 500, 700, 600, 300]) {
14104
+ if (!weightLadder.includes(w)) weightLadder.push(w);
14105
+ }
14106
+ const tryFetch = async (w, italic) => {
14107
+ const fs = await fetchFontshareTTF(fontName, w, italic);
14108
+ if (fs) return fs;
14109
+ const g = await fetchGoogleFontTTF(fontName, w, italic);
14110
+ return g;
14111
+ };
14112
+ let b64 = null;
14113
+ let usedItalic = isItalic;
14114
+ let usedWeight = resolved;
14115
+ for (const w of weightLadder) {
14116
+ b64 = await tryFetch(w, isItalic);
14117
+ if (b64) {
14118
+ usedWeight = w;
14119
+ break;
14120
+ }
14121
+ }
14122
+ if (!b64 && isItalic) {
14123
+ for (const w of weightLadder) {
14124
+ b64 = await tryFetch(w, false);
14125
+ if (b64) {
14126
+ usedItalic = false;
14127
+ usedWeight = w;
14128
+ break;
14129
+ }
14130
+ }
14131
+ }
14132
+ if (!b64) return false;
14133
+ return registerJsPdfFont(pdf, fontName, usedWeight, usedItalic, b64);
14105
14134
  }
14106
14135
  async function embedFontsForConfig(pdf, config, fontBaseUrl) {
14107
14136
  const fontKeys = /* @__PURE__ */ new Set();
@@ -16203,7 +16232,7 @@ class PixldocsRenderer {
16203
16232
  await this.waitForCanvasScene(container, cloned, i);
16204
16233
  }
16205
16234
  console.log(`[canvas-renderer][pdf-unified] mounted ${cloned.pages.length} page(s), handing off to client exportMultiPagePdf`);
16206
- const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-BmqYmqUF.cjs"));
16235
+ const { exportMultiPagePdf, preparePagesForExport } = await Promise.resolve().then(() => require("./vectorPdfExport-DCNpWd6K.cjs"));
16207
16236
  const prepared = preparePagesForExport(
16208
16237
  cloned.pages,
16209
16238
  canvasWidth,
@@ -18196,7 +18225,7 @@ async function prepareLiveCanvasSvgForPdf(rawSvg, pageWidth, pageHeight, pageKey
18196
18225
  if (options == null ? void 0 : options.stripPageBackground) stripRootPageBackgroundFromSvg(svgToDraw);
18197
18226
  sanitizeSvgTreeForPdf(svgToDraw);
18198
18227
  try {
18199
- const { bakeTextAnchorPositionsFromLiveSvg } = await Promise.resolve().then(() => require("./vectorPdfExport-BmqYmqUF.cjs"));
18228
+ const { bakeTextAnchorPositionsFromLiveSvg } = await Promise.resolve().then(() => require("./vectorPdfExport-DCNpWd6K.cjs"));
18200
18229
  await bakeTextAnchorPositionsFromLiveSvg(svgToDraw);
18201
18230
  } catch (e) {
18202
18231
  console.warn("[canvas-renderer][pdf-export] anchor-bake pass failed (continuing):", e);
@@ -18327,7 +18356,7 @@ async function assemblePdfFromSvgs(svgResults, options = {}) {
18327
18356
  }
18328
18357
  if (shouldOutlineText) {
18329
18358
  try {
18330
- const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-D6xJoPO2.cjs"));
18359
+ const { convertAllTextToPath } = await Promise.resolve().then(() => require("./svgTextToPath-GeR0CexD.cjs"));
18331
18360
  pageSvg = await convertAllTextToPath(pageSvg, fontBaseUrl, { mode: outlineSubMode });
18332
18361
  try {
18333
18362
  dumpSvgTextDiagnostics(pageSvg, i, PARITY_TAG, "STAGE-1b-after-text-to-path-raw");
@@ -18538,4 +18567,4 @@ exports.setAutoShrinkDebug = setAutoShrinkDebug;
18538
18567
  exports.setBundledAssetPrefixes = setBundledAssetPrefixes;
18539
18568
  exports.warmResolvedTemplateForPreview = warmResolvedTemplateForPreview;
18540
18569
  exports.warmTemplateFromForm = warmTemplateFromForm;
18541
- //# sourceMappingURL=index-4IzWx9f-.cjs.map
18570
+ //# sourceMappingURL=index-D5rY5lp8.cjs.map