@superdoc-dev/cli 0.16.0-next.20 → 0.16.0-next.22

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.
Files changed (2) hide show
  1. package/dist/index.js +1027 -682
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -230111,7 +230111,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
230111
230111
  init_remark_gfm_BhnWr3yf_es();
230112
230112
  });
230113
230113
 
230114
- // ../../packages/superdoc/dist/chunks/src-CEhzpYi5.es.js
230114
+ // ../../packages/superdoc/dist/chunks/src-B1aSE-tB.es.js
230115
230115
  function deleteProps(obj, propOrProps) {
230116
230116
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
230117
230117
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -270389,6 +270389,187 @@ function computeTabWidth(currentPos, justification, tabs, hangingIndent, firstLi
270389
270389
  tabWidth = nextDefaultTabStop - currentPos;
270390
270390
  return tabWidth;
270391
270391
  }
270392
+ function isSettled(status) {
270393
+ return SETTLED_STATUSES.includes(status);
270394
+ }
270395
+ function normalizeFamilyKey$2(family$1) {
270396
+ return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270397
+ }
270398
+ function splitStack(cssFontFamily) {
270399
+ return cssFontFamily.split(",").map((part) => part.trim()).filter(Boolean);
270400
+ }
270401
+ function createFontResolver() {
270402
+ return new FontResolver;
270403
+ }
270404
+ function resolveFontFamily2(logicalFamily) {
270405
+ return defaultResolver.resolveFontFamily(logicalFamily);
270406
+ }
270407
+ function resolvePhysicalFamily(cssFontFamily) {
270408
+ return defaultResolver.resolvePhysicalFamily(cssFontFamily);
270409
+ }
270410
+ function resolvePrimaryPhysicalFamily(family$1) {
270411
+ return defaultResolver.resolvePrimaryPhysicalFamily(family$1);
270412
+ }
270413
+ function getFontConfigVersion() {
270414
+ return fontConfigVersion;
270415
+ }
270416
+ function bumpFontConfigVersion() {
270417
+ return fontConfigVersion += 1;
270418
+ }
270419
+ function fourFaces(filePrefix) {
270420
+ return [
270421
+ {
270422
+ weight: "normal",
270423
+ style: "normal",
270424
+ file: `${filePrefix}-Regular.woff2`
270425
+ },
270426
+ {
270427
+ weight: "bold",
270428
+ style: "normal",
270429
+ file: `${filePrefix}-Bold.woff2`
270430
+ },
270431
+ {
270432
+ weight: "normal",
270433
+ style: "italic",
270434
+ file: `${filePrefix}-Italic.woff2`
270435
+ },
270436
+ {
270437
+ weight: "bold",
270438
+ style: "italic",
270439
+ file: `${filePrefix}-BoldItalic.woff2`
270440
+ }
270441
+ ];
270442
+ }
270443
+ function family(name, filePrefix, license) {
270444
+ return {
270445
+ family: name,
270446
+ license,
270447
+ faces: fourFaces(filePrefix)
270448
+ };
270449
+ }
270450
+ function withTrailingSlash(base5) {
270451
+ return base5.endsWith("/") ? base5 : `${base5}/`;
270452
+ }
270453
+ function joinUrl(base5, file) {
270454
+ return `${withTrailingSlash(base5)}${file}`;
270455
+ }
270456
+ function weightToken(weight) {
270457
+ return weight === "bold" ? "700" : "400";
270458
+ }
270459
+ function bundledAssetSignature(resolve3) {
270460
+ const family$1 = BUNDLED_MANIFEST[0];
270461
+ const face = family$1?.faces[0];
270462
+ if (!family$1 || !face)
270463
+ return "";
270464
+ return resolve3({
270465
+ file: face.file,
270466
+ family: family$1.family,
270467
+ weight: weightToken(face.weight),
270468
+ style: face.style,
270469
+ source: "bundled-substitute"
270470
+ });
270471
+ }
270472
+ function installBundledSubstitutes(registry2, options = {}) {
270473
+ const resolve3 = options.resolveAssetUrl ?? ((context) => joinUrl(options.assetBaseUrl ?? defaultAssetBase, context.file));
270474
+ const signature = bundledAssetSignature(resolve3);
270475
+ const installed = installedRegistries.get(registry2);
270476
+ if (installed !== undefined) {
270477
+ if (installed !== signature)
270478
+ console.warn(`[superdoc] bundled fonts are already registered for this document from "${installed}"; a later fonts config resolving to "${signature}" is ignored. Use one fonts.assetBaseUrl / fonts.resolveAssetUrl per document.`);
270479
+ return;
270480
+ }
270481
+ installedRegistries.set(registry2, signature);
270482
+ for (const family$1 of BUNDLED_MANIFEST)
270483
+ for (const face of family$1.faces) {
270484
+ const context = {
270485
+ file: face.file,
270486
+ family: family$1.family,
270487
+ weight: weightToken(face.weight),
270488
+ style: face.style,
270489
+ source: "bundled-substitute"
270490
+ };
270491
+ registry2.register({
270492
+ family: family$1.family,
270493
+ source: `url(${resolve3(context)})`,
270494
+ descriptors: {
270495
+ weight: face.weight,
270496
+ style: face.style
270497
+ }
270498
+ });
270499
+ }
270500
+ }
270501
+ function buildFontReport(logicalFamilies, registry2, resolver2) {
270502
+ const seen = /* @__PURE__ */ new Set;
270503
+ const report = [];
270504
+ for (const logical of logicalFamilies) {
270505
+ if (!logical || seen.has(logical))
270506
+ continue;
270507
+ seen.add(logical);
270508
+ const { physicalFamily, reason } = resolver2 ? resolver2.resolveFontFamily(logical) : resolveFontFamily2(logical);
270509
+ const loadStatus = registry2.getStatus(physicalFamily);
270510
+ report.push({
270511
+ logicalFamily: logical,
270512
+ physicalFamily,
270513
+ reason,
270514
+ loadStatus,
270515
+ exportFamily: logical,
270516
+ missing: isSettled(loadStatus) && loadStatus !== "loaded"
270517
+ });
270518
+ }
270519
+ return report;
270520
+ }
270521
+ function quoteFamily(family$1) {
270522
+ return `"${family$1.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
270523
+ }
270524
+ function canonicalizeFontSource(source) {
270525
+ const match$1 = /^\s*url\(\s*([\s\S]*?)\s*\)\s*$/i.exec(source);
270526
+ if (!match$1)
270527
+ return source;
270528
+ let inner = match$1[1].trim();
270529
+ if (inner.startsWith('"') && inner.endsWith('"') || inner.startsWith("'") && inner.endsWith("'"))
270530
+ inner = inner.slice(1, -1);
270531
+ return `url(${JSON.stringify(inner)})`;
270532
+ }
270533
+ function normalizeFamilyKey$1(family$1) {
270534
+ return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270535
+ }
270536
+ function normalizeWeight(weight) {
270537
+ if (weight === undefined)
270538
+ return "400";
270539
+ const w = String(weight).trim().toLowerCase();
270540
+ if (w === "bold" || w === "bolder")
270541
+ return "700";
270542
+ const n = Number(w);
270543
+ return Number.isFinite(n) && n >= 600 ? "700" : "400";
270544
+ }
270545
+ function normalizeStyle$1(style2) {
270546
+ if (!style2)
270547
+ return "normal";
270548
+ const s2 = style2.trim().toLowerCase();
270549
+ return s2.startsWith("italic") || s2.startsWith("oblique") ? "italic" : "normal";
270550
+ }
270551
+ function faceKeyOf$1(family$1, weight, style2) {
270552
+ return `${normalizeFamilyKey$1(family$1)}|${weight}|${style2}`;
270553
+ }
270554
+ function faceProbe(family$1, weight, style2, size$1) {
270555
+ return `${style2 === "italic" ? "italic " : ""}${weight} ${size$1} ${quoteFamily(family$1)}`;
270556
+ }
270557
+ function getFontRegistryFor(fontSet, FontFaceCtor) {
270558
+ if (!fontSet) {
270559
+ if (!domlessRegistry)
270560
+ domlessRegistry = new FontRegistry({});
270561
+ return domlessRegistry;
270562
+ }
270563
+ let registry2 = registriesByFontSet.get(fontSet);
270564
+ if (!registry2) {
270565
+ registry2 = new FontRegistry({
270566
+ fontSet,
270567
+ FontFaceCtor
270568
+ });
270569
+ registriesByFontSet.set(fontSet, registry2);
270570
+ }
270571
+ return registry2;
270572
+ }
270392
270573
  function isResolvedFragmentWithBorders(item) {
270393
270574
  return item !== undefined && item.kind === "fragment" && "paragraphBorders" in item && item.paragraphBorders !== undefined;
270394
270575
  }
@@ -270598,205 +270779,6 @@ function renderPartialEmbeddedTable(params$1) {
270598
270779
  hasSdtContainerChrome: tableResult.hasSdtContainerChrome
270599
270780
  };
270600
270781
  }
270601
- function isSettled(status) {
270602
- return SETTLED_STATUSES.includes(status);
270603
- }
270604
- function normalizeFamilyKey$2(family$1) {
270605
- return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270606
- }
270607
- function splitStack(cssFontFamily) {
270608
- return cssFontFamily.split(",").map((part) => part.trim()).filter(Boolean);
270609
- }
270610
- function physicalFor(bareFamily) {
270611
- const physical = BUNDLED_SUBSTITUTES[normalizeFamilyKey$2(bareFamily)];
270612
- return physical ? {
270613
- physical,
270614
- mapped: true
270615
- } : {
270616
- physical: bareFamily,
270617
- mapped: false
270618
- };
270619
- }
270620
- function resolveFontFamily2(logicalFamily) {
270621
- const { physical, mapped } = physicalFor(splitStack(logicalFamily)[0] ?? logicalFamily);
270622
- return {
270623
- logicalFamily,
270624
- physicalFamily: physical,
270625
- reason: mapped ? "bundled_substitute" : "as_requested"
270626
- };
270627
- }
270628
- function resolvePhysicalFamily(cssFontFamily) {
270629
- if (!cssFontFamily)
270630
- return cssFontFamily;
270631
- const parts = splitStack(cssFontFamily);
270632
- if (parts.length === 0)
270633
- return cssFontFamily;
270634
- const { physical, mapped } = physicalFor(parts[0]);
270635
- if (!mapped)
270636
- return cssFontFamily;
270637
- return [physical, ...parts.slice(1)].join(", ");
270638
- }
270639
- function resolvePrimaryPhysicalFamily(family$1) {
270640
- return physicalFor(splitStack(family$1)[0] ?? family$1).physical;
270641
- }
270642
- function resolvePhysicalFamilies(families) {
270643
- const out = /* @__PURE__ */ new Set;
270644
- for (const family$1 of families)
270645
- if (family$1)
270646
- out.add(resolvePrimaryPhysicalFamily(family$1));
270647
- return [...out];
270648
- }
270649
- function getFontConfigVersion() {
270650
- return fontConfigVersion;
270651
- }
270652
- function bumpFontConfigVersion() {
270653
- return fontConfigVersion += 1;
270654
- }
270655
- function fourFaces(filePrefix) {
270656
- return [
270657
- {
270658
- weight: "normal",
270659
- style: "normal",
270660
- file: `${filePrefix}-Regular.woff2`
270661
- },
270662
- {
270663
- weight: "bold",
270664
- style: "normal",
270665
- file: `${filePrefix}-Bold.woff2`
270666
- },
270667
- {
270668
- weight: "normal",
270669
- style: "italic",
270670
- file: `${filePrefix}-Italic.woff2`
270671
- },
270672
- {
270673
- weight: "bold",
270674
- style: "italic",
270675
- file: `${filePrefix}-BoldItalic.woff2`
270676
- }
270677
- ];
270678
- }
270679
- function family(name, filePrefix, license) {
270680
- return {
270681
- family: name,
270682
- license,
270683
- faces: fourFaces(filePrefix)
270684
- };
270685
- }
270686
- function withTrailingSlash(base5) {
270687
- return base5.endsWith("/") ? base5 : `${base5}/`;
270688
- }
270689
- function joinUrl(base5, file) {
270690
- return `${withTrailingSlash(base5)}${file}`;
270691
- }
270692
- function weightToken(weight) {
270693
- return weight === "bold" ? "700" : "400";
270694
- }
270695
- function bundledAssetSignature(resolve3) {
270696
- const family$1 = BUNDLED_MANIFEST[0];
270697
- const face = family$1?.faces[0];
270698
- if (!family$1 || !face)
270699
- return "";
270700
- return resolve3({
270701
- file: face.file,
270702
- family: family$1.family,
270703
- weight: weightToken(face.weight),
270704
- style: face.style,
270705
- source: "bundled-substitute"
270706
- });
270707
- }
270708
- function installBundledSubstitutes(registry2, options = {}) {
270709
- const resolve3 = options.resolveAssetUrl ?? ((context) => joinUrl(options.assetBaseUrl ?? defaultAssetBase, context.file));
270710
- const signature = bundledAssetSignature(resolve3);
270711
- const installed = installedRegistries.get(registry2);
270712
- if (installed !== undefined) {
270713
- if (installed !== signature)
270714
- console.warn(`[superdoc] bundled fonts are already registered for this document from "${installed}"; a later fonts config resolving to "${signature}" is ignored. Use one fonts.assetBaseUrl / fonts.resolveAssetUrl per document.`);
270715
- return;
270716
- }
270717
- installedRegistries.set(registry2, signature);
270718
- for (const family$1 of BUNDLED_MANIFEST)
270719
- for (const face of family$1.faces) {
270720
- const context = {
270721
- file: face.file,
270722
- family: family$1.family,
270723
- weight: weightToken(face.weight),
270724
- style: face.style,
270725
- source: "bundled-substitute"
270726
- };
270727
- registry2.register({
270728
- family: family$1.family,
270729
- source: `url(${resolve3(context)})`,
270730
- descriptors: {
270731
- weight: face.weight,
270732
- style: face.style
270733
- }
270734
- });
270735
- }
270736
- }
270737
- function buildFontReport(logicalFamilies, registry2) {
270738
- const seen = /* @__PURE__ */ new Set;
270739
- const report = [];
270740
- for (const logical of logicalFamilies) {
270741
- if (!logical || seen.has(logical))
270742
- continue;
270743
- seen.add(logical);
270744
- const { physicalFamily, reason } = resolveFontFamily2(logical);
270745
- const loadStatus = registry2.getStatus(physicalFamily);
270746
- report.push({
270747
- logicalFamily: logical,
270748
- physicalFamily,
270749
- reason,
270750
- loadStatus,
270751
- exportFamily: logical,
270752
- missing: isSettled(loadStatus) && loadStatus !== "loaded"
270753
- });
270754
- }
270755
- return report;
270756
- }
270757
- function quoteFamily(family$1) {
270758
- return `"${family$1.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
270759
- }
270760
- function normalizeFamilyKey$1(family$1) {
270761
- return family$1.trim().replace(/^["']|["']$/g, "").toLowerCase();
270762
- }
270763
- function normalizeWeight(weight) {
270764
- if (weight === undefined)
270765
- return "400";
270766
- const w = String(weight).trim().toLowerCase();
270767
- if (w === "bold" || w === "bolder")
270768
- return "700";
270769
- const n = Number(w);
270770
- return Number.isFinite(n) && n >= 600 ? "700" : "400";
270771
- }
270772
- function normalizeStyle$1(style2) {
270773
- if (!style2)
270774
- return "normal";
270775
- const s2 = style2.trim().toLowerCase();
270776
- return s2.startsWith("italic") || s2.startsWith("oblique") ? "italic" : "normal";
270777
- }
270778
- function faceKeyOf$1(family$1, weight, style2) {
270779
- return `${normalizeFamilyKey$1(family$1)}|${weight}|${style2}`;
270780
- }
270781
- function faceProbe(family$1, weight, style2, size$1) {
270782
- return `${style2 === "italic" ? "italic " : ""}${weight} ${size$1} ${quoteFamily(family$1)}`;
270783
- }
270784
- function getFontRegistryFor(fontSet, FontFaceCtor) {
270785
- if (!fontSet) {
270786
- if (!domlessRegistry)
270787
- domlessRegistry = new FontRegistry({});
270788
- return domlessRegistry;
270789
- }
270790
- let registry2 = registriesByFontSet.get(fontSet);
270791
- if (!registry2) {
270792
- registry2 = new FontRegistry({
270793
- fontSet,
270794
- FontFaceCtor
270795
- });
270796
- registriesByFontSet.set(fontSet, registry2);
270797
- }
270798
- return registry2;
270799
- }
270800
270782
  function isDigit(ch) {
270801
270783
  return ch >= "0" && ch <= "9";
270802
270784
  }
@@ -271792,7 +271774,7 @@ function resolveFragmentSdtContainerKey(fragment2, blockMap) {
271792
271774
  return getSdtContainerKey(block.attrs?.sdt, block.attrs?.containerSdt);
271793
271775
  return null;
271794
271776
  }
271795
- function computeBlockVersion(blockId, blockMap, cache$2) {
271777
+ function computeBlockVersion(blockId, blockMap, cache$2, fontSignature = "") {
271796
271778
  const cached = cache$2.get(blockId);
271797
271779
  if (cached !== undefined)
271798
271780
  return cached;
@@ -271802,8 +271784,9 @@ function computeBlockVersion(blockId, blockMap, cache$2) {
271802
271784
  return "missing";
271803
271785
  }
271804
271786
  const version$1 = deriveBlockVersion(entry.block);
271805
- cache$2.set(blockId, version$1);
271806
- return version$1;
271787
+ const versioned = fontSignature ? `${fontSignature}|${version$1}` : version$1;
271788
+ cache$2.set(blockId, versioned);
271789
+ return versioned;
271807
271790
  }
271808
271791
  function applyPaintVersions(item, visualVersion) {
271809
271792
  const evidenceVersion = sourceAnchorSignature(item.sourceAnchor);
@@ -271814,9 +271797,9 @@ function applyPaintVersions(item, visualVersion) {
271814
271797
  } else
271815
271798
  item.paintCacheVersion = visualVersion;
271816
271799
  }
271817
- function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, story) {
271800
+ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, story, fontSignature = "") {
271818
271801
  const sdtContainerKey = resolveFragmentSdtContainerKey(fragment2, blockMap);
271819
- const version$1 = fragmentSignature(fragment2, computeBlockVersion(fragment2.blockId, blockMap, blockVersionCache));
271802
+ const version$1 = fragmentSignature(fragment2, computeBlockVersion(fragment2.blockId, blockMap, blockVersionCache, fontSignature));
271820
271803
  const layoutSourceIdentity = resolveFragmentLayoutIdentity(fragment2, story);
271821
271804
  switch (fragment2.kind) {
271822
271805
  case "table": {
@@ -271919,6 +271902,7 @@ function resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, bloc
271919
271902
  }
271920
271903
  function resolveLayout(input2) {
271921
271904
  const { layout, flowMode, blocks: blocks2, measures } = input2;
271905
+ const fontSignature = input2.fontSignature ?? "";
271922
271906
  const blockMap = buildBlockMap(blocks2, measures);
271923
271907
  const blockVersionCache = /* @__PURE__ */ new Map;
271924
271908
  const pages = layout.pages.map((page, pageIndex) => ({
@@ -271929,7 +271913,7 @@ function resolveLayout(input2) {
271929
271913
  number: page.number,
271930
271914
  width: page.size?.w ?? layout.pageSize.w,
271931
271915
  height: page.size?.h ?? layout.pageSize.h,
271932
- items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache)),
271916
+ items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, pageIndex, blockMap, blockVersionCache, undefined, fontSignature)),
271933
271917
  margins: page.margins,
271934
271918
  footnoteReserved: page.footnoteReserved,
271935
271919
  displayNumber: page.displayNumber,
@@ -271952,12 +271936,12 @@ function resolveLayout(input2) {
271952
271936
  ...layout.documentBackground ? { documentBackground: layout.documentBackground } : {}
271953
271937
  };
271954
271938
  if (blocks2.length > 0)
271955
- resolved.blockVersions = Object.fromEntries(blocks2.map((block) => [block.id, computeBlockVersion(block.id, blockMap, blockVersionCache)]));
271939
+ resolved.blockVersions = Object.fromEntries(blocks2.map((block) => [block.id, computeBlockVersion(block.id, blockMap, blockVersionCache, fontSignature)]));
271956
271940
  if (layout.layoutEpoch != null)
271957
271941
  resolved.layoutEpoch = layout.layoutEpoch;
271958
271942
  return resolved;
271959
271943
  }
271960
- function resolveHeaderFooterLayout(layout, blocks2, measures, story) {
271944
+ function resolveHeaderFooterLayout(layout, blocks2, measures, story, fontSignature = "") {
271961
271945
  const pages = layout.pages.map((page) => {
271962
271946
  const blockMap = buildBlockMap(page.blocks ?? blocks2, page.measures ?? measures);
271963
271947
  const blockVersionCache = /* @__PURE__ */ new Map;
@@ -271968,7 +271952,7 @@ function resolveHeaderFooterLayout(layout, blocks2, measures, story) {
271968
271952
  pageNumberFormat: page.pageNumberFormat,
271969
271953
  pageNumberChapterText: page.pageNumberChapterText,
271970
271954
  pageNumberChapterSeparator: page.pageNumberChapterSeparator,
271971
- items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, page.number - 1, blockMap, blockVersionCache, story))
271955
+ items: page.fragments.map((fragment2, fragmentIndex) => resolveFragmentItem(fragment2, fragmentIndex, page.number - 1, blockMap, blockVersionCache, story, fontSignature))
271972
271956
  };
271973
271957
  });
271974
271958
  return {
@@ -277584,7 +277568,7 @@ function hasPageNumberTokensRequiringPerPageLayout(blocks2) {
277584
277568
  }
277585
277569
  return false;
277586
277570
  }
277587
- async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind) {
277571
+ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1, cache$2 = sharedHeaderFooterCache, totalPages, pageResolver, kind, fontSignature = "") {
277588
277572
  const result = {};
277589
277573
  if (!pageResolver) {
277590
277574
  const numPages = totalPages ?? 1;
@@ -277593,7 +277577,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
277593
277577
  continue;
277594
277578
  const clonedBlocks = cloneHeaderFooterBlocks(blocks2);
277595
277579
  resolveHeaderFooterTokens(clonedBlocks, 1, numPages);
277596
- const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1);
277580
+ const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1, fontSignature);
277597
277581
  result[type] = {
277598
277582
  blocks: clonedBlocks,
277599
277583
  measures,
@@ -277610,7 +277594,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
277610
277594
  if (!blocks2 || blocks2.length === 0)
277611
277595
  continue;
277612
277596
  if (!hasPageTokens(blocks2)) {
277613
- const measures = await cache$2.measureBlocks(blocks2, constraints, measureBlock$1);
277597
+ const measures = await cache$2.measureBlocks(blocks2, constraints, measureBlock$1, fontSignature);
277614
277598
  result[type] = {
277615
277599
  blocks: blocks2,
277616
277600
  measures,
@@ -277635,7 +277619,7 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock$1
277635
277619
  const clonedBlocks = cloneHeaderFooterBlocks(blocks2);
277636
277620
  const { displayText, displayNumber, totalPages: totalPagesForPage, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator } = pageResolver(pageNum);
277637
277621
  resolveHeaderFooterTokens(clonedBlocks, pageNum, totalPagesForPage, displayText, displayNumber, sectionPageCount, pageFormat, chapterNumberText, chapterSeparator);
277638
- const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1);
277622
+ const measures = await cache$2.measureBlocks(clonedBlocks, constraints, measureBlock$1, fontSignature);
277639
277623
  const pageLayout = layoutHeaderFooter(clonedBlocks, measures, constraints, kind);
277640
277624
  const measuresById = /* @__PURE__ */ new Map;
277641
277625
  for (let i4 = 0;i4 < clonedBlocks.length; i4 += 1)
@@ -278420,7 +278404,9 @@ function invalidateHeaderFooterCache(cache$2, cacheState, headerBlocks, footerBl
278420
278404
  HeaderFooterCacheLogger.logInvalidation(invalidationReasons.join(", "), uniqueBlockIds);
278421
278405
  }
278422
278406
  }
278423
- async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, options, measureBlock$1, headerFooter, previousMeasures) {
278407
+ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, options, measureBlock$1, headerFooter, previousMeasures, fontRuntime) {
278408
+ const fontSignature = fontRuntime?.fontContext?.fontSignature ?? "";
278409
+ const previousFontSignature = fontRuntime?.previousFontSignature ?? "";
278424
278410
  const isSemanticFlow = options.flowMode === "semantic";
278425
278411
  if (isSemanticFlow) {
278426
278412
  headerFooter = undefined;
@@ -278435,7 +278421,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278435
278421
  throw new Error("incrementalLayout: invalid measurement constraints resolved from options");
278436
278422
  const hasPreviousMeasures = Array.isArray(previousMeasures) && previousMeasures.length === previousBlocks.length;
278437
278423
  const previousConstraints = hasPreviousMeasures && !isSemanticFlow ? resolveMeasurementConstraints(options, previousBlocks) : null;
278438
- const canReusePreviousMeasures = hasPreviousMeasures && previousConstraints?.measurementWidth === measurementWidth && previousConstraints?.measurementHeight === measurementHeight;
278424
+ const canReusePreviousMeasures = hasPreviousMeasures && fontSignature === previousFontSignature && previousConstraints?.measurementWidth === measurementWidth && previousConstraints?.measurementHeight === measurementHeight;
278439
278425
  const previousPerSectionConstraints = canReusePreviousMeasures ? computePerSectionConstraints(options, previousBlocks) : null;
278440
278426
  const previousMeasuresById = canReusePreviousMeasures ? new Map(previousBlocks.map((block, index2) => [block.id, previousMeasures[index2]])) : null;
278441
278427
  const previousConstraintsById = canReusePreviousMeasures ? new Map(previousBlocks.map((block, index2) => [block.id, previousPerSectionConstraints[index2]])) : null;
@@ -278465,7 +278451,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278465
278451
  }
278466
278452
  }
278467
278453
  const lookupStart = performance.now();
278468
- const cached = measureCache.get(block, blockMeasureWidth, blockMeasureHeight);
278454
+ const cached = measureCache.get(block, blockMeasureWidth, blockMeasureHeight, fontSignature);
278469
278455
  cacheLookupTime += performance.now() - lookupStart;
278470
278456
  if (cached) {
278471
278457
  measures.push(cached);
@@ -278475,7 +278461,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278475
278461
  const measureBlockStart = performance.now();
278476
278462
  const measurement = await measureBlock$1(block, sectionConstraints);
278477
278463
  actualMeasureTime += performance.now() - measureBlockStart;
278478
- measureCache.set(block, blockMeasureWidth, blockMeasureHeight, measurement);
278464
+ measureCache.set(block, blockMeasureWidth, blockMeasureHeight, measurement, fontSignature);
278479
278465
  measures.push(measurement);
278480
278466
  cacheMisses++;
278481
278467
  }
@@ -278536,7 +278522,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278536
278522
  };
278537
278523
  headerContentHeights = {};
278538
278524
  if (hasHeaderBlocks && headerFooter.headerBlocks) {
278539
- const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header");
278525
+ const preHeaderLayouts = await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, HEADER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "header", fontSignature);
278540
278526
  for (const [type, value] of Object.entries(preHeaderLayouts)) {
278541
278527
  if (!isValidHeaderType(type))
278542
278528
  continue;
@@ -278577,7 +278563,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278577
278563
  footerContentHeights = {};
278578
278564
  try {
278579
278565
  if (hasFooterBlocks && headerFooter.footerBlocks) {
278580
- const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer");
278566
+ const preFooterLayouts = await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FOOTER_PRELAYOUT_PLACEHOLDER_PAGE_COUNT, prelayoutPageResolver, "footer", fontSignature);
278581
278567
  for (const [type, value] of Object.entries(preFooterLayouts)) {
278582
278568
  if (!isValidFooterType(type))
278583
278569
  continue;
@@ -278640,7 +278626,7 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278640
278626
  measureCache.invalidate(Array.from(tokenResult.affectedBlockIds));
278641
278627
  const remeasureStart = performance.now();
278642
278628
  const currentPerSectionConstraints = computePerSectionConstraints(options, currentBlocks);
278643
- currentMeasures = await remeasureAffectedBlocks(currentBlocks, currentMeasures, tokenResult.affectedBlockIds, currentPerSectionConstraints, measureBlock$1, measureCache);
278629
+ currentMeasures = await remeasureAffectedBlocks(currentBlocks, currentMeasures, tokenResult.affectedBlockIds, currentPerSectionConstraints, measureBlock$1, fontSignature, measureCache);
278644
278630
  const remeasureTime = performance.now() - remeasureStart;
278645
278631
  totalRemeasureTime += remeasureTime;
278646
278632
  perfLog$1(`[Perf] 4.3.${iteration + 1}.1 Re-measure: ${remeasureTime.toFixed(2)}ms`);
@@ -278717,13 +278703,13 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
278717
278703
  const blocks2 = Array.from(needed.values());
278718
278704
  const measuresById$1 = /* @__PURE__ */ new Map;
278719
278705
  await Promise.all(blocks2.map(async (block) => {
278720
- const cached = measureCache.get(block, footnoteConstraints.maxWidth, footnoteConstraints.maxHeight);
278706
+ const cached = measureCache.get(block, footnoteConstraints.maxWidth, footnoteConstraints.maxHeight, fontSignature);
278721
278707
  if (cached) {
278722
278708
  measuresById$1.set(block.id, cached);
278723
278709
  return;
278724
278710
  }
278725
278711
  const measurement = await measureBlock$1(block, footnoteConstraints);
278726
- measureCache.set(block, footnoteConstraints.maxWidth, footnoteConstraints.maxHeight, measurement);
278712
+ measureCache.set(block, footnoteConstraints.maxWidth, footnoteConstraints.maxHeight, measurement, fontSignature);
278727
278713
  measuresById$1.set(block.id, measurement);
278728
278714
  }));
278729
278715
  return {
@@ -279679,9 +279665,9 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
279679
279665
  };
279680
279666
  } : undefined;
279681
279667
  if (headerFooter.headerBlocks)
279682
- headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header"));
279668
+ headers = serializeHeaderFooterResults("header", await layoutHeaderFooterWithCache(headerFooter.headerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "header", fontSignature));
279683
279669
  if (headerFooter.footerBlocks)
279684
- footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer"));
279670
+ footers = serializeHeaderFooterResults("footer", await layoutHeaderFooterWithCache(headerFooter.footerBlocks, headerFooter.constraints, measureFn, headerMeasureCache, FeatureFlags.HEADER_FOOTER_PAGE_TOKENS ? undefined : numberingCtx.totalPages, pageResolver, "footer", fontSignature));
279685
279671
  perfLog$1(`[Perf] 4.4 Header/footer layout: ${(performance.now() - hfStart).toFixed(2)}ms`);
279686
279672
  const cacheStats = headerMeasureCache.getStats();
279687
279673
  globalMetrics.recordHeaderFooterCacheMetrics(cacheStats);
@@ -279958,7 +279944,7 @@ function buildNumberingContext(layout, sections, blockById, chapterContextCache)
279958
279944
  }))
279959
279945
  };
279960
279946
  }
279961
- async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perBlockConstraints, measureBlock$1, measureCache$1) {
279947
+ async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perBlockConstraints, measureBlock$1, fontSignature, measureCache$1) {
279962
279948
  const updatedMeasures = [...measures];
279963
279949
  for (let i4 = 0;i4 < blocks2.length; i4++) {
279964
279950
  const block = blocks2[i4];
@@ -279968,7 +279954,7 @@ async function remeasureAffectedBlocks(blocks2, measures, affectedBlockIds, perB
279968
279954
  const newMeasure = await measureBlock$1(block, perBlockConstraints[i4]);
279969
279955
  updatedMeasures[i4] = newMeasure;
279970
279956
  const blockConstraints = perBlockConstraints[i4];
279971
- measureCache$1?.set(block, blockConstraints.maxWidth, blockConstraints.maxHeight, newMeasure);
279957
+ measureCache$1?.set(block, blockConstraints.maxWidth, blockConstraints.maxHeight, newMeasure, fontSignature);
279972
279958
  } catch (error3) {
279973
279959
  console.warn(`[incrementalLayout] Failed to re-measure block ${block.id} after token resolution:`, error3);
279974
279960
  }
@@ -285800,8 +285786,10 @@ function clearTableAutoFitMeasurementCaches() {
285800
285786
  autoFitTableResultCache.clear();
285801
285787
  }
285802
285788
  function buildTableCellContentMetricsCacheKey(cell2, options) {
285789
+ const fontContext = options.fontContext ?? DEFAULT_FONT_MEASURE_CONTEXT;
285803
285790
  return stableSerialize({
285804
285791
  maxWidth: Math.max(1, Math.round(options.maxWidth)),
285792
+ fontSignature: fontContext.fontSignature ?? "",
285805
285793
  layoutEpoch: options.layoutEpoch ?? null,
285806
285794
  attrs: cell2.attrs ?? null,
285807
285795
  paragraph: cell2.paragraph ?? null,
@@ -285815,6 +285803,7 @@ function buildAutoFitTableResultCacheKey(table2, options) {
285815
285803
  columnWidths: table2.columnWidths ?? null,
285816
285804
  rowCount: table2.rows.length,
285817
285805
  maxWidth: Math.max(1, Math.round(options.maxWidth)),
285806
+ fontSignature: options.fontSignature ?? "",
285818
285807
  layoutEpoch: options.layoutEpoch ?? null,
285819
285808
  cellMetricKeys: options.cellMetricKeys,
285820
285809
  workingGrid: {
@@ -285854,7 +285843,12 @@ function setCachedAutoFitTableResult(cacheKey, result) {
285854
285843
  autoFitTableResultCache.set(cacheKey, result);
285855
285844
  }
285856
285845
  async function measureTableCellContentMetrics(cell2, options) {
285857
- const cacheKey = buildTableCellContentMetricsCacheKey(cell2, options);
285846
+ const fontContext = options.fontContext ?? DEFAULT_FONT_MEASURE_CONTEXT;
285847
+ const normalizedOptions = {
285848
+ ...options,
285849
+ fontContext
285850
+ };
285851
+ const cacheKey = buildTableCellContentMetricsCacheKey(cell2, normalizedOptions);
285858
285852
  const cached = tableCellMetricsCache.get(cacheKey);
285859
285853
  if (cached)
285860
285854
  return cached;
@@ -285871,7 +285865,7 @@ async function measureTableCellContentMetrics(cell2, options) {
285871
285865
  let minContentWidthPx = 0;
285872
285866
  let maxContentWidthPx = 0;
285873
285867
  for (const block of contentBlocks) {
285874
- const metrics = await measureIntrinsicBlockWidthMetrics(block, options);
285868
+ const metrics = await measureIntrinsicBlockWidthMetrics(block, normalizedOptions);
285875
285869
  minContentWidthPx = Math.max(minContentWidthPx, metrics.minWidthPx);
285876
285870
  maxContentWidthPx = Math.max(maxContentWidthPx, metrics.maxWidthPx);
285877
285871
  }
@@ -285882,7 +285876,7 @@ async function measureTableCellContentMetrics(cell2, options) {
285882
285876
  tableCellMetricsCache.set(cacheKey, result);
285883
285877
  return result;
285884
285878
  }
285885
- async function measureTableAutoFitContentMetrics(table2, workingInput, fixedLayout, measureBlock$1) {
285879
+ async function measureTableAutoFitContentMetrics(table2, workingInput, fixedLayout, measureBlock$1, fontContext = DEFAULT_FONT_MEASURE_CONTEXT) {
285886
285880
  const tableMeasurementBasis = Math.max(1, fixedLayout.totalWidth);
285887
285881
  const cellMetricKeys = [];
285888
285882
  const rowMetrics = await Promise.all(table2.rows.map(async (row2, rowIndex) => {
@@ -285893,10 +285887,14 @@ async function measureTableAutoFitContentMetrics(table2, workingInput, fixedLayo
285893
285887
  const normalizedCell = normalizedRow.cells?.[cellIndex];
285894
285888
  const span = normalizedCell?.span ?? cell2.colSpan ?? 1;
285895
285889
  const measurementMaxWidth = resolveAutoFitCellMeasurementMaxWidth(cell2, normalizedCell, span, fixedLayout, tableMeasurementBasis, workingInput.gridColumnCount);
285896
- cellMetricKeys.push(buildTableCellContentMetricsCacheKey(cell2, { maxWidth: measurementMaxWidth }));
285890
+ cellMetricKeys.push(buildTableCellContentMetricsCacheKey(cell2, {
285891
+ maxWidth: measurementMaxWidth,
285892
+ fontContext
285893
+ }));
285897
285894
  const metrics = await measureTableCellContentMetrics(cell2, {
285898
285895
  maxWidth: measurementMaxWidth,
285899
- measureBlock: measureBlock$1
285896
+ measureBlock: measureBlock$1,
285897
+ fontContext
285900
285898
  });
285901
285899
  return {
285902
285900
  cellIndex,
@@ -285928,7 +285926,7 @@ async function measureTableAutoFitContentMetrics(table2, workingInput, fixedLayo
285928
285926
  }
285929
285927
  async function measureIntrinsicBlockWidthMetrics(block, options) {
285930
285928
  if (block.kind === "paragraph")
285931
- return measureParagraphIntrinsicWidthMetrics(block, options.measureBlock);
285929
+ return measureParagraphIntrinsicWidthMetrics(block, options.measureBlock, options.fontContext);
285932
285930
  if (block.kind === "table")
285933
285931
  return measureNestedTableIntrinsicWidthMetrics(block, options);
285934
285932
  const intrinsicWidth = getIntrinsicAtomicBlockWidth(block);
@@ -285937,13 +285935,13 @@ async function measureIntrinsicBlockWidthMetrics(block, options) {
285937
285935
  maxWidthPx: intrinsicWidth
285938
285936
  };
285939
285937
  }
285940
- async function measureParagraphIntrinsicWidthMetrics(paragraph2, measureBlock$1) {
285938
+ async function measureParagraphIntrinsicWidthMetrics(paragraph2, measureBlock$1, fontContext) {
285941
285939
  const maxLineWidth = (await measureBlock$1(paragraph2, {
285942
285940
  maxWidth: NO_WRAP_MAX_WIDTH,
285943
285941
  maxHeight: Infinity
285944
285942
  })).lines.reduce((widest, line) => Math.max(widest, line.width), 0);
285945
285943
  return {
285946
- minWidthPx: measureParagraphMinTokenWidth(paragraph2),
285944
+ minWidthPx: measureParagraphMinTokenWidth(paragraph2, fontContext),
285947
285945
  maxWidthPx: maxLineWidth
285948
285946
  };
285949
285947
  }
@@ -285962,7 +285960,7 @@ async function measureNestedTableIntrinsicWidthMetrics(table2, options) {
285962
285960
  maxWidthPx: nestedMeasure.totalWidth
285963
285961
  };
285964
285962
  }
285965
- function measureParagraphMinTokenWidth(paragraph2) {
285963
+ function measureParagraphMinTokenWidth(paragraph2, fontContext) {
285966
285964
  let widestToken = 0;
285967
285965
  let currentTokenWidth = 0;
285968
285966
  const flushToken = () => {
@@ -285977,7 +285975,7 @@ function measureParagraphMinTokenWidth(paragraph2) {
285977
285975
  if (isTextLikeRun(run2)) {
285978
285976
  accumulateTextRunMinTokenWidth(run2, (width) => {
285979
285977
  currentTokenWidth += width;
285980
- }, flushToken);
285978
+ }, flushToken, fontContext);
285981
285979
  continue;
285982
285980
  }
285983
285981
  flushToken();
@@ -285986,7 +285984,7 @@ function measureParagraphMinTokenWidth(paragraph2) {
285986
285984
  continue;
285987
285985
  }
285988
285986
  if (run2.kind === "fieldAnnotation") {
285989
- widestToken = Math.max(widestToken, measureFieldAnnotationWidth(run2));
285987
+ widestToken = Math.max(widestToken, measureFieldAnnotationWidth(run2, fontContext));
285990
285988
  continue;
285991
285989
  }
285992
285990
  if (run2.kind === "math")
@@ -285995,8 +285993,8 @@ function measureParagraphMinTokenWidth(paragraph2) {
285995
285993
  flushToken();
285996
285994
  return widestToken;
285997
285995
  }
285998
- function accumulateTextRunMinTokenWidth(run2, appendTokenPiece, flushToken) {
285999
- const font = buildFontString$1(run2);
285996
+ function accumulateTextRunMinTokenWidth(run2, appendTokenPiece, flushToken, fontContext) {
285997
+ const font = buildFontString$1(run2, fontContext);
286000
285998
  let cursor = 0;
286001
285999
  for (const boundary of run2.text.matchAll(TOKEN_BOUNDARY_PATTERN)) {
286002
286000
  const boundaryStart = boundary.index ?? cursor;
@@ -286062,14 +286060,15 @@ function getCanvasContext$1() {
286062
286060
  }
286063
286061
  return canvasContext$1;
286064
286062
  }
286065
- function buildFontString$1(run2) {
286063
+ function buildFontString$1(run2, fontContext) {
286066
286064
  const parts = [];
286067
286065
  if (run2.italic)
286068
286066
  parts.push("italic");
286069
286067
  if (run2.bold)
286070
286068
  parts.push("bold");
286071
286069
  parts.push(`${normalizeFontSize$1(run2.fontSize)}px`);
286072
- parts.push(toCssFontFamily(normalizeFontFamily$1(run2.fontFamily)) ?? normalizeFontFamily$1(run2.fontFamily));
286070
+ const physicalFamily = normalizeFontFamily$1(fontContext.resolvePhysical(normalizeFontFamily$1(run2.fontFamily)));
286071
+ parts.push(toCssFontFamily(physicalFamily) ?? physicalFamily);
286073
286072
  return parts.join(" ");
286074
286073
  }
286075
286074
  function applyTextTransform$1(text5, run2, startOffset = 0) {
@@ -286094,14 +286093,14 @@ function capitalizeText$1(text5, fullText, startOffset) {
286094
286093
  }
286095
286094
  return result;
286096
286095
  }
286097
- function measureFieldAnnotationWidth(run2) {
286096
+ function measureFieldAnnotationWidth(run2, fontContext) {
286098
286097
  const fontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE$1 : DEFAULT_FIELD_ANNOTATION_FONT_SIZE$1;
286099
286098
  const font = buildFontString$1({
286100
286099
  fontFamily: normalizeFontFamily$1(run2.fontFamily ?? "Arial"),
286101
286100
  fontSize,
286102
286101
  bold: run2.bold,
286103
286102
  italic: run2.italic
286104
- });
286103
+ }, fontContext);
286105
286104
  return getMeasuredTextWidth(applyTextTransform$1(run2.displayLabel || "", { text: run2.displayLabel || "" }), font, 0, getCanvasContext$1()) + (run2.highlighted === false ? 0 : FIELD_ANNOTATION_PILL_PADDING$1);
286106
286105
  }
286107
286106
  function isExplicitLineBreakRun(run2) {
@@ -286175,14 +286174,14 @@ function getCanvasContext() {
286175
286174
  }
286176
286175
  return canvasContext;
286177
286176
  }
286178
- function buildFontString(run2) {
286177
+ function buildFontString(run2, fontContext) {
286179
286178
  const parts = [];
286180
286179
  if (run2.italic)
286181
286180
  parts.push("italic");
286182
286181
  if (run2.bold)
286183
286182
  parts.push("bold");
286184
286183
  parts.push(`${run2.fontSize}px`);
286185
- const physicalFamily = resolvePhysicalFamily(run2.fontFamily);
286184
+ const physicalFamily = fontContext.resolvePhysical(run2.fontFamily);
286186
286185
  if (measurementConfig.mode === "deterministic")
286187
286186
  parts.push(measurementConfig.fonts.fallbackStack.length > 0 ? measurementConfig.fonts.fallbackStack.join(", ") : measurementConfig.fonts.deterministicFamily);
286188
286187
  else
@@ -286247,17 +286246,17 @@ function calculateEmptyParagraphMetrics(fontSize, spacing, fontInfo) {
286247
286246
  function lineHeightFontSize(run2) {
286248
286247
  return resolveBaseFontSizeForVerticalText(run2.fontSize, run2);
286249
286248
  }
286250
- function getFontInfoFromRun(run2) {
286249
+ function getFontInfoFromRun(run2, fontContext) {
286251
286250
  return {
286252
- fontFamily: normalizeFontFamily(run2.fontFamily),
286251
+ fontFamily: normalizeFontFamily(fontContext.resolvePhysical(run2.fontFamily)),
286253
286252
  fontSize: normalizeFontSize2(lineHeightFontSize(run2)),
286254
286253
  bold: run2.bold,
286255
286254
  italic: run2.italic
286256
286255
  };
286257
286256
  }
286258
- function updateMaxFontInfo(currentMaxSize, currentMaxInfo, newRun) {
286257
+ function updateMaxFontInfo(currentMaxSize, currentMaxInfo, newRun, fontContext) {
286259
286258
  if (lineHeightFontSize(newRun) >= currentMaxSize)
286260
- return getFontInfoFromRun(newRun);
286259
+ return getFontInfoFromRun(newRun, fontContext);
286261
286260
  return currentMaxInfo;
286262
286261
  }
286263
286262
  function isTextRun$22(run2) {
@@ -286275,7 +286274,7 @@ function isLineBreakRun(run2) {
286275
286274
  function isFieldAnnotationRun(run2) {
286276
286275
  return run2.kind === "fieldAnnotation";
286277
286276
  }
286278
- function measureTabAlignmentGroup(startRunIndex, runs2, ctx$1, decimalSeparator = ".") {
286277
+ function measureTabAlignmentGroup(startRunIndex, runs2, ctx$1, decimalSeparator = ".", fontContext) {
286279
286278
  const result = {
286280
286279
  totalWidth: 0,
286281
286280
  runs: [],
@@ -286296,7 +286295,7 @@ function measureTabAlignmentGroup(startRunIndex, runs2, ctx$1, decimalSeparator
286296
286295
  const textRun = run2;
286297
286296
  const text5 = textRun.text || "";
286298
286297
  if (text5.length > 0) {
286299
- const { font } = buildFontString(textRun);
286298
+ const { font } = buildFontString(textRun, fontContext);
286300
286299
  const width = measureRunWidth(text5, font, ctx$1, textRun, 0);
286301
286300
  let beforeDecimalWidth;
286302
286301
  if (!foundDecimal) {
@@ -286350,7 +286349,7 @@ function measureTabAlignmentGroup(startRunIndex, runs2, ctx$1, decimalSeparator
286350
286349
  fontSize,
286351
286350
  bold: run2.bold,
286352
286351
  italic: run2.italic
286353
- });
286352
+ }, fontContext);
286354
286353
  const pillWidth = (run2.displayLabel ? measureRunWidth(run2.displayLabel, font, ctx$1, run2, 0) : 0) + FIELD_ANNOTATION_PILL_PADDING;
286355
286354
  result.runs.push({
286356
286355
  runIndex: i4,
@@ -286366,25 +286365,25 @@ function measureTabAlignmentGroup(startRunIndex, runs2, ctx$1, decimalSeparator
286366
286365
  }
286367
286366
  return result;
286368
286367
  }
286369
- async function measureBlock(block, constraints) {
286368
+ async function measureBlock(block, constraints, fontContext = DEFAULT_FONT_MEASURE_CONTEXT) {
286370
286369
  const normalized = normalizeConstraints(constraints);
286371
286370
  if (block.kind === "drawing")
286372
286371
  return measureDrawingBlock(block, normalized);
286373
286372
  if (block.kind === "image")
286374
286373
  return measureImageBlock(block, normalized);
286375
286374
  if (block.kind === "list")
286376
- return measureListBlock(block, normalized);
286375
+ return measureListBlock(block, normalized, fontContext);
286377
286376
  if (block.kind === "table")
286378
- return measureTableBlock(block, normalized);
286377
+ return measureTableBlock(block, normalized, fontContext);
286379
286378
  if (block.kind === "sectionBreak")
286380
286379
  return { kind: "sectionBreak" };
286381
286380
  if (block.kind === "pageBreak")
286382
286381
  return { kind: "pageBreak" };
286383
286382
  if (block.kind === "columnBreak")
286384
286383
  return { kind: "columnBreak" };
286385
- return measureParagraphBlock(block, normalized.maxWidth);
286384
+ return measureParagraphBlock(block, normalized.maxWidth, fontContext);
286386
286385
  }
286387
- async function measureParagraphBlock(block, maxWidth) {
286386
+ async function measureParagraphBlock(block, maxWidth, fontContext) {
286388
286387
  const ctx$1 = getCanvasContext();
286389
286388
  const wordLayout = block.attrs?.wordLayout;
286390
286389
  const firstTextRunWithSize = block.runs.find((run2) => isTextRun$22(run2) && ("fontSize" in run2) && run2.fontSize != null);
@@ -286397,7 +286396,7 @@ async function measureParagraphBlock(block, maxWidth) {
286397
286396
  fontSize: wordLayout.marker.run.fontSize ?? fallbackFontSize,
286398
286397
  bold: wordLayout.marker.run.bold,
286399
286398
  italic: wordLayout.marker.run.italic
286400
- });
286399
+ }, fontContext);
286401
286400
  const markerText = wordLayout.marker.markerText ?? "";
286402
286401
  const glyphWidth = markerText ? measureText(markerText, markerFont, ctx$1) : 0;
286403
286402
  const gutter = typeof wordLayout.marker.gutterWidthPx === "number" && isFinite(wordLayout.marker.gutterWidthPx) && wordLayout.marker.gutterWidthPx >= 0 ? wordLayout.marker.gutterWidthPx : 8;
@@ -286430,7 +286429,7 @@ async function measureParagraphBlock(block, maxWidth) {
286430
286429
  fontSize: marker.run?.fontSize ?? fallbackFontSize,
286431
286430
  bold: marker.run?.bold ?? false,
286432
286431
  italic: marker.run?.italic ?? false
286433
- });
286432
+ }, fontContext);
286434
286433
  return measureText(markerText, markerFont, ctx$1);
286435
286434
  }) ?? textStartPx;
286436
286435
  if (typeof effectiveTextStartPx === "number" && effectiveTextStartPx > indentLeft)
@@ -286454,14 +286453,14 @@ async function measureParagraphBlock(block, maxWidth) {
286454
286453
  if (!dropCapDescriptor.run || !dropCapDescriptor.run.text || !dropCapDescriptor.lines)
286455
286454
  console.warn("Invalid drop cap descriptor - missing required fields:", dropCapDescriptor);
286456
286455
  else {
286457
- const dropCapMeasured = measureDropCap(ctx$1, dropCapDescriptor, spacing);
286456
+ const dropCapMeasured = measureDropCap(ctx$1, dropCapDescriptor, spacing, fontContext);
286458
286457
  dropCapMeasure = dropCapMeasured;
286459
286458
  dropCapDescriptor.measuredWidth = dropCapMeasured.width;
286460
286459
  dropCapDescriptor.measuredHeight = dropCapMeasured.height;
286461
286460
  }
286462
286461
  const emptyParagraphRun = normalizedRuns.length === 1 && isEmptyTextRun2(normalizedRuns[0]) && !isEmptySdtPlaceholderRun(normalizedRuns[0]) ? normalizedRuns[0] : null;
286463
286462
  if (emptyParagraphRun) {
286464
- const metrics = calculateEmptyParagraphMetrics(emptyParagraphRun.fontSize ?? DEFAULT_PARAGRAPH_FONT_SIZE, spacing, getFontInfoFromRun(emptyParagraphRun));
286463
+ const metrics = calculateEmptyParagraphMetrics(emptyParagraphRun.fontSize ?? DEFAULT_PARAGRAPH_FONT_SIZE, spacing, getFontInfoFromRun(emptyParagraphRun, fontContext));
286465
286464
  const emptyLine = {
286466
286465
  fromRun: 0,
286467
286466
  fromChar: 0,
@@ -286498,7 +286497,7 @@ async function measureParagraphBlock(block, maxWidth) {
286498
286497
  ...markerInfo ? { marker: markerInfo } : {}
286499
286498
  };
286500
286499
  }
286501
- const fallbackFontInfo = firstTextRunWithSize ? getFontInfoFromRun(firstTextRunWithSize) : undefined;
286500
+ const fallbackFontInfo = firstTextRunWithSize ? getFontInfoFromRun(firstTextRunWithSize, fontContext) : undefined;
286502
286501
  let currentLine = null;
286503
286502
  const getEffectiveWidth = (baseWidth) => {
286504
286503
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop")
@@ -286679,7 +286678,7 @@ async function measureParagraphBlock(block, maxWidth) {
286679
286678
  if (lineToTrim.fromRun === lineToTrim.toRun && sliceText.trim().length === 0)
286680
286679
  return;
286681
286680
  const keptText = sliceText.slice(0, Math.max(0, sliceText.length - trimCount));
286682
- const { font } = buildFontString(lastRun);
286681
+ const { font } = buildFontString(lastRun, fontContext);
286683
286682
  const fullWidth = measureRunWidth(sliceText, font, ctx$1, lastRun, sliceStart);
286684
286683
  const keptWidth = keptText.length > 0 ? measureRunWidth(keptText, font, ctx$1, lastRun, sliceStart) : 0;
286685
286684
  const delta = Math.max(0, fullWidth - keptWidth);
@@ -286826,7 +286825,7 @@ async function measureParagraphBlock(block, maxWidth) {
286826
286825
  toChar: 1,
286827
286826
  width: 0,
286828
286827
  maxFontSize: lastFontSize,
286829
- maxFontInfo: hasSeenTextRun ? undefined : fallbackFontInfo ?? getFontInfoFromRun(run2),
286828
+ maxFontInfo: hasSeenTextRun ? undefined : fallbackFontInfo ?? getFontInfoFromRun(run2, fontContext),
286830
286829
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
286831
286830
  segments: [],
286832
286831
  spaceCount: 0
@@ -286876,7 +286875,7 @@ async function measureParagraphBlock(block, maxWidth) {
286876
286875
  if (stop) {
286877
286876
  validateTabStopVal(stop);
286878
286877
  if (stop.val === "end" || stop.val === "center" || stop.val === "decimal") {
286879
- const groupMeasure = measureTabAlignmentGroup(runIndex + 1, runsToProcess, ctx$1, decimalSeparator);
286878
+ const groupMeasure = measureTabAlignmentGroup(runIndex + 1, runsToProcess, ctx$1, decimalSeparator, fontContext);
286880
286879
  if (groupMeasure.totalWidth > 0) {
286881
286880
  const relativeTarget = clampedTarget - effectiveIndent;
286882
286881
  let groupStartX;
@@ -287052,7 +287051,7 @@ async function measureParagraphBlock(block, maxWidth) {
287052
287051
  if (isFieldAnnotationRun(run2)) {
287053
287052
  const displayText = applyTextTransform(run2.displayLabel || "", run2);
287054
287053
  const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
287055
- const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
287054
+ const annotationFontFamily = fontContext.resolvePhysical(run2.fontFamily || "Arial, sans-serif");
287056
287055
  const fontWeight = run2.bold ? "bold" : "normal";
287057
287056
  ctx$1.font = `${run2.italic ? "italic" : "normal"} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
287058
287057
  const textWidth = displayText ? ctx$1.measureText(displayText).width : 0;
@@ -287153,7 +287152,7 @@ async function measureParagraphBlock(block, maxWidth) {
287153
287152
  continue;
287154
287153
  }
287155
287154
  if (isEmptySdtPlaceholderRun(run2)) {
287156
- const placeholderFont = buildFontString(run2).font;
287155
+ const placeholderFont = buildFontString(run2, fontContext).font;
287157
287156
  const placeholderText = applyTextTransform(EMPTY_SDT_PLACEHOLDER_TEXT, run2);
287158
287157
  const measuredPlaceholderWidth = getMeasuredTextWidth(placeholderText, placeholderFont, run2.letterSpacing ?? 0, ctx$1);
287159
287158
  const fallbackPlaceholderWidth = placeholderText.length * run2.fontSize * 0.45;
@@ -287166,7 +287165,7 @@ async function measureParagraphBlock(block, maxWidth) {
287166
287165
  toChar: 0,
287167
287166
  width: placeholderWidth,
287168
287167
  maxFontSize: lineHeightFontSize(run2),
287169
- maxFontInfo: getFontInfoFromRun(run2),
287168
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287170
287169
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
287171
287170
  segments: [{
287172
287171
  runIndex,
@@ -287199,7 +287198,7 @@ async function measureParagraphBlock(block, maxWidth) {
287199
287198
  toChar: 0,
287200
287199
  width: placeholderWidth,
287201
287200
  maxFontSize: lineHeightFontSize(run2),
287202
- maxFontInfo: getFontInfoFromRun(run2),
287201
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287203
287202
  maxWidth: getEffectiveWidth(bodyContentWidth),
287204
287203
  segments: [{
287205
287204
  runIndex,
@@ -287213,7 +287212,7 @@ async function measureParagraphBlock(block, maxWidth) {
287213
287212
  currentLine.toRun = runIndex;
287214
287213
  currentLine.toChar = 0;
287215
287214
  currentLine.width = roundValue(currentLine.width + boundarySpacing + placeholderWidth);
287216
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287215
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287217
287216
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287218
287217
  appendSegment(currentLine.segments, runIndex, 0, 0, placeholderWidth);
287219
287218
  }
@@ -287225,7 +287224,7 @@ async function measureParagraphBlock(block, maxWidth) {
287225
287224
  }
287226
287225
  lastFontSize = run2.fontSize;
287227
287226
  hasSeenTextRun = true;
287228
- const { font } = buildFontString(run2);
287227
+ const { font } = buildFontString(run2, fontContext);
287229
287228
  const tabSegments = run2.text.split("\t");
287230
287229
  let charPosInRun = 0;
287231
287230
  for (let segmentIndex = 0;segmentIndex < tabSegments.length; segmentIndex++) {
@@ -287245,7 +287244,7 @@ async function measureParagraphBlock(block, maxWidth) {
287245
287244
  toChar: spacesEndChar,
287246
287245
  width: spacesWidth,
287247
287246
  maxFontSize: lineHeightFontSize(run2),
287248
- maxFontInfo: getFontInfoFromRun(run2),
287247
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287249
287248
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
287250
287249
  segments: [{
287251
287250
  runIndex,
@@ -287277,7 +287276,7 @@ async function measureParagraphBlock(block, maxWidth) {
287277
287276
  toChar: spacesEndChar,
287278
287277
  width: spacesWidth,
287279
287278
  maxFontSize: lineHeightFontSize(run2),
287280
- maxFontInfo: getFontInfoFromRun(run2),
287279
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287281
287280
  maxWidth: getEffectiveWidth(bodyContentWidth),
287282
287281
  segments: [{
287283
287282
  runIndex,
@@ -287291,7 +287290,7 @@ async function measureParagraphBlock(block, maxWidth) {
287291
287290
  currentLine.toRun = runIndex;
287292
287291
  currentLine.toChar = spacesEndChar;
287293
287292
  currentLine.width = roundValue(currentLine.width + boundarySpacing + spacesWidth);
287294
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287293
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287295
287294
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287296
287295
  appendSegment(currentLine.segments, runIndex, spacesStartChar, spacesEndChar, spacesWidth);
287297
287296
  currentLine.spaceCount += spacesLength;
@@ -287344,7 +287343,7 @@ async function measureParagraphBlock(block, maxWidth) {
287344
287343
  toChar: spaceEndChar,
287345
287344
  width: singleSpaceWidth,
287346
287345
  maxFontSize: lineHeightFontSize(run2),
287347
- maxFontInfo: getFontInfoFromRun(run2),
287346
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287348
287347
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
287349
287348
  segments: [{
287350
287349
  runIndex,
@@ -287378,7 +287377,7 @@ async function measureParagraphBlock(block, maxWidth) {
287378
287377
  toChar: spaceEndChar,
287379
287378
  width: singleSpaceWidth,
287380
287379
  maxFontSize: lineHeightFontSize(run2),
287381
- maxFontInfo: getFontInfoFromRun(run2),
287380
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287382
287381
  maxWidth: getEffectiveWidth(bodyContentWidth),
287383
287382
  segments: [{
287384
287383
  runIndex,
@@ -287392,7 +287391,7 @@ async function measureParagraphBlock(block, maxWidth) {
287392
287391
  currentLine.toRun = runIndex;
287393
287392
  currentLine.toChar = spaceEndChar;
287394
287393
  currentLine.width = roundValue(currentLine.width + boundarySpacing$1 + singleSpaceWidth);
287395
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287394
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287396
287395
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287397
287396
  let spaceExplicitX;
287398
287397
  let spacePrecedingTabEndX;
@@ -287448,7 +287447,7 @@ async function measureParagraphBlock(block, maxWidth) {
287448
287447
  currentLine.toChar = chunkEndChar;
287449
287448
  currentLine.width = roundValue(currentLine.width + chunk2.width);
287450
287449
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287451
- currentLine.maxFontInfo = getFontInfoFromRun(run2);
287450
+ currentLine.maxFontInfo = getFontInfoFromRun(run2, fontContext);
287452
287451
  currentLine.segments.push({
287453
287452
  runIndex,
287454
287453
  fromChar: chunkStartChar,
@@ -287487,7 +287486,7 @@ async function measureParagraphBlock(block, maxWidth) {
287487
287486
  toChar: chunkEndChar,
287488
287487
  width: chunk2.width,
287489
287488
  maxFontSize: lineHeightFontSize(run2),
287490
- maxFontInfo: getFontInfoFromRun(run2),
287489
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287491
287490
  maxWidth: getEffectiveWidth(contentWidth),
287492
287491
  segments: [{
287493
287492
  runIndex,
@@ -287507,7 +287506,7 @@ async function measureParagraphBlock(block, maxWidth) {
287507
287506
  charPosInRun = wordEndWithSpace;
287508
287507
  } else {
287509
287508
  const chunkLineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
287510
- const metrics = calculateTypographyMetrics(run2.fontSize, spacing, getFontInfoFromRun(run2));
287509
+ const metrics = calculateTypographyMetrics(run2.fontSize, spacing, getFontInfoFromRun(run2, fontContext));
287511
287510
  const chunkLine = {
287512
287511
  fromRun: runIndex,
287513
287512
  fromChar: chunkStartChar,
@@ -287539,7 +287538,7 @@ async function measureParagraphBlock(block, maxWidth) {
287539
287538
  toChar: wordEndNoSpace,
287540
287539
  width: wordOnlyWidth,
287541
287540
  maxFontSize: lineHeightFontSize(run2),
287542
- maxFontInfo: getFontInfoFromRun(run2),
287541
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287543
287542
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
287544
287543
  segments: [{
287545
287544
  runIndex,
@@ -287607,7 +287606,7 @@ async function measureParagraphBlock(block, maxWidth) {
287607
287606
  toChar: wordEndNoSpace,
287608
287607
  width: wordOnlyWidth,
287609
287608
  maxFontSize: lineHeightFontSize(run2),
287610
- maxFontInfo: getFontInfoFromRun(run2),
287609
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287611
287610
  maxWidth: getEffectiveWidth(bodyContentWidth),
287612
287611
  segments: [{
287613
287612
  runIndex,
@@ -287633,7 +287632,7 @@ async function measureParagraphBlock(block, maxWidth) {
287633
287632
  if (shouldIncludeDelimiterSpace && currentLine.width + boundarySpacing + wordOnlyWidth + spaceWidth > currentLine.maxWidth - WIDTH_FUDGE_PX$1) {
287634
287633
  currentLine.toChar = wordEndNoSpace;
287635
287634
  currentLine.width = roundValue(currentLine.width + boundarySpacing + wordOnlyWidth);
287636
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287635
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287637
287636
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287638
287637
  let explicitXHere;
287639
287638
  if (inActiveTabGroup && activeTabGroup) {
@@ -287669,7 +287668,7 @@ async function measureParagraphBlock(block, maxWidth) {
287669
287668
  if (compressedWidth != null)
287670
287669
  currentLine.naturalWidth = roundValue(totalWidthWithWord);
287671
287670
  currentLine.width = roundValue(targetWidth);
287672
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287671
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287673
287672
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287674
287673
  appendSegment(currentLine.segments, runIndex, wordStartChar, newToChar, wordCommitWidth, explicitX, wordIndex === 0 ? consumeSegmentPrecedingTabEndX() : undefined);
287675
287674
  if (shouldIncludeDelimiterSpace)
@@ -287699,7 +287698,7 @@ async function measureParagraphBlock(block, maxWidth) {
287699
287698
  toChar: charPosInRun,
287700
287699
  width: 0,
287701
287700
  maxFontSize: lineHeightFontSize(run2),
287702
- maxFontInfo: getFontInfoFromRun(run2),
287701
+ maxFontInfo: getFontInfoFromRun(run2, fontContext),
287703
287702
  maxWidth: getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : bodyContentWidth),
287704
287703
  segments: [],
287705
287704
  spaceCount: 0
@@ -287715,7 +287714,7 @@ async function measureParagraphBlock(block, maxWidth) {
287715
287714
  currentLine.width = roundValue(currentLine.width + tabAdvance);
287716
287715
  if (stop?.source === "explicit")
287717
287716
  currentLine.hasExplicitTabStops = true;
287718
- currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2);
287717
+ currentLine.maxFontInfo = updateMaxFontInfo(currentLine.maxFontSize, currentLine.maxFontInfo, run2, fontContext);
287719
287718
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, lineHeightFontSize(run2));
287720
287719
  currentLine.toRun = runIndex;
287721
287720
  currentLine.toChar = charPosInRun;
@@ -287779,9 +287778,9 @@ async function measureParagraphBlock(block, maxWidth) {
287779
287778
  ...dropCapMeasure ? { dropCap: dropCapMeasure } : {}
287780
287779
  };
287781
287780
  }
287782
- async function measureTableBlock(block, constraints) {
287781
+ async function measureTableBlock(block, constraints, fontContext) {
287783
287782
  const workingInput = buildAutoFitWorkingGridInput(block, { maxWidth: typeof constraints === "number" ? constraints : constraints.maxWidth });
287784
- const columnWidths = await resolveRuntimeTableColumnWidths(block, workingInput);
287783
+ const columnWidths = await resolveRuntimeTableColumnWidths(block, workingInput, fontContext);
287785
287784
  const gridColumnCount = columnWidths.length;
287786
287785
  const calculateCellWidth = (startCol, colspan) => {
287787
287786
  let width = 0;
@@ -287832,7 +287831,7 @@ async function measureTableBlock(block, constraints) {
287832
287831
  const measure = await measureBlock(block$1, {
287833
287832
  maxWidth: contentWidth$1,
287834
287833
  maxHeight: Infinity
287835
- });
287834
+ }, fontContext);
287836
287835
  blockMeasures.push(measure);
287837
287836
  const blockHeight = "totalHeight" in measure ? measure.totalHeight : ("height" in measure) ? measure.height : 0;
287838
287837
  if ((block$1.kind === "image" || block$1.kind === "drawing") && block$1.anchor?.isAnchored === true && (block$1.wrap?.type ?? "Inline") !== "Inline")
@@ -287920,14 +287919,15 @@ async function measureTableBlock(block, constraints) {
287920
287919
  tableBorderWidths: borderWidthH > 0 || borderWidthV > 0 ? tableBorderWidths : undefined
287921
287920
  };
287922
287921
  }
287923
- async function resolveRuntimeTableColumnWidths(block, workingInput) {
287922
+ async function resolveRuntimeTableColumnWidths(block, workingInput, fontContext) {
287924
287923
  const fixedLayout = computeFixedTableColumnWidths(workingInput);
287925
287924
  if (workingInput.layoutMode === "fixed")
287926
287925
  return fixedLayout.columnWidths;
287927
- const { contentMetrics, cellMetricKeys } = await buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout);
287926
+ const { contentMetrics, cellMetricKeys } = await buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout, fontContext);
287928
287927
  const cacheKey = buildAutoFitTableResultCacheKey(block, {
287929
287928
  maxWidth: workingInput.maxTableWidth,
287930
287929
  cellMetricKeys,
287930
+ fontSignature: fontContext.fontSignature,
287931
287931
  workingInput,
287932
287932
  fixedLayout
287933
287933
  });
@@ -287945,8 +287945,9 @@ async function resolveRuntimeTableColumnWidths(block, workingInput) {
287945
287945
  });
287946
287946
  return result.columnWidths;
287947
287947
  }
287948
- async function buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout) {
287949
- const contentMetrics = await measureTableAutoFitContentMetrics(block, workingInput, fixedLayout, measureBlock);
287948
+ async function buildMeasuredAutoFitContentMetrics(block, workingInput, fixedLayout, fontContext) {
287949
+ const measureBlockWithFontContext = (childBlock, childConstraints) => measureBlock(childBlock, childConstraints, fontContext);
287950
+ const contentMetrics = await measureTableAutoFitContentMetrics(block, workingInput, fixedLayout, measureBlockWithFontContext, fontContext);
287950
287951
  return {
287951
287952
  contentMetrics,
287952
287953
  cellMetricKeys: contentMetrics.cellMetricKeys
@@ -288060,7 +288061,7 @@ function normalizeConstraints(constraints) {
288060
288061
  return { maxWidth: constraints };
288061
288062
  return constraints;
288062
288063
  }
288063
- async function measureListBlock(block, constraints) {
288064
+ async function measureListBlock(block, constraints, fontContext) {
288064
288065
  const ctx$1 = getCanvasContext();
288065
288066
  const items = [];
288066
288067
  let totalHeight = 0;
@@ -288079,12 +288080,12 @@ async function measureListBlock(block, constraints) {
288079
288080
  bold: marker.run.bold,
288080
288081
  italic: marker.run.italic,
288081
288082
  letterSpacing: marker.run.letterSpacing
288082
- });
288083
+ }, fontContext);
288083
288084
  markerTextWidth = marker.markerText ? measureText(marker.markerText, markerFont, ctx$1) : 0;
288084
288085
  markerWidth = 0;
288085
288086
  indentLeft = wordLayout.indentLeftPx ?? 0;
288086
288087
  } else {
288087
- const { font: markerFont } = buildFontString(getPrimaryRun(item.paragraph));
288088
+ const { font: markerFont } = buildFontString(getPrimaryRun(item.paragraph), fontContext);
288088
288089
  const markerText = item.marker.text ?? "";
288089
288090
  markerTextWidth = markerText ? measureText(markerText, markerFont, ctx$1) : 0;
288090
288091
  indentLeft = resolveIndentLeft(item);
@@ -288092,7 +288093,7 @@ async function measureListBlock(block, constraints) {
288092
288093
  markerWidth = Math.max(24, markerTextWidth + 8, indentHanging);
288093
288094
  }
288094
288095
  const paragraphWidth = Math.max(1, constraints.maxWidth - indentLeft - markerWidth);
288095
- const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth);
288096
+ const paragraphMeasure = await measureParagraphBlock(item.paragraph, paragraphWidth, fontContext);
288096
288097
  totalHeight += paragraphMeasure.totalHeight;
288097
288098
  items.push({
288098
288099
  itemId: item.id,
@@ -288108,7 +288109,7 @@ async function measureListBlock(block, constraints) {
288108
288109
  totalHeight
288109
288110
  };
288110
288111
  }
288111
- async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, deps) {
288112
+ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, deps, fontResolver) {
288112
288113
  deps.headerLayoutsByRId.clear();
288113
288114
  deps.footerLayoutsByRId.clear();
288114
288115
  if (!headerFooterInput)
@@ -288131,25 +288132,30 @@ async function layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetad
288131
288132
  };
288132
288133
  };
288133
288134
  if (sectionMetadata.length > 1 && sectionMetadata.some((s2) => s2.margins || s2.pageSize)) {
288134
- await layoutWithPerSectionConstraints("header", headerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.headerLayoutsByRId);
288135
- await layoutWithPerSectionConstraints("footer", footerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.footerLayoutsByRId);
288135
+ await layoutWithPerSectionConstraints("header", headerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.headerLayoutsByRId, fontResolver);
288136
+ await layoutWithPerSectionConstraints("footer", footerBlocksByRId, sectionMetadata, constraints, pageResolver, deps.footerLayoutsByRId, fontResolver);
288136
288137
  } else {
288137
288138
  const effectiveHeaderRefsBySection = buildEffectiveHeaderFooterRefsBySection(sectionMetadata, "header");
288138
288139
  const effectiveFooterRefsBySection = buildEffectiveHeaderFooterRefsBySection(sectionMetadata, "footer");
288139
- await layoutBlocksByRId("header", headerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveHeaderRefsBySection), constraints, pageResolver, deps.headerLayoutsByRId);
288140
- await layoutBlocksByRId("footer", footerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveFooterRefsBySection), constraints, pageResolver, deps.footerLayoutsByRId);
288140
+ await layoutBlocksByRId("header", headerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveHeaderRefsBySection), constraints, pageResolver, deps.headerLayoutsByRId, fontResolver);
288141
+ await layoutBlocksByRId("footer", footerBlocksByRId, collectReferencedHeaderFooterRIds(effectiveFooterRefsBySection), constraints, pageResolver, deps.footerLayoutsByRId, fontResolver);
288141
288142
  }
288142
288143
  }
288143
- async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints, pageResolver, layoutsByRId) {
288144
+ async function layoutBlocksByRId(kind, blocksByRId, referencedRIds, constraints, pageResolver, layoutsByRId, fontResolver) {
288144
288145
  if (!blocksByRId || referencedRIds.size === 0)
288145
288146
  return;
288147
+ const fontSignature = fontResolver?.signature ?? "";
288148
+ const fontMeasureContext = fontResolver ? {
288149
+ resolvePhysical: (css) => fontResolver.resolvePhysicalFamily(css),
288150
+ fontSignature
288151
+ } : undefined;
288146
288152
  for (const [rId, blocks2] of blocksByRId) {
288147
288153
  if (!referencedRIds.has(rId))
288148
288154
  continue;
288149
288155
  if (!blocks2 || blocks2.length === 0)
288150
288156
  continue;
288151
288157
  try {
288152
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c), undefined, undefined, pageResolver, kind);
288158
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, constraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
288153
288159
  if (batchResult.default)
288154
288160
  layoutsByRId.set(rId, {
288155
288161
  kind,
@@ -288195,16 +288201,21 @@ function adjustFramePositionsForContentWidth(layout, blocks2, effectiveWidth, co
288195
288201
  fragment2.x -= widthDiff / 2;
288196
288202
  }
288197
288203
  }
288198
- async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadata, fallbackConstraints, pageResolver, layoutsByRId) {
288204
+ async function layoutWithPerSectionConstraints(kind, blocksByRId, sectionMetadata, fallbackConstraints, pageResolver, layoutsByRId, fontResolver) {
288199
288205
  if (!blocksByRId)
288200
288206
  return;
288207
+ const fontSignature = fontResolver?.signature ?? "";
288208
+ const fontMeasureContext = fontResolver ? {
288209
+ resolvePhysical: (css) => fontResolver.resolvePhysicalFamily(css),
288210
+ fontSignature
288211
+ } : undefined;
288201
288212
  const groups = buildSectionAwareHeaderFooterMeasurementGroups(kind, blocksByRId, sectionMetadata, fallbackConstraints);
288202
288213
  for (const group of groups) {
288203
288214
  const blocks2 = blocksByRId.get(group.rId);
288204
288215
  if (!blocks2 || blocks2.length === 0)
288205
288216
  continue;
288206
288217
  try {
288207
- const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c), undefined, undefined, pageResolver, kind);
288218
+ const batchResult = await layoutHeaderFooterWithCache({ default: blocks2 }, group.sectionConstraints, (block, c) => measureBlock(block, c, fontMeasureContext), undefined, undefined, pageResolver, kind, fontSignature);
288208
288219
  if (batchResult.default)
288209
288220
  for (const sectionIndex of group.sectionIndices) {
288210
288221
  const contentWidth = buildSectionContentWidth(sectionMetadata.find((s2) => s2.sectionIndex === sectionIndex), fallbackConstraints);
@@ -288567,9 +288578,9 @@ function refForVariant(refs, variant) {
288567
288578
  matchedVariant: "default"
288568
288579
  } : undefined;
288569
288580
  }
288570
- function resolveResult(result, storyId) {
288581
+ function resolveResult(result, storyId, fontSignature = "") {
288571
288582
  const story = buildHeaderFooterStory(result.kind, storyId ?? String(result.type));
288572
- return resolveHeaderFooterLayout(result.layout, result.blocks, result.measures, story);
288583
+ return resolveHeaderFooterLayout(result.layout, result.blocks, result.measures, story, fontSignature);
288573
288584
  }
288574
288585
  function shiftResolvedPaintItemY(item, yOffset) {
288575
288586
  if (item.kind === "group")
@@ -288854,13 +288865,23 @@ function defaultInvalidate() {
288854
288865
  clearTextMeasurementCaches();
288855
288866
  measureCache.clear();
288856
288867
  }
288868
+ function toCssFontSource(url2) {
288869
+ return /^\s*url\(/i.test(url2) ? url2 : `url(${JSON.stringify(url2)})`;
288870
+ }
288871
+ function defaultScheduleMicrotask(callback) {
288872
+ if (typeof queueMicrotask === "function") {
288873
+ queueMicrotask(callback);
288874
+ return;
288875
+ }
288876
+ Promise.resolve().then(callback);
288877
+ }
288857
288878
  function faceKey(req) {
288858
288879
  return `${req.family.toLowerCase()}|${req.weight}|${req.style}`;
288859
288880
  }
288860
- function collect(out, node3) {
288881
+ function collect(out, node3, resolve3) {
288861
288882
  if (!node3 || typeof node3.fontFamily !== "string" || !node3.fontFamily)
288862
288883
  return;
288863
- const family$1 = resolvePrimaryPhysicalFamily(node3.fontFamily);
288884
+ const family$1 = resolve3(node3.fontFamily);
288864
288885
  if (!family$1)
288865
288886
  return;
288866
288887
  const req = {
@@ -288872,7 +288893,7 @@ function collect(out, node3) {
288872
288893
  if (!out.has(key2))
288873
288894
  out.set(key2, req);
288874
288895
  }
288875
- function collectRuns(out, runs2) {
288896
+ function collectRuns(out, runs2, resolve3) {
288876
288897
  if (!runs2)
288877
288898
  return;
288878
288899
  for (const run2 of runs2) {
@@ -288881,51 +288902,52 @@ function collectRuns(out, runs2) {
288881
288902
  collect(out, {
288882
288903
  ...bearing,
288883
288904
  fontFamily: "Arial"
288884
- });
288905
+ }, resolve3);
288885
288906
  else
288886
- collect(out, bearing);
288907
+ collect(out, bearing, resolve3);
288887
288908
  }
288888
288909
  }
288889
- function collectParagraph(out, paragraph2) {
288910
+ function collectParagraph(out, paragraph2, resolve3) {
288890
288911
  if (!paragraph2)
288891
288912
  return;
288892
- collectRuns(out, paragraph2.runs);
288893
- collect(out, paragraph2.attrs?.wordLayout?.marker?.run);
288894
- collect(out, paragraph2.attrs?.dropCapDescriptor?.run);
288913
+ collectRuns(out, paragraph2.runs, resolve3);
288914
+ collect(out, paragraph2.attrs?.wordLayout?.marker?.run, resolve3);
288915
+ collect(out, paragraph2.attrs?.dropCapDescriptor?.run, resolve3);
288895
288916
  }
288896
- function collectTable(out, table2) {
288917
+ function collectTable(out, table2, resolve3) {
288897
288918
  for (const row2 of table2.rows)
288898
288919
  for (const cell2 of row2.cells) {
288899
- collectParagraph(out, cell2.paragraph);
288920
+ collectParagraph(out, cell2.paragraph, resolve3);
288900
288921
  if (cell2.blocks)
288901
288922
  for (const b$1 of cell2.blocks)
288902
- collectBlock(out, b$1);
288923
+ collectBlock(out, b$1, resolve3);
288903
288924
  }
288904
288925
  }
288905
- function collectList(out, list5) {
288926
+ function collectList(out, list5, resolve3) {
288906
288927
  for (const item of list5.items)
288907
- collectParagraph(out, item.paragraph);
288928
+ collectParagraph(out, item.paragraph, resolve3);
288908
288929
  }
288909
- function collectBlock(out, block) {
288930
+ function collectBlock(out, block, resolve3) {
288910
288931
  switch (block.kind) {
288911
288932
  case "paragraph":
288912
- collectParagraph(out, block);
288933
+ collectParagraph(out, block, resolve3);
288913
288934
  break;
288914
288935
  case "table":
288915
- collectTable(out, block);
288936
+ collectTable(out, block, resolve3);
288916
288937
  break;
288917
288938
  case "list":
288918
- collectList(out, block);
288939
+ collectList(out, block, resolve3);
288919
288940
  break;
288920
288941
  default:
288921
288942
  break;
288922
288943
  }
288923
288944
  }
288924
- function planRequiredFontFaces(blocks2) {
288945
+ function planRequiredFontFaces(blocks2, resolver2) {
288946
+ const resolve3 = resolver2 ? (family$1) => resolver2.resolvePrimaryPhysicalFamily(family$1) : resolvePrimaryPhysicalFamily;
288925
288947
  const out = /* @__PURE__ */ new Map;
288926
288948
  if (blocks2)
288927
288949
  for (const block of blocks2)
288928
- collectBlock(out, block);
288950
+ collectBlock(out, block, resolve3);
288929
288951
  return [...out.values()];
288930
288952
  }
288931
288953
  function buildSemanticFootnoteBlocks(input2, footnotesMode) {
@@ -310006,7 +310028,370 @@ menclose::after {
310006
310028
  const minReadablePx = getMinimumReadableTextStartPx(markerContentEndPx, gutterWidthPx);
310007
310029
  return Math.max(nextTabStopPx, minReadablePx);
310008
310030
  }
310009
- }, hashParagraphBorder$2 = (border) => {
310031
+ }, SETTLED_STATUSES, BUNDLED_SUBSTITUTES, FontResolver = class {
310032
+ #overrides = /* @__PURE__ */ new Map;
310033
+ #version = 0;
310034
+ #cachedSignature = null;
310035
+ map(logicalFamily, physicalFamily) {
310036
+ const key2 = normalizeFamilyKey$2(logicalFamily);
310037
+ const physical = physicalFamily?.trim();
310038
+ if (!key2 || !physical)
310039
+ return;
310040
+ if (this.#overrides.get(key2) === physical)
310041
+ return;
310042
+ if ((BUNDLED_SUBSTITUTES[key2] ?? logicalFamily.trim()) === physical) {
310043
+ if (this.#overrides.delete(key2)) {
310044
+ this.#version += 1;
310045
+ this.#cachedSignature = null;
310046
+ }
310047
+ return;
310048
+ }
310049
+ this.#overrides.set(key2, physical);
310050
+ this.#version += 1;
310051
+ this.#cachedSignature = null;
310052
+ }
310053
+ unmap(logicalFamily) {
310054
+ if (this.#overrides.delete(normalizeFamilyKey$2(logicalFamily))) {
310055
+ this.#version += 1;
310056
+ this.#cachedSignature = null;
310057
+ }
310058
+ }
310059
+ reset() {
310060
+ if (this.#overrides.size === 0)
310061
+ return;
310062
+ this.#overrides.clear();
310063
+ this.#version += 1;
310064
+ this.#cachedSignature = null;
310065
+ }
310066
+ get version() {
310067
+ return this.#version;
310068
+ }
310069
+ get signature() {
310070
+ if (this.#cachedSignature !== null)
310071
+ return this.#cachedSignature;
310072
+ this.#cachedSignature = this.#overrides.size === 0 ? "" : JSON.stringify([...this.#overrides.entries()].sort(([a2], [b$1]) => a2 < b$1 ? -1 : a2 > b$1 ? 1 : 0));
310073
+ return this.#cachedSignature;
310074
+ }
310075
+ #physicalFor(bareFamily) {
310076
+ const key2 = normalizeFamilyKey$2(bareFamily);
310077
+ const override = this.#overrides.get(key2);
310078
+ if (override)
310079
+ return {
310080
+ physical: override,
310081
+ reason: "custom_mapping"
310082
+ };
310083
+ const bundled = BUNDLED_SUBSTITUTES[key2];
310084
+ if (bundled)
310085
+ return {
310086
+ physical: bundled,
310087
+ reason: "bundled_substitute"
310088
+ };
310089
+ return {
310090
+ physical: bareFamily,
310091
+ reason: "as_requested"
310092
+ };
310093
+ }
310094
+ resolveFontFamily(logicalFamily) {
310095
+ const primary = splitStack(logicalFamily)[0] ?? logicalFamily;
310096
+ const { physical, reason } = this.#physicalFor(primary);
310097
+ return {
310098
+ logicalFamily,
310099
+ physicalFamily: physical,
310100
+ reason
310101
+ };
310102
+ }
310103
+ resolvePhysicalFamily(cssFontFamily) {
310104
+ if (!cssFontFamily)
310105
+ return cssFontFamily;
310106
+ const parts = splitStack(cssFontFamily);
310107
+ if (parts.length === 0)
310108
+ return cssFontFamily;
310109
+ const { physical, reason } = this.#physicalFor(parts[0]);
310110
+ if (reason === "as_requested")
310111
+ return cssFontFamily;
310112
+ return [physical, ...parts.slice(1)].join(", ");
310113
+ }
310114
+ resolvePrimaryPhysicalFamily(family$1) {
310115
+ const primary = splitStack(family$1)[0] ?? family$1;
310116
+ return this.#physicalFor(primary).physical;
310117
+ }
310118
+ resolvePhysicalFamilies(families) {
310119
+ const out = /* @__PURE__ */ new Set;
310120
+ for (const family$1 of families)
310121
+ if (family$1)
310122
+ out.add(this.resolvePrimaryPhysicalFamily(family$1));
310123
+ return [...out];
310124
+ }
310125
+ }, defaultResolver, DEFAULT_FONT_MEASURE_CONTEXT, fontConfigVersion = 0, BUNDLED_MANIFEST, defaultAssetBase = "/fonts/", installedRegistries, DEFAULT_FONT_LOAD_TIMEOUT_MS = 3000, DEFAULT_PROBE_SIZE = "16px", FontRegistry = class {
310126
+ #fontSet;
310127
+ #FontFaceCtor;
310128
+ #probeSize;
310129
+ #scheduleTimeout;
310130
+ #cancelTimeout;
310131
+ #managed = /* @__PURE__ */ new Map;
310132
+ #status = /* @__PURE__ */ new Map;
310133
+ #sources = /* @__PURE__ */ new Map;
310134
+ #warnedFailures = /* @__PURE__ */ new Set;
310135
+ #inflight = /* @__PURE__ */ new Map;
310136
+ #faceStatus = /* @__PURE__ */ new Map;
310137
+ #faceInflight = /* @__PURE__ */ new Map;
310138
+ #faceSources = /* @__PURE__ */ new Map;
310139
+ #facesByFamily = /* @__PURE__ */ new Map;
310140
+ #warnedFaceFailures = /* @__PURE__ */ new Set;
310141
+ constructor(options = {}) {
310142
+ this.#fontSet = options.fontSet ?? null;
310143
+ this.#FontFaceCtor = options.FontFaceCtor ?? null;
310144
+ this.#probeSize = options.probeSize ?? DEFAULT_PROBE_SIZE;
310145
+ this.#scheduleTimeout = options.scheduleTimeout ?? ((cb, ms) => globalThis.setTimeout(cb, ms));
310146
+ this.#cancelTimeout = options.cancelTimeout ?? ((handle3) => globalThis.clearTimeout(handle3));
310147
+ }
310148
+ register(descriptor) {
310149
+ const { family: family$1, source, descriptors: descriptors2 } = descriptor;
310150
+ const identitySource = typeof source === "string" ? canonicalizeFontSource(source) : source;
310151
+ const key2 = faceKeyOf$1(family$1, normalizeWeight(descriptors2?.weight), normalizeStyle$1(descriptors2?.style));
310152
+ if (typeof identitySource === "string") {
310153
+ const existingSource = this.#faceSources.get(key2);
310154
+ if (existingSource === identitySource)
310155
+ return {
310156
+ family: family$1,
310157
+ status: this.getStatus(family$1),
310158
+ changed: false
310159
+ };
310160
+ if (existingSource !== undefined)
310161
+ throw new Error(`[superdoc] font face "${key2}" is already registered from a different source ("${existingSource}"); a registered face's source cannot be replaced`);
310162
+ }
310163
+ if (this.#FontFaceCtor && this.#fontSet) {
310164
+ const face = new this.#FontFaceCtor(family$1, source, descriptors2);
310165
+ this.#fontSet.add(face);
310166
+ this.#managed.set(family$1, face);
310167
+ }
310168
+ if (typeof source === "string") {
310169
+ const list5 = this.#sources.get(family$1) ?? [];
310170
+ if (!list5.includes(source))
310171
+ list5.push(source);
310172
+ this.#sources.set(family$1, list5);
310173
+ }
310174
+ if (!this.#status.has(family$1))
310175
+ this.#status.set(family$1, "unloaded");
310176
+ this.#trackFace(family$1, key2);
310177
+ if (!this.#faceStatus.has(key2))
310178
+ this.#faceStatus.set(key2, "unloaded");
310179
+ if (typeof identitySource === "string" && !this.#faceSources.has(key2))
310180
+ this.#faceSources.set(key2, identitySource);
310181
+ return {
310182
+ family: family$1,
310183
+ status: this.getStatus(family$1),
310184
+ changed: true
310185
+ };
310186
+ }
310187
+ #trackFace(family$1, key2) {
310188
+ const fam = normalizeFamilyKey$1(family$1);
310189
+ const set = this.#facesByFamily.get(fam) ?? /* @__PURE__ */ new Set;
310190
+ set.add(key2);
310191
+ this.#facesByFamily.set(fam, set);
310192
+ }
310193
+ isManaged(family$1) {
310194
+ return this.#managed.has(family$1);
310195
+ }
310196
+ getStatus(family$1) {
310197
+ const statuses = [];
310198
+ const faceKeys = this.#facesByFamily.get(normalizeFamilyKey$1(family$1));
310199
+ if (faceKeys)
310200
+ for (const k$1 of faceKeys)
310201
+ statuses.push(this.#faceStatus.get(k$1) ?? "unloaded");
310202
+ const legacy = this.#status.get(family$1);
310203
+ if (legacy)
310204
+ statuses.push(legacy);
310205
+ if (statuses.length === 0)
310206
+ return "unloaded";
310207
+ for (const s2 of [
310208
+ "failed",
310209
+ "timed_out",
310210
+ "fallback_used",
310211
+ "loaded",
310212
+ "loading",
310213
+ "unloaded"
310214
+ ])
310215
+ if (statuses.includes(s2))
310216
+ return s2;
310217
+ return "unloaded";
310218
+ }
310219
+ isAvailable(family$1) {
310220
+ if (!this.#fontSet)
310221
+ return false;
310222
+ try {
310223
+ return this.#fontSet.check(`${this.#probeSize} ${quoteFamily(family$1)}`);
310224
+ } catch {
310225
+ return false;
310226
+ }
310227
+ }
310228
+ awaitFace(family$1, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
310229
+ if (this.#status.get(family$1) === "loaded")
310230
+ return Promise.resolve({
310231
+ family: family$1,
310232
+ status: "loaded"
310233
+ });
310234
+ const existing = this.#inflight.get(family$1);
310235
+ if (existing)
310236
+ return existing;
310237
+ const probe = this.#loadOne(family$1, timeoutMs).finally(() => {
310238
+ this.#inflight.delete(family$1);
310239
+ });
310240
+ this.#inflight.set(family$1, probe);
310241
+ return probe;
310242
+ }
310243
+ async awaitFaces(families, options = {}) {
310244
+ const unique$2 = [...new Set(families)];
310245
+ const timeoutMs = options.timeoutMs ?? 3000;
310246
+ return Promise.all(unique$2.map((family$1) => this.awaitFace(family$1, timeoutMs)));
310247
+ }
310248
+ getRequiredFaces(families, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
310249
+ return [...new Set(families)].map((family$1) => ({
310250
+ family: family$1,
310251
+ status: this.getStatus(family$1),
310252
+ ready: this.awaitFace(family$1, timeoutMs)
310253
+ }));
310254
+ }
310255
+ getStates() {
310256
+ return [...this.#status.entries()].map(([family$1, status]) => ({
310257
+ family: family$1,
310258
+ status
310259
+ }));
310260
+ }
310261
+ getFaceStatus(request) {
310262
+ return this.#faceStatus.get(faceKeyOf$1(request.family, request.weight, request.style)) ?? "unloaded";
310263
+ }
310264
+ awaitFaceRequest(request, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
310265
+ const key2 = faceKeyOf$1(request.family, request.weight, request.style);
310266
+ if (this.#faceStatus.get(key2) === "loaded")
310267
+ return Promise.resolve({
310268
+ request,
310269
+ status: "loaded"
310270
+ });
310271
+ const existing = this.#faceInflight.get(key2);
310272
+ if (existing)
310273
+ return existing;
310274
+ const probe = this.#loadOneFace(request, key2, timeoutMs).finally(() => {
310275
+ this.#faceInflight.delete(key2);
310276
+ });
310277
+ this.#faceInflight.set(key2, probe);
310278
+ return probe;
310279
+ }
310280
+ async awaitFaceRequests(requests, options = {}) {
310281
+ const timeoutMs = options.timeoutMs ?? 3000;
310282
+ const seen = /* @__PURE__ */ new Set;
310283
+ const unique$2 = [];
310284
+ for (const r$1 of requests) {
310285
+ const key2 = faceKeyOf$1(r$1.family, r$1.weight, r$1.style);
310286
+ if (seen.has(key2))
310287
+ continue;
310288
+ seen.add(key2);
310289
+ unique$2.push(r$1);
310290
+ }
310291
+ return Promise.all(unique$2.map((r$1) => this.awaitFaceRequest(r$1, timeoutMs)));
310292
+ }
310293
+ async#loadOneFace(request, key2, timeoutMs) {
310294
+ this.#trackFace(request.family, key2);
310295
+ const fontSet = this.#fontSet;
310296
+ if (!fontSet) {
310297
+ this.#faceStatus.set(key2, "fallback_used");
310298
+ return {
310299
+ request,
310300
+ status: "fallback_used"
310301
+ };
310302
+ }
310303
+ this.#faceStatus.set(key2, "loading");
310304
+ const probe = faceProbe(request.family, request.weight, request.style, this.#probeSize);
310305
+ const TIMEOUT = Symbol("timeout");
310306
+ let handle3;
310307
+ const timeout$1 = new Promise((resolve3) => {
310308
+ handle3 = this.#scheduleTimeout(() => resolve3(TIMEOUT), timeoutMs);
310309
+ });
310310
+ try {
310311
+ const settled = await Promise.race([fontSet.load(probe), timeout$1]);
310312
+ if (settled === TIMEOUT) {
310313
+ this.#faceStatus.set(key2, "timed_out");
310314
+ return {
310315
+ request,
310316
+ status: "timed_out"
310317
+ };
310318
+ }
310319
+ const status = settled.length > 0 ? "loaded" : "fallback_used";
310320
+ this.#faceStatus.set(key2, status);
310321
+ return {
310322
+ request,
310323
+ status
310324
+ };
310325
+ } catch {
310326
+ this.#faceStatus.set(key2, "failed");
310327
+ this.#warnFaceFailureOnce(request, key2);
310328
+ return {
310329
+ request,
310330
+ status: "failed"
310331
+ };
310332
+ } finally {
310333
+ this.#cancelTimeout(handle3);
310334
+ }
310335
+ }
310336
+ #warnFaceFailureOnce(request, key2) {
310337
+ if (this.#warnedFaceFailures.has(key2))
310338
+ return;
310339
+ this.#warnedFaceFailures.add(key2);
310340
+ const src = this.#faceSources.get(key2);
310341
+ const detail = src ? ` from ${src}` : "";
310342
+ console.warn(`[superdoc] font face failed to load: "${request.family}" ${request.weight} ${request.style}${detail}. Check fonts.assetBaseUrl / fonts.resolveAssetUrl so the bundled .woff2 are served.`);
310343
+ }
310344
+ async#loadOne(family$1, timeoutMs) {
310345
+ const fontSet = this.#fontSet;
310346
+ if (!fontSet) {
310347
+ this.#status.set(family$1, "fallback_used");
310348
+ return {
310349
+ family: family$1,
310350
+ status: "fallback_used"
310351
+ };
310352
+ }
310353
+ this.#status.set(family$1, "loading");
310354
+ const probe = `${this.#probeSize} ${quoteFamily(family$1)}`;
310355
+ const TIMEOUT = Symbol("timeout");
310356
+ let handle3;
310357
+ const timeout$1 = new Promise((resolve3) => {
310358
+ handle3 = this.#scheduleTimeout(() => resolve3(TIMEOUT), timeoutMs);
310359
+ });
310360
+ try {
310361
+ const settled = await Promise.race([fontSet.load(probe), timeout$1]);
310362
+ if (settled === TIMEOUT) {
310363
+ this.#status.set(family$1, "timed_out");
310364
+ return {
310365
+ family: family$1,
310366
+ status: "timed_out"
310367
+ };
310368
+ }
310369
+ const status = settled.length > 0 ? "loaded" : "fallback_used";
310370
+ this.#status.set(family$1, status);
310371
+ return {
310372
+ family: family$1,
310373
+ status
310374
+ };
310375
+ } catch {
310376
+ this.#status.set(family$1, "failed");
310377
+ this.#warnLoadFailureOnce(family$1);
310378
+ return {
310379
+ family: family$1,
310380
+ status: "failed"
310381
+ };
310382
+ } finally {
310383
+ this.#cancelTimeout(handle3);
310384
+ }
310385
+ }
310386
+ #warnLoadFailureOnce(family$1) {
310387
+ if (this.#warnedFailures.has(family$1))
310388
+ return;
310389
+ this.#warnedFailures.add(family$1);
310390
+ const sources = this.#sources.get(family$1);
310391
+ const detail = sources && sources.length ? ` from ${sources.join(", ")}` : "";
310392
+ console.warn(`[superdoc] font asset failed to load for "${family$1}"${detail}. Check fonts.assetBaseUrl / fonts.resolveAssetUrl so the bundled .woff2 are served.`);
310393
+ }
310394
+ }, registriesByFontSet, domlessRegistry = null, hashParagraphBorder$2 = (border) => {
310010
310395
  const parts = [];
310011
310396
  if (border.style !== undefined)
310012
310397
  parts.push(`s:${border.style}`);
@@ -310323,7 +310708,7 @@ menclose::after {
310323
310708
  if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
310324
310709
  return;
310325
310710
  return value;
310326
- }, resolvePainterMarkerTextWidth = (markerTextWidthPx, marker) => getFiniteNonNegativeNumber(markerTextWidthPx) ?? getFiniteNonNegativeNumber(marker.glyphWidthPx) ?? getFiniteNonNegativeNumber(marker.markerBoxWidthPx) ?? 0, resolvePainterListMarkerGeometry = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListMarkerGeometry(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), resolvePainterListTextStartPx = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListTextStartPx(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), isMarkerSuffix = (suffix) => suffix === "tab" || suffix === "space" || suffix === "nothing", createListMarkerElement = (doc$12, markerText, run2, sourceAnchor) => {
310711
+ }, resolvePainterMarkerTextWidth = (markerTextWidthPx, marker) => getFiniteNonNegativeNumber(markerTextWidthPx) ?? getFiniteNonNegativeNumber(marker.glyphWidthPx) ?? getFiniteNonNegativeNumber(marker.markerBoxWidthPx) ?? 0, resolvePainterListMarkerGeometry = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListMarkerGeometry(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), resolvePainterListTextStartPx = ({ wordLayout, indentLeftPx, hangingIndentPx, firstLineIndentPx, markerTextWidthPx }) => resolveListTextStartPx(wordLayout, indentLeftPx, firstLineIndentPx, hangingIndentPx, (_markerText, marker) => resolvePainterMarkerTextWidth(markerTextWidthPx, marker)), isMarkerSuffix = (suffix) => suffix === "tab" || suffix === "space" || suffix === "nothing", createListMarkerElement = (doc$12, markerText, run2, sourceAnchor, resolvePhysical = resolvePhysicalFamily) => {
310327
310712
  const markerContainer = doc$12.createElement("span");
310328
310713
  markerContainer.classList.add(DOM_CLASS_NAMES.LIST_MARKER);
310329
310714
  markerContainer.style.display = "inline-block";
@@ -310332,7 +310717,8 @@ menclose::after {
310332
310717
  markerEl.classList.add("superdoc-paragraph-marker");
310333
310718
  markerEl.textContent = markerText;
310334
310719
  markerEl.style.pointerEvents = "none";
310335
- markerEl.style.fontFamily = toCssFontFamily(run2.fontFamily) ?? run2.fontFamily ?? "";
310720
+ const cssFontFamily = toCssFontFamily(run2.fontFamily) ?? run2.fontFamily ?? "";
310721
+ markerEl.style.fontFamily = resolvePhysical(cssFontFamily);
310336
310722
  if (run2.fontSize != null)
310337
310723
  markerEl.style.fontSize = `${run2.fontSize}px`;
310338
310724
  markerEl.style.fontWeight = run2.bold ? "bold" : "";
@@ -310350,7 +310736,7 @@ menclose::after {
310350
310736
  applySourceAnchorDataset(markerEl, sourceAnchor);
310351
310737
  return markerContainer;
310352
310738
  }, renderLegacyListMarker = (params$1) => {
310353
- const { doc: doc$12, lineEl, wordLayout, markerLayout, markerMeasure, markerTextWidthPx, indentLeftPx, hangingIndentPx, firstLineIndentPx, isRtl, sourceAnchor } = params$1;
310739
+ const { doc: doc$12, lineEl, wordLayout, markerLayout, markerMeasure, markerTextWidthPx, indentLeftPx, hangingIndentPx, firstLineIndentPx, isRtl, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
310354
310740
  const markerTextWidth = markerTextWidthPx ?? markerMeasure?.markerTextWidth ?? 0;
310355
310741
  const markerGeometry = markerLayout?.justification === "left" && wordLayout?.firstLineIndentMode !== true && typeof markerTextWidth === "number" && Number.isFinite(markerTextWidth) && markerTextWidth >= 0 ? resolvePainterListMarkerGeometry({
310356
310742
  wordLayout,
@@ -310387,7 +310773,7 @@ menclose::after {
310387
310773
  lineEl.style.paddingLeft = `${anchorPoint}px`;
310388
310774
  if (markerLayout?.run?.vanish)
310389
310775
  return;
310390
- const markerContainer = createListMarkerElement(doc$12, markerLayout?.markerText ?? "", markerLayout?.run ?? {}, sourceAnchor);
310776
+ const markerContainer = createListMarkerElement(doc$12, markerLayout?.markerText ?? "", markerLayout?.run ?? {}, sourceAnchor, resolvePhysical);
310391
310777
  markerContainer.style.position = "relative";
310392
310778
  if (markerJustification === "right") {
310393
310779
  markerContainer.style.position = "absolute";
@@ -310408,14 +310794,14 @@ menclose::after {
310408
310794
  prependMarkerSuffix(doc$12, lineEl, isMarkerSuffix(suffix) ? suffix : undefined, suffixWidthPx, markerLayout?.run?.fontSize);
310409
310795
  lineEl.prepend(markerContainer);
310410
310796
  }, renderResolvedListMarker = (params$1) => {
310411
- const { doc: doc$12, lineEl, marker, isRtl, sourceAnchor } = params$1;
310797
+ const { doc: doc$12, lineEl, marker, isRtl, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
310412
310798
  if (isRtl)
310413
310799
  lineEl.style.paddingRight = `${marker.firstLinePaddingLeftPx}px`;
310414
310800
  else
310415
310801
  lineEl.style.paddingLeft = `${marker.firstLinePaddingLeftPx}px`;
310416
310802
  if (marker.vanish)
310417
310803
  return;
310418
- const markerContainer = createListMarkerElement(doc$12, marker.text, marker.run, marker.sourceAnchor ?? sourceAnchor);
310804
+ const markerContainer = createListMarkerElement(doc$12, marker.text, marker.run, marker.sourceAnchor ?? sourceAnchor, resolvePhysical);
310419
310805
  markerContainer.style.position = "relative";
310420
310806
  if (marker.justification === "right") {
310421
310807
  markerContainer.style.position = "absolute";
@@ -310683,7 +311069,7 @@ menclose::after {
310683
311069
  skipJustifyOverride: (resolvedLine?.skipJustify ?? false) || hasMultipleExplicitPositionedSegments
310684
311070
  }) ? Math.max(lineWidth, availableWidth) : lineWidth;
310685
311071
  }, renderResolvedLines = (params$1) => {
310686
- const { frameEl, block, resolvedContent: content3, markerTextWidth, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor } = params$1;
311072
+ const { frameEl, block, resolvedContent: content3, markerTextWidth, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
310687
311073
  const renderedLines = [];
310688
311074
  const resolvedMarker = content3.marker;
310689
311075
  const expandedRunsForBlock = expandRunsForInlineNewlines(block.runs);
@@ -310713,7 +311099,8 @@ menclose::after {
310713
311099
  lineEl,
310714
311100
  marker: resolvedMarker,
310715
311101
  isRtl,
310716
- sourceAnchor
311102
+ sourceAnchor,
311103
+ resolvePhysical
310717
311104
  });
310718
311105
  if (convertFinalParagraphMark && index2 === content3.lines.length - 1 && !content3.continuesOnNext)
310719
311106
  convertParagraphMarkToCellMark(lineEl);
@@ -310736,7 +311123,7 @@ menclose::after {
310736
311123
  renderedLines
310737
311124
  };
310738
311125
  }, renderMeasuredLines = (params$1) => {
310739
- const { doc: doc$12, frameEl, block, measure, containerKind, width, localStartLine, localEndLine, linesOverride, lineIndexOffset = 0, continuesFromPrev, continuesOnNext, markerWidth, markerTextWidth, wordLayout, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor } = params$1;
311126
+ const { doc: doc$12, frameEl, block, measure, containerKind, width, localStartLine, localEndLine, linesOverride, lineIndexOffset = 0, continuesFromPrev, continuesOnNext, markerWidth, markerTextWidth, wordLayout, renderLine: renderLine$1, captureLineSnapshot, convertFinalParagraphMark, lineTopOffset = 0, sourceAnchor, resolvePhysical = resolvePhysicalFamily } = params$1;
310740
311127
  const lines = linesOverride ?? measure.lines ?? [];
310741
311128
  const paraIndent = block.attrs?.indent;
310742
311129
  const paraIndentLeft = paraIndent?.left ?? 0;
@@ -310810,7 +311197,8 @@ menclose::after {
310810
311197
  hangingIndentPx: markerHanging,
310811
311198
  firstLineIndentPx: markerFirstLine,
310812
311199
  isRtl,
310813
- sourceAnchor
311200
+ sourceAnchor,
311201
+ resolvePhysical
310814
311202
  });
310815
311203
  } else
310816
311204
  applyParagraphLineIndentation({
@@ -310964,7 +311352,7 @@ menclose::after {
310964
311352
  hasSdtContainerChrome
310965
311353
  };
310966
311354
  }, renderTableCell = (deps) => {
310967
- const { doc: doc$12, x, y: y$1, rowHeight, cellMeasure, cell: cell2, borders, useDefaultBorder, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, context, applySdtDataset: applySdtDataset$1, chrome: chrome2, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, tableIndent, isRtl, cellWidth, fromLine, toLine } = deps;
311355
+ const { doc: doc$12, x, y: y$1, rowHeight, cellMeasure, cell: cell2, borders, useDefaultBorder, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, context, applySdtDataset: applySdtDataset$1, chrome: chrome2, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, tableIndent, isRtl, cellWidth, fromLine, toLine, resolvePhysical } = deps;
310968
311356
  const padding = cell2?.attrs?.padding || {
310969
311357
  top: 0,
310970
311358
  left: 4,
@@ -311216,6 +311604,7 @@ menclose::after {
311216
311604
  },
311217
311605
  contentControlsChrome: chrome2,
311218
311606
  applySdtDataset: applySdtDataset$1,
311607
+ resolvePhysical,
311219
311608
  renderLine: ({ block: block$1, line, lineIndex, isLastLine, resolvedListTextStartPx }) => renderLine$1(block$1, line, {
311220
311609
  ...context,
311221
311610
  section: "body"
@@ -311392,7 +311781,7 @@ menclose::after {
311392
311781
  left: baseBorders.left
311393
311782
  };
311394
311783
  }, renderTableRow = (deps) => {
311395
- const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2 } = deps;
311784
+ const { doc: doc$12, container, rowIndex, y: y$1, rowMeasure, row: row2, totalRows, tableBorders, columnWidths, allRowHeights, tableIndent, isRtl, context, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applySdtDataset: applySdtDataset$1, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, continuesFromPrev, continuesOnNext, partialRow, cellSpacingPx = 0, chrome: chrome2, resolvePhysical } = deps;
311396
311785
  const totalCols = columnWidths.length;
311397
311786
  const calculateXPosition = (gridColumnStart) => {
311398
311787
  let x = cellSpacingPx;
@@ -311479,12 +311868,13 @@ menclose::after {
311479
311868
  tableIndent,
311480
311869
  isRtl,
311481
311870
  cellWidth: computedCellWidth > 0 ? computedCellWidth : undefined,
311482
- chrome: chrome2
311871
+ chrome: chrome2,
311872
+ resolvePhysical
311483
311873
  });
311484
311874
  container.appendChild(cellElement);
311485
311875
  }
311486
311876
  }, renderTableFragment = (deps) => {
311487
- const { doc: doc$12, fragment: fragment2, block, measure, cellSpacingPx, effectiveColumnWidths, chrome: chrome2, context, sdtBoundary, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, applyStyles: applyStyles$3 } = deps;
311877
+ const { doc: doc$12, fragment: fragment2, block, measure, cellSpacingPx, effectiveColumnWidths, chrome: chrome2, context, sdtBoundary, ancestorContainerKey, ancestorContainerSdt, ancestorContainerKeys, ancestorContainerSdts, onSdtContainerChrome, renderLine: renderLine$1, captureLineSnapshot, renderDrawingContent, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, applyStyles: applyStyles$3, resolvePhysical } = deps;
311488
311878
  if (!doc$12) {
311489
311879
  console.error("DomPainter: document is not available");
311490
311880
  if (typeof document !== "undefined") {
@@ -311666,7 +312056,8 @@ menclose::after {
311666
312056
  chrome: chrome2,
311667
312057
  continuesFromPrev: false,
311668
312058
  continuesOnNext: false,
311669
- cellSpacingPx
312059
+ cellSpacingPx,
312060
+ resolvePhysical
311670
312061
  });
311671
312062
  y$1 += rowMeasure.height + cellSpacingPx;
311672
312063
  }
@@ -311784,7 +312175,8 @@ menclose::after {
311784
312175
  continuesFromPrev: isFirstRenderedBodyRow && fragment2.continuesFromPrev === true,
311785
312176
  continuesOnNext: isLastRenderedBodyRow && fragment2.continuesOnNext === true,
311786
312177
  partialRow: partialRowData,
311787
- cellSpacingPx
312178
+ cellSpacingPx,
312179
+ resolvePhysical
311788
312180
  });
311789
312181
  y$1 += actualRowHeight + cellSpacingPx;
311790
312182
  }
@@ -312002,7 +312394,7 @@ menclose::after {
312002
312394
  else
312003
312395
  delete el.dataset.continuesOnNext;
312004
312396
  }, isMinimalWordLayout$2 = (value) => isMinimalWordLayout(value), renderParagraphFragment = (params$1) => {
312005
- const { doc: doc$12, fragment: fragment2, sdtBoundary, betweenInfo, resolvedItem, applyStyles: applyStyles$3, applyResolvedFragmentFrame, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, renderLine: renderLine$1, captureLineSnapshot, createErrorPlaceholder, contentControlsChrome } = params$1;
312397
+ const { doc: doc$12, fragment: fragment2, sdtBoundary, betweenInfo, resolvedItem, applyStyles: applyStyles$3, applyResolvedFragmentFrame, applyFragmentFrame, applySdtDataset: applySdtDataset$1, applyContainerSdtDataset: applyContainerSdtDataset$1, renderLine: renderLine$1, captureLineSnapshot, createErrorPlaceholder, contentControlsChrome, resolvePhysical = resolvePhysicalFamily } = params$1;
312006
312398
  try {
312007
312399
  if (!doc$12)
312008
312400
  throw new Error("DomPainter: document is not available");
@@ -312061,7 +312453,8 @@ menclose::after {
312061
312453
  sdtBoundary,
312062
312454
  applySdtDataset: applySdtDataset$1,
312063
312455
  applyContainerSdtDataset: applyContainerSdtDataset$1,
312064
- renderDropCap: (descriptor, dropCapMeasure) => renderDropCap(doc$12, descriptor, dropCapMeasure),
312456
+ resolvePhysical,
312457
+ renderDropCap: (descriptor, dropCapMeasure) => renderDropCap(doc$12, descriptor, dropCapMeasure, resolvePhysical),
312065
312458
  renderLine: renderLine$1,
312066
312459
  captureLineSnapshot: (lineEl, options) => {
312067
312460
  captureLineSnapshot(lineEl, {
@@ -312080,12 +312473,12 @@ menclose::after {
312080
312473
  });
312081
312474
  return createErrorPlaceholder(fragment2.blockId, error3);
312082
312475
  }
312083
- }, renderDropCap = (doc$12, descriptor, measure) => {
312476
+ }, renderDropCap = (doc$12, descriptor, measure, resolvePhysical = resolvePhysicalFamily) => {
312084
312477
  const { run: run2, mode } = descriptor;
312085
312478
  const dropCapEl = doc$12.createElement("span");
312086
312479
  dropCapEl.classList.add("superdoc-drop-cap");
312087
312480
  dropCapEl.textContent = run2.text;
312088
- dropCapEl.style.fontFamily = run2.fontFamily;
312481
+ dropCapEl.style.fontFamily = resolvePhysical(run2.fontFamily);
312089
312482
  dropCapEl.style.fontSize = `${run2.fontSize}px`;
312090
312483
  if (run2.bold)
312091
312484
  dropCapEl.style.fontWeight = "bold";
@@ -312178,263 +312571,7 @@ menclose::after {
312178
312571
  const visualTextEndOffset = lineEl.dir === "rtl" || lineEl.style.direction === "rtl" ? alignmentOffset : alignmentOffset + lineWidth;
312179
312572
  mark2.style.left = `${Math.max(0, leftOffsetPx + visualTextEndOffset)}px`;
312180
312573
  lineEl.appendChild(mark2);
312181
- }, SETTLED_STATUSES, BUNDLED_SUBSTITUTES, fontConfigVersion = 0, BUNDLED_MANIFEST, defaultAssetBase = "/fonts/", installedRegistries, DEFAULT_FONT_LOAD_TIMEOUT_MS = 3000, DEFAULT_PROBE_SIZE = "16px", FontRegistry = class {
312182
- #fontSet;
312183
- #FontFaceCtor;
312184
- #probeSize;
312185
- #scheduleTimeout;
312186
- #cancelTimeout;
312187
- #managed = /* @__PURE__ */ new Map;
312188
- #status = /* @__PURE__ */ new Map;
312189
- #sources = /* @__PURE__ */ new Map;
312190
- #warnedFailures = /* @__PURE__ */ new Set;
312191
- #inflight = /* @__PURE__ */ new Map;
312192
- #faceStatus = /* @__PURE__ */ new Map;
312193
- #faceInflight = /* @__PURE__ */ new Map;
312194
- #faceSources = /* @__PURE__ */ new Map;
312195
- #facesByFamily = /* @__PURE__ */ new Map;
312196
- #warnedFaceFailures = /* @__PURE__ */ new Set;
312197
- constructor(options = {}) {
312198
- this.#fontSet = options.fontSet ?? null;
312199
- this.#FontFaceCtor = options.FontFaceCtor ?? null;
312200
- this.#probeSize = options.probeSize ?? DEFAULT_PROBE_SIZE;
312201
- this.#scheduleTimeout = options.scheduleTimeout ?? ((cb, ms) => globalThis.setTimeout(cb, ms));
312202
- this.#cancelTimeout = options.cancelTimeout ?? ((handle3) => globalThis.clearTimeout(handle3));
312203
- }
312204
- register(descriptor) {
312205
- const { family: family$1, source, descriptors: descriptors2 } = descriptor;
312206
- if (this.#FontFaceCtor && this.#fontSet) {
312207
- const face = new this.#FontFaceCtor(family$1, source, descriptors2);
312208
- this.#fontSet.add(face);
312209
- this.#managed.set(family$1, face);
312210
- }
312211
- if (typeof source === "string") {
312212
- const list5 = this.#sources.get(family$1) ?? [];
312213
- if (!list5.includes(source))
312214
- list5.push(source);
312215
- this.#sources.set(family$1, list5);
312216
- }
312217
- if (!this.#status.has(family$1))
312218
- this.#status.set(family$1, "unloaded");
312219
- const key2 = faceKeyOf$1(family$1, normalizeWeight(descriptors2?.weight), normalizeStyle$1(descriptors2?.style));
312220
- this.#trackFace(family$1, key2);
312221
- if (!this.#faceStatus.has(key2))
312222
- this.#faceStatus.set(key2, "unloaded");
312223
- if (typeof source === "string" && !this.#faceSources.has(key2))
312224
- this.#faceSources.set(key2, source);
312225
- return {
312226
- family: family$1,
312227
- status: this.getStatus(family$1)
312228
- };
312229
- }
312230
- #trackFace(family$1, key2) {
312231
- const fam = normalizeFamilyKey$1(family$1);
312232
- const set = this.#facesByFamily.get(fam) ?? /* @__PURE__ */ new Set;
312233
- set.add(key2);
312234
- this.#facesByFamily.set(fam, set);
312235
- }
312236
- isManaged(family$1) {
312237
- return this.#managed.has(family$1);
312238
- }
312239
- getStatus(family$1) {
312240
- const statuses = [];
312241
- const faceKeys = this.#facesByFamily.get(normalizeFamilyKey$1(family$1));
312242
- if (faceKeys)
312243
- for (const k$1 of faceKeys)
312244
- statuses.push(this.#faceStatus.get(k$1) ?? "unloaded");
312245
- const legacy = this.#status.get(family$1);
312246
- if (legacy)
312247
- statuses.push(legacy);
312248
- if (statuses.length === 0)
312249
- return "unloaded";
312250
- for (const s2 of [
312251
- "failed",
312252
- "timed_out",
312253
- "fallback_used",
312254
- "loaded",
312255
- "loading",
312256
- "unloaded"
312257
- ])
312258
- if (statuses.includes(s2))
312259
- return s2;
312260
- return "unloaded";
312261
- }
312262
- isAvailable(family$1) {
312263
- if (!this.#fontSet)
312264
- return false;
312265
- try {
312266
- return this.#fontSet.check(`${this.#probeSize} ${quoteFamily(family$1)}`);
312267
- } catch {
312268
- return false;
312269
- }
312270
- }
312271
- awaitFace(family$1, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
312272
- if (this.#status.get(family$1) === "loaded")
312273
- return Promise.resolve({
312274
- family: family$1,
312275
- status: "loaded"
312276
- });
312277
- const existing = this.#inflight.get(family$1);
312278
- if (existing)
312279
- return existing;
312280
- const probe = this.#loadOne(family$1, timeoutMs).finally(() => {
312281
- this.#inflight.delete(family$1);
312282
- });
312283
- this.#inflight.set(family$1, probe);
312284
- return probe;
312285
- }
312286
- async awaitFaces(families, options = {}) {
312287
- const unique$2 = [...new Set(families)];
312288
- const timeoutMs = options.timeoutMs ?? 3000;
312289
- return Promise.all(unique$2.map((family$1) => this.awaitFace(family$1, timeoutMs)));
312290
- }
312291
- getRequiredFaces(families, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
312292
- return [...new Set(families)].map((family$1) => ({
312293
- family: family$1,
312294
- status: this.getStatus(family$1),
312295
- ready: this.awaitFace(family$1, timeoutMs)
312296
- }));
312297
- }
312298
- getStates() {
312299
- return [...this.#status.entries()].map(([family$1, status]) => ({
312300
- family: family$1,
312301
- status
312302
- }));
312303
- }
312304
- getFaceStatus(request) {
312305
- return this.#faceStatus.get(faceKeyOf$1(request.family, request.weight, request.style)) ?? "unloaded";
312306
- }
312307
- awaitFaceRequest(request, timeoutMs = DEFAULT_FONT_LOAD_TIMEOUT_MS) {
312308
- const key2 = faceKeyOf$1(request.family, request.weight, request.style);
312309
- if (this.#faceStatus.get(key2) === "loaded")
312310
- return Promise.resolve({
312311
- request,
312312
- status: "loaded"
312313
- });
312314
- const existing = this.#faceInflight.get(key2);
312315
- if (existing)
312316
- return existing;
312317
- const probe = this.#loadOneFace(request, key2, timeoutMs).finally(() => {
312318
- this.#faceInflight.delete(key2);
312319
- });
312320
- this.#faceInflight.set(key2, probe);
312321
- return probe;
312322
- }
312323
- async awaitFaceRequests(requests, options = {}) {
312324
- const timeoutMs = options.timeoutMs ?? 3000;
312325
- const seen = /* @__PURE__ */ new Set;
312326
- const unique$2 = [];
312327
- for (const r$1 of requests) {
312328
- const key2 = faceKeyOf$1(r$1.family, r$1.weight, r$1.style);
312329
- if (seen.has(key2))
312330
- continue;
312331
- seen.add(key2);
312332
- unique$2.push(r$1);
312333
- }
312334
- return Promise.all(unique$2.map((r$1) => this.awaitFaceRequest(r$1, timeoutMs)));
312335
- }
312336
- async#loadOneFace(request, key2, timeoutMs) {
312337
- this.#trackFace(request.family, key2);
312338
- const fontSet = this.#fontSet;
312339
- if (!fontSet) {
312340
- this.#faceStatus.set(key2, "fallback_used");
312341
- return {
312342
- request,
312343
- status: "fallback_used"
312344
- };
312345
- }
312346
- this.#faceStatus.set(key2, "loading");
312347
- const probe = faceProbe(request.family, request.weight, request.style, this.#probeSize);
312348
- const TIMEOUT = Symbol("timeout");
312349
- let handle3;
312350
- const timeout$1 = new Promise((resolve3) => {
312351
- handle3 = this.#scheduleTimeout(() => resolve3(TIMEOUT), timeoutMs);
312352
- });
312353
- try {
312354
- const settled = await Promise.race([fontSet.load(probe), timeout$1]);
312355
- if (settled === TIMEOUT) {
312356
- this.#faceStatus.set(key2, "timed_out");
312357
- return {
312358
- request,
312359
- status: "timed_out"
312360
- };
312361
- }
312362
- const status = settled.length > 0 ? "loaded" : "fallback_used";
312363
- this.#faceStatus.set(key2, status);
312364
- return {
312365
- request,
312366
- status
312367
- };
312368
- } catch {
312369
- this.#faceStatus.set(key2, "failed");
312370
- this.#warnFaceFailureOnce(request, key2);
312371
- return {
312372
- request,
312373
- status: "failed"
312374
- };
312375
- } finally {
312376
- this.#cancelTimeout(handle3);
312377
- }
312378
- }
312379
- #warnFaceFailureOnce(request, key2) {
312380
- if (this.#warnedFaceFailures.has(key2))
312381
- return;
312382
- this.#warnedFaceFailures.add(key2);
312383
- const src = this.#faceSources.get(key2);
312384
- const detail = src ? ` from ${src}` : "";
312385
- console.warn(`[superdoc] font face failed to load: "${request.family}" ${request.weight} ${request.style}${detail}. Check fonts.assetBaseUrl / fonts.resolveAssetUrl so the bundled .woff2 are served.`);
312386
- }
312387
- async#loadOne(family$1, timeoutMs) {
312388
- const fontSet = this.#fontSet;
312389
- if (!fontSet) {
312390
- this.#status.set(family$1, "fallback_used");
312391
- return {
312392
- family: family$1,
312393
- status: "fallback_used"
312394
- };
312395
- }
312396
- this.#status.set(family$1, "loading");
312397
- const probe = `${this.#probeSize} ${quoteFamily(family$1)}`;
312398
- const TIMEOUT = Symbol("timeout");
312399
- let handle3;
312400
- const timeout$1 = new Promise((resolve3) => {
312401
- handle3 = this.#scheduleTimeout(() => resolve3(TIMEOUT), timeoutMs);
312402
- });
312403
- try {
312404
- const settled = await Promise.race([fontSet.load(probe), timeout$1]);
312405
- if (settled === TIMEOUT) {
312406
- this.#status.set(family$1, "timed_out");
312407
- return {
312408
- family: family$1,
312409
- status: "timed_out"
312410
- };
312411
- }
312412
- const status = settled.length > 0 ? "loaded" : "fallback_used";
312413
- this.#status.set(family$1, status);
312414
- return {
312415
- family: family$1,
312416
- status
312417
- };
312418
- } catch {
312419
- this.#status.set(family$1, "failed");
312420
- this.#warnLoadFailureOnce(family$1);
312421
- return {
312422
- family: family$1,
312423
- status: "failed"
312424
- };
312425
- } finally {
312426
- this.#cancelTimeout(handle3);
312427
- }
312428
- }
312429
- #warnLoadFailureOnce(family$1) {
312430
- if (this.#warnedFailures.has(family$1))
312431
- return;
312432
- this.#warnedFailures.add(family$1);
312433
- const sources = this.#sources.get(family$1);
312434
- const detail = sources && sources.length ? ` from ${sources.join(", ")}` : "";
312435
- console.warn(`[superdoc] font asset failed to load for "${family$1}"${detail}. Check fonts.assetBaseUrl / fonts.resolveAssetUrl so the bundled .woff2 are served.`);
312436
- }
312437
- }, registriesByFontSet, domlessRegistry = null, DEFAULT_SUPERSCRIPT_RAISE_RATIO = 0.33, DEFAULT_SUBSCRIPT_LOWER_RATIO = 0.14, underlineThicknessPx = (fontSize) => Math.max(1, Math.round(fontSize / 14)), hasVerticalPositioning = (run2) => normalizeBaselineShift(run2.baselineShift) != null || run2.vertAlign === "superscript" || run2.vertAlign === "subscript", applyRunVerticalPositioning = (element3, run2) => {
312574
+ }, DEFAULT_SUPERSCRIPT_RAISE_RATIO = 0.33, DEFAULT_SUBSCRIPT_LOWER_RATIO = 0.14, underlineThicknessPx = (fontSize) => Math.max(1, Math.round(fontSize / 14)), hasVerticalPositioning = (run2) => normalizeBaselineShift(run2.baselineShift) != null || run2.vertAlign === "superscript" || run2.vertAlign === "subscript", applyRunVerticalPositioning = (element3, run2) => {
312438
312575
  if (hasVerticalPositioning(run2))
312439
312576
  element3.style.lineHeight = "1";
312440
312577
  const explicitBaselineShift = normalizeBaselineShift(run2.baselineShift);
@@ -312454,10 +312591,10 @@ menclose::after {
312454
312591
  }
312455
312592
  if (run2.vertAlign === "baseline")
312456
312593
  element3.style.verticalAlign = "baseline";
312457
- }, applyRunStyles = (element3, run2, _isLink = false) => {
312594
+ }, applyRunStyles = (element3, run2, _isLink = false, resolvePhysical = resolvePhysicalFamily) => {
312458
312595
  if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || run2.kind === "math")
312459
312596
  return;
312460
- element3.style.fontFamily = resolvePhysicalFamily(run2.fontFamily);
312597
+ element3.style.fontFamily = resolvePhysical(run2.fontFamily);
312461
312598
  element3.style.fontSize = `${run2.fontSize}px`;
312462
312599
  if (run2.bold)
312463
312600
  element3.style.fontWeight = "bold";
@@ -312558,7 +312695,7 @@ menclose::after {
312558
312695
  if (linkData.tooltip)
312559
312696
  renderContext.pendingTooltips.set(elem, linkData.tooltip);
312560
312697
  }
312561
- applyRunStyles(elem, run2, isActiveLink);
312698
+ applyRunStyles(elem, run2, isActiveLink, renderContext.resolvePhysical);
312562
312699
  const dirAttr = resolveRunDirectionAttribute({
312563
312700
  runText: run2.text,
312564
312701
  effectiveText,
@@ -312638,8 +312775,10 @@ menclose::after {
312638
312775
  annotation.style.height = `${run2.size.height}px`;
312639
312776
  }
312640
312777
  }
312641
- if (run2.fontFamily)
312642
- annotation.style.fontFamily = run2.fontFamily;
312778
+ {
312779
+ const resolvePhysical = context.resolvePhysical ?? resolvePhysicalFamily;
312780
+ annotation.style.fontFamily = resolvePhysical(run2.fontFamily || "Arial, sans-serif");
312781
+ }
312643
312782
  {
312644
312783
  const fontSize = run2.fontSize ? typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize : BROWSER_DEFAULT_FONT_SIZE;
312645
312784
  annotation.style.fontSize = fontSize;
@@ -313242,7 +313381,7 @@ menclose::after {
313242
313381
  if (run2.pmEnd != null)
313243
313382
  elem.dataset.pmEnd = String(run2.pmEnd);
313244
313383
  renderContext.applySdtDataset(elem, run2.sdt);
313245
- applyRunStyles(elem, run2);
313384
+ applyRunStyles(elem, run2, false, renderContext.resolvePhysical);
313246
313385
  return elem;
313247
313386
  }, renderRun = (run2, context, renderContext, trackedConfig) => {
313248
313387
  if (isImageRun$1(run2))
@@ -315350,6 +315489,7 @@ menclose::after {
315350
315489
  applyFragmentFrame: (el, paraFragment) => this.applyFragmentFrame(el, paraFragment, context.section, context.story),
315351
315490
  applySdtDataset,
315352
315491
  applyContainerSdtDataset,
315492
+ resolvePhysical: this.options.resolvePhysical,
315353
315493
  renderLine: ({ block, line, availableWidth, lineIndex, skipJustify, preExpandedRuns, resolvedListTextStartPx, indentOffsetOverride, paragraphMarkLeftOffsetOverride }) => this.renderLine(block, line, context, availableWidth, lineIndex, skipJustify, preExpandedRuns, resolvedListTextStartPx, indentOffsetOverride, paragraphMarkLeftOffsetOverride),
315354
315494
  captureLineSnapshot: (lineEl, options) => {
315355
315495
  this.capturePaintSnapshotLine(lineEl, context, {
@@ -316122,7 +316262,8 @@ menclose::after {
316122
316262
  applyFragmentFrame: applyFragmentFrameWithSection,
316123
316263
  applySdtDataset,
316124
316264
  applyContainerSdtDataset,
316125
- applyStyles
316265
+ applyStyles,
316266
+ resolvePhysical: this.options.resolvePhysical
316126
316267
  });
316127
316268
  if (resolvedItem) {
316128
316269
  this.applyResolvedFragmentFrame(el, resolvedItem, fragment2, context.section, context.story);
@@ -316163,6 +316304,7 @@ menclose::after {
316163
316304
  layoutEpoch: this.layoutEpoch,
316164
316305
  showFormattingMarks: this.showFormattingMarks,
316165
316306
  contentControlsChrome: this.contentControlsChrome,
316307
+ resolvePhysical: this.options.resolvePhysical,
316166
316308
  pendingTooltips: this.pendingTooltips,
316167
316309
  getNextLinkId: () => `superdoc-link-${++this.linkIdCounter}`,
316168
316310
  applySdtDataset,
@@ -317850,10 +317992,10 @@ menclose::after {
317850
317992
  this.cache = /* @__PURE__ */ new Map;
317851
317993
  this.stats = createStats();
317852
317994
  }
317853
- get(block, width, height) {
317995
+ get(block, width, height, fontSignature = "") {
317854
317996
  if (!block || !block.id)
317855
317997
  return;
317856
- const key2 = this.composeKey(block, width, height);
317998
+ const key2 = this.composeKey(block, width, height, fontSignature);
317857
317999
  const value = this.cache.get(key2);
317858
318000
  if (value !== undefined) {
317859
318001
  this.stats.hits += 1;
@@ -317865,10 +318007,10 @@ menclose::after {
317865
318007
  return;
317866
318008
  }
317867
318009
  }
317868
- set(block, width, height, value) {
318010
+ set(block, width, height, value, fontSignature = "") {
317869
318011
  if (!block || !block.id)
317870
318012
  return;
317871
- const key2 = this.composeKey(block, width, height);
318013
+ const key2 = this.composeKey(block, width, height, fontSignature);
317872
318014
  if (this.cache.has(key2))
317873
318015
  this.cache.delete(key2);
317874
318016
  if (this.cache.size >= MAX_CACHE_SIZE$1) {
@@ -317922,11 +318064,11 @@ menclose::after {
317922
318064
  this.stats.size = this.cache.size;
317923
318065
  this.stats.memorySizeEstimate = this.cache.size * BYTES_PER_ENTRY_ESTIMATE;
317924
318066
  }
317925
- composeKey(block, width, height) {
318067
+ composeKey(block, width, height, fontSignature) {
317926
318068
  const safeWidth = Number.isFinite(width) ? Math.max(0, Math.min(Math.floor(width), MAX_DIMENSION)) : 0;
317927
318069
  const safeHeight = Number.isFinite(height) ? Math.max(0, Math.min(Math.floor(height), MAX_DIMENSION)) : 0;
317928
318070
  const hash$3 = hashRuns(block);
317929
- return `${block.id}@${safeWidth}x${safeHeight}:${hash$3}`;
318071
+ return `${block.id}@${safeWidth}x${safeHeight}:${hash$3}#${fontSignature}`;
317930
318072
  }
317931
318073
  }, FeatureFlags, PageTokenLogger, HeaderFooterCacheLogger, MetricsCollector = class {
317932
318074
  constructor() {
@@ -317983,10 +318125,10 @@ menclose::after {
317983
318125
  constructor() {
317984
318126
  this.cache = new MeasureCache;
317985
318127
  }
317986
- async measureBlocks(blocks2, constraints, measureBlock$1) {
318128
+ async measureBlocks(blocks2, constraints, measureBlock$1, fontSignature = "") {
317987
318129
  const measures = [];
317988
318130
  for (const block of blocks2) {
317989
- const cached = this.cache.get(block, constraints.width, constraints.height);
318131
+ const cached = this.cache.get(block, constraints.width, constraints.height, fontSignature);
317990
318132
  if (cached) {
317991
318133
  measures.push(cached);
317992
318134
  continue;
@@ -317995,7 +318137,7 @@ menclose::after {
317995
318137
  maxWidth: constraints.width,
317996
318138
  maxHeight: constraints.height
317997
318139
  });
317998
- this.cache.set(block, constraints.width, constraints.height, measurement);
318140
+ this.cache.set(block, constraints.width, constraints.height, measurement, fontSignature);
317999
318141
  measures.push(measurement);
318000
318142
  }
318001
318143
  return measures;
@@ -323597,14 +323739,14 @@ menclose::after {
323597
323739
  if (value === ",")
323598
323740
  return ",";
323599
323741
  return DEFAULT_DECIMAL_SEPARATOR2;
323600
- }, DROP_CAP_PADDING_PX = 4, measureDropCap = (ctx$1, descriptor, spacing) => {
323742
+ }, DROP_CAP_PADDING_PX = 4, measureDropCap = (ctx$1, descriptor, spacing, fontContext) => {
323601
323743
  const { run: run2, lines, mode } = descriptor;
323602
323744
  const { font } = buildFontString({
323603
323745
  fontFamily: run2.fontFamily,
323604
323746
  fontSize: run2.fontSize,
323605
323747
  bold: run2.bold,
323606
323748
  italic: run2.italic
323607
- });
323749
+ }, fontContext);
323608
323750
  ctx$1.font = font;
323609
323751
  const displayText = applyTextTransform(run2.text, run2);
323610
323752
  const metrics = ctx$1.measureText(displayText);
@@ -323760,7 +323902,7 @@ menclose::after {
323760
323902
  set headerLayoutResults(results) {
323761
323903
  this.#headerFooterLayoutSnapshotPending = true;
323762
323904
  this.#headerLayoutResults = results;
323763
- this.#resolvedHeaderLayouts = results ? results.map((result) => resolveResult(result)) : null;
323905
+ this.#resolvedHeaderLayouts = results ? results.map((result) => this.#resolveResult(result)) : null;
323764
323906
  }
323765
323907
  get footerLayoutResults() {
323766
323908
  return this.#footerLayoutResults;
@@ -323768,7 +323910,7 @@ menclose::after {
323768
323910
  set footerLayoutResults(results) {
323769
323911
  this.#headerFooterLayoutSnapshotPending = true;
323770
323912
  this.#footerLayoutResults = results;
323771
- this.#resolvedFooterLayouts = results ? results.map((result) => resolveResult(result)) : null;
323913
+ this.#resolvedFooterLayouts = results ? results.map((result) => this.#resolveResult(result)) : null;
323772
323914
  }
323773
323915
  get headerLayoutsByRId() {
323774
323916
  return this.#headerLayoutsByRId;
@@ -323843,8 +323985,8 @@ menclose::after {
323843
323985
  this.#headerFooterLayoutSnapshotPending = true;
323844
323986
  this.#headerLayoutResults = headerResults;
323845
323987
  this.#footerLayoutResults = footerResults;
323846
- this.#resolvedHeaderLayouts = headerResults ? headerResults.map((result) => resolveResult(result)) : null;
323847
- this.#resolvedFooterLayouts = footerResults ? footerResults.map((result) => resolveResult(result)) : null;
323988
+ this.#resolvedHeaderLayouts = headerResults ? headerResults.map((result) => this.#resolveResult(result)) : null;
323989
+ this.#resolvedFooterLayouts = footerResults ? footerResults.map((result) => this.#resolveResult(result)) : null;
323848
323990
  }
323849
323991
  initialize() {
323850
323992
  if (!this.#options.editor)
@@ -324564,17 +324706,20 @@ menclose::after {
324564
324706
  overflowBaseHeight
324565
324707
  };
324566
324708
  }
324567
- async layoutPerRId(headerFooterInput, layout, sectionMetadata) {
324709
+ #resolveResult(result, storyId) {
324710
+ return resolveResult(result, storyId, this.#options.getFontSignature?.() ?? "");
324711
+ }
324712
+ async layoutPerRId(headerFooterInput, layout, sectionMetadata, fontResolver) {
324568
324713
  await layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata, {
324569
324714
  headerLayoutsByRId: this.#headerLayoutsByRId,
324570
324715
  footerLayoutsByRId: this.#footerLayoutsByRId
324571
- });
324716
+ }, fontResolver);
324572
324717
  this.#resolvedHeaderByRId.clear();
324573
324718
  for (const [key2, result] of this.#headerLayoutsByRId)
324574
- this.#resolvedHeaderByRId.set(key2, resolveResult(result, storyIdFromHeaderFooterLayoutKey(key2)));
324719
+ this.#resolvedHeaderByRId.set(key2, this.#resolveResult(result, storyIdFromHeaderFooterLayoutKey(key2)));
324575
324720
  this.#resolvedFooterByRId.clear();
324576
324721
  for (const [key2, result] of this.#footerLayoutsByRId)
324577
- this.#resolvedFooterByRId.set(key2, resolveResult(result, storyIdFromHeaderFooterLayoutKey(key2)));
324722
+ this.#resolvedFooterByRId.set(key2, this.#resolveResult(result, storyIdFromHeaderFooterLayoutKey(key2)));
324578
324723
  }
324579
324724
  #computeMetrics(kind, layoutHeight, box, pageHeight, footerMargin) {
324580
324725
  const validatedLayoutHeight = Number.isFinite(layoutHeight) && layoutHeight >= 0 ? layoutHeight : 0;
@@ -324984,7 +325129,7 @@ menclose::after {
324984
325129
  return cachedItems;
324985
325130
  if (cachedItems)
324986
325131
  console.warn(`[HeaderFooterSessionManager] Resolved items length (${cachedItems.length}) does not match fragments length (${fragments.length}) for ${contextLabel}. Recomputing items.`);
324987
- const freshItems = resolveResult(result, storyId).pages.find((page) => page.number === slotPageNumber)?.items;
325132
+ const freshItems = this.#resolveResult(result, storyId).pages.find((page) => page.number === slotPageNumber)?.items;
324988
325133
  if (freshItems && freshItems.length === fragments.length)
324989
325134
  return freshItems;
324990
325135
  if (freshItems)
@@ -325427,6 +325572,7 @@ menclose::after {
325427
325572
  #getDocumentFonts;
325428
325573
  #getRequiredFaces;
325429
325574
  #resolveFamilies;
325575
+ #fontResolver;
325430
325576
  #requestReflow;
325431
325577
  #getFontEnvironment;
325432
325578
  #registryOverride;
@@ -325446,7 +325592,9 @@ menclose::after {
325446
325592
  constructor(options) {
325447
325593
  this.#getDocumentFonts = options.getDocumentFonts;
325448
325594
  this.#getRequiredFaces = options.getRequiredFaces ?? null;
325449
- this.#resolveFamilies = options.resolveFamilies ?? ((families) => families);
325595
+ this.#fontResolver = options.fontResolver ?? null;
325596
+ const resolver2 = this.#fontResolver;
325597
+ this.#resolveFamilies = options.resolveFamilies ?? (resolver2 ? (families) => resolver2.resolvePhysicalFamilies(families) : (families) => families);
325450
325598
  this.#requestReflow = options.requestReflow;
325451
325599
  this.#getFontEnvironment = options.getFontEnvironment ?? defaultFontEnvironment;
325452
325600
  this.#registryOverride = options.registry ?? null;
@@ -325474,7 +325622,7 @@ menclose::after {
325474
325622
  } catch {
325475
325623
  return [];
325476
325624
  }
325477
- return buildFontReport(logical, this.#resolveContext().registry);
325625
+ return buildFontReport(logical, this.#resolveContext().registry, this.#fontResolver ?? undefined);
325478
325626
  }
325479
325627
  async ensureReadyForMeasure() {
325480
325628
  if (this.#getRequiredFaces)
@@ -325539,14 +325687,22 @@ menclose::after {
325539
325687
  this.#lastSummary = summarize(results);
325540
325688
  return this.#lastSummary;
325541
325689
  }
325542
- notifyFontConfigChanged() {
325690
+ notifyDocumentFontConfigChanged(options) {
325543
325691
  this.#fontConfigVersion += 1;
325544
- bumpFontConfigVersion();
325545
325692
  this.#resetRequiredAndSeen();
325546
325693
  this.#lateLoadScheduler.cancel();
325547
- this.#invalidateCaches();
325694
+ if (options?.availabilityChanged) {
325695
+ bumpFontConfigVersion();
325696
+ this.#invalidateCaches();
325697
+ }
325548
325698
  this.#requestReflow();
325549
325699
  }
325700
+ invalidateCachesForConfigRegistration() {
325701
+ this.#invalidateCaches();
325702
+ }
325703
+ resolveRegistry() {
325704
+ return this.#resolveContext().registry;
325705
+ }
325550
325706
  resetForDocumentChange() {
325551
325707
  this.#lateLoadScheduler.cancel();
325552
325708
  this.#resetRequiredAndSeen();
@@ -325628,7 +325784,139 @@ menclose::after {
325628
325784
  #flushLateFontLoads() {
325629
325785
  this.#requestReflow();
325630
325786
  }
325631
- }, FACE_STATUS_PRIORITY, DEFAULT_SEMANTIC_FOOTNOTE_HEADING_STYLE, NATIVE_SELECTION_STYLES = `
325787
+ }, FACE_STATUS_PRIORITY, DocumentFontController = class {
325788
+ #resolver;
325789
+ #getGate;
325790
+ #onDocumentFontConfigApplied;
325791
+ #scheduleMicrotask;
325792
+ #runtimeReflowQueued = false;
325793
+ #runtimeReflowToken = 0;
325794
+ #runtimeAvailabilityChanged = false;
325795
+ constructor(deps) {
325796
+ this.#resolver = deps.resolver;
325797
+ this.#getGate = deps.getGate;
325798
+ this.#onDocumentFontConfigApplied = deps.onDocumentFontConfigApplied;
325799
+ this.#scheduleMicrotask = deps.scheduleMicrotask ?? defaultScheduleMicrotask;
325800
+ }
325801
+ map(mappings) {
325802
+ if (this.#applyMappings(mappings))
325803
+ this.#queueRuntimeReflow();
325804
+ }
325805
+ unmap(families) {
325806
+ const before2 = this.#resolver.signature;
325807
+ for (const family$1 of Array.isArray(families) ? families : [families])
325808
+ this.#resolver.unmap(family$1);
325809
+ this.#reflowIfChanged(before2);
325810
+ }
325811
+ reset() {
325812
+ this.#cancelPendingRuntimeReflow();
325813
+ this.#resolver.reset();
325814
+ }
325815
+ dispose() {
325816
+ this.#cancelPendingRuntimeReflow();
325817
+ }
325818
+ applyInitialConfig(config2) {
325819
+ this.#cancelPendingRuntimeReflow();
325820
+ if (!config2)
325821
+ return;
325822
+ const registered$1 = this.#registerFamilies(config2.families);
325823
+ this.#applyMappings(config2.map);
325824
+ if (registered$1)
325825
+ this.#getGate()?.invalidateCachesForConfigRegistration();
325826
+ }
325827
+ add(families) {
325828
+ let committed = false;
325829
+ try {
325830
+ this.#registerFamilies(families, () => {
325831
+ committed = true;
325832
+ });
325833
+ } finally {
325834
+ if (committed) {
325835
+ this.#runtimeAvailabilityChanged = true;
325836
+ this.#queueRuntimeReflow();
325837
+ }
325838
+ }
325839
+ }
325840
+ #registerFamilies(families, onFaceRegistered) {
325841
+ if (!families?.length)
325842
+ return false;
325843
+ const registry2 = this.#getGate()?.resolveRegistry();
325844
+ if (!registry2)
325845
+ throw new Error("[superdoc] fonts.add: the font registry is not ready yet");
325846
+ let changed = false;
325847
+ for (const entry of families) {
325848
+ const family$1 = entry?.family;
325849
+ const faces = entry?.faces;
325850
+ if (typeof family$1 !== "string" || !family$1.trim())
325851
+ throw new Error('[superdoc] fonts.add: each family needs a non-empty "family" name');
325852
+ if (!Array.isArray(faces) || faces.length === 0)
325853
+ throw new Error(`[superdoc] fonts.add: family "${family$1}" needs at least one face in "faces"`);
325854
+ for (const face of faces) {
325855
+ if (!face || typeof face.source !== "string" || !face.source.trim())
325856
+ throw new Error(`[superdoc] fonts.add: family "${family$1}" has a face with no "source" URL`);
325857
+ if (registry2.register({
325858
+ family: family$1,
325859
+ source: toCssFontSource(face.source),
325860
+ descriptors: {
325861
+ weight: face.weight == null ? undefined : String(face.weight),
325862
+ style: face.style
325863
+ }
325864
+ }).changed) {
325865
+ changed = true;
325866
+ onFaceRegistered?.();
325867
+ }
325868
+ }
325869
+ }
325870
+ return changed;
325871
+ }
325872
+ async preload(families) {
325873
+ if (!Array.isArray(families))
325874
+ throw new Error('[superdoc] fonts.preload expects an array of logical family names, e.g. preload(["Georgia"])');
325875
+ const registry2 = this.#getGate()?.resolveRegistry();
325876
+ if (!registry2)
325877
+ throw new Error("[superdoc] fonts.preload: the font registry is not ready yet");
325878
+ const requests = families.map((logical) => ({
325879
+ family: this.#resolver.resolvePrimaryPhysicalFamily(logical),
325880
+ weight: "400",
325881
+ style: "normal"
325882
+ }));
325883
+ await registry2.awaitFaceRequests(requests);
325884
+ }
325885
+ #reflowIfChanged(signatureBefore) {
325886
+ if (this.#resolver.signature !== signatureBefore)
325887
+ this.#queueRuntimeReflow();
325888
+ }
325889
+ #applyMappings(mappings) {
325890
+ if (!mappings)
325891
+ return false;
325892
+ const before2 = this.#resolver.signature;
325893
+ for (const [logicalFamily, physicalFamily] of Object.entries(mappings))
325894
+ this.#resolver.map(logicalFamily, physicalFamily);
325895
+ return this.#resolver.signature !== before2;
325896
+ }
325897
+ #queueRuntimeReflow() {
325898
+ if (this.#runtimeReflowQueued)
325899
+ return;
325900
+ this.#runtimeReflowQueued = true;
325901
+ const token$1 = ++this.#runtimeReflowToken;
325902
+ this.#scheduleMicrotask(() => {
325903
+ if (!this.#runtimeReflowQueued || token$1 !== this.#runtimeReflowToken)
325904
+ return;
325905
+ this.#runtimeReflowQueued = false;
325906
+ const availabilityChanged = this.#runtimeAvailabilityChanged;
325907
+ this.#runtimeAvailabilityChanged = false;
325908
+ this.#onDocumentFontConfigApplied();
325909
+ this.#getGate()?.notifyDocumentFontConfigChanged({ availabilityChanged });
325910
+ });
325911
+ }
325912
+ #cancelPendingRuntimeReflow() {
325913
+ this.#runtimeAvailabilityChanged = false;
325914
+ if (!this.#runtimeReflowQueued)
325915
+ return;
325916
+ this.#runtimeReflowQueued = false;
325917
+ this.#runtimeReflowToken += 1;
325918
+ }
325919
+ }, DEFAULT_SEMANTIC_FOOTNOTE_HEADING_STYLE, NATIVE_SELECTION_STYLES = `
325632
325920
  /* Hide native browser selection on layout engine content.
325633
325921
  * We render our own selection overlay via PresentationEditor's #localSelectionLayer
325634
325922
  * for precise control over selection geometry across pages and zoom levels. */
@@ -325705,7 +325993,7 @@ menclose::after {
325705
325993
  return;
325706
325994
  console.log(...args$1);
325707
325995
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions, TRACKED_MARK_NAMES;
325708
- var init_src_CEhzpYi5_es = __esm(() => {
325996
+ var init_src_B1aSE_tB_es = __esm(() => {
325709
325997
  init_rolldown_runtime_Bg48TavK_es();
325710
325998
  init_SuperConverter_B9mZiCO9_es();
325711
325999
  init_jszip_C49i9kUs_es();
@@ -352580,6 +352868,33 @@ function print() { __p += __j.call(arguments, '') }
352580
352868
  "wave",
352581
352869
  "doubleWave"
352582
352870
  ]);
352871
+ SETTLED_STATUSES = [
352872
+ "loaded",
352873
+ "failed",
352874
+ "timed_out",
352875
+ "fallback_used"
352876
+ ];
352877
+ BUNDLED_SUBSTITUTES = Object.freeze({
352878
+ calibri: "Carlito",
352879
+ cambria: "Caladea",
352880
+ arial: "Liberation Sans",
352881
+ "times new roman": "Liberation Serif",
352882
+ "courier new": "Liberation Mono"
352883
+ });
352884
+ defaultResolver = new FontResolver;
352885
+ DEFAULT_FONT_MEASURE_CONTEXT = Object.freeze({
352886
+ resolvePhysical: resolvePhysicalFamily,
352887
+ fontSignature: ""
352888
+ });
352889
+ BUNDLED_MANIFEST = Object.freeze([
352890
+ family("Carlito", "Carlito", "OFL-1.1"),
352891
+ family("Caladea", "Caladea", "Apache-2.0"),
352892
+ family("Liberation Sans", "LiberationSans", "OFL-1.1"),
352893
+ family("Liberation Serif", "LiberationSerif", "OFL-1.1"),
352894
+ family("Liberation Mono", "LiberationMono", "OFL-1.1")
352895
+ ]);
352896
+ installedRegistries = /* @__PURE__ */ new WeakMap;
352897
+ registriesByFontSet = /* @__PURE__ */ new WeakMap;
352583
352898
  PX_PER_PT$12 = 96 / 72;
352584
352899
  BORDER_SIDES3 = [
352585
352900
  "top",
@@ -352611,28 +352926,6 @@ function print() { __p += __j.call(arguments, '') }
352611
352926
  "sdtDocpartId",
352612
352927
  "sdtDocpartInstruction"
352613
352928
  ];
352614
- SETTLED_STATUSES = [
352615
- "loaded",
352616
- "failed",
352617
- "timed_out",
352618
- "fallback_used"
352619
- ];
352620
- BUNDLED_SUBSTITUTES = Object.freeze({
352621
- calibri: "Carlito",
352622
- cambria: "Caladea",
352623
- arial: "Liberation Sans",
352624
- "times new roman": "Liberation Serif",
352625
- "courier new": "Liberation Mono"
352626
- });
352627
- BUNDLED_MANIFEST = Object.freeze([
352628
- family("Carlito", "Carlito", "OFL-1.1"),
352629
- family("Caladea", "Caladea", "Apache-2.0"),
352630
- family("Liberation Sans", "LiberationSans", "OFL-1.1"),
352631
- family("Liberation Serif", "LiberationSerif", "OFL-1.1"),
352632
- family("Liberation Mono", "LiberationMono", "OFL-1.1")
352633
- ]);
352634
- installedRegistries = /* @__PURE__ */ new WeakMap;
352635
- registriesByFontSet = /* @__PURE__ */ new WeakMap;
352636
352929
  OPERATOR_CHARS = new Set([
352637
352930
  "+",
352638
352931
  "-",
@@ -353840,6 +354133,7 @@ function print() { __p += __j.call(arguments, '') }
353840
354133
  layout: null,
353841
354134
  bookmarks: /* @__PURE__ */ new Map
353842
354135
  };
354136
+ #layoutFontSignature = "";
353843
354137
  #layoutLookupBlocks = [];
353844
354138
  #layoutLookupMeasures = [];
353845
354139
  #flowBlockCache = new FlowBlockCache;
@@ -353863,6 +354157,15 @@ function print() { __p += __j.call(arguments, '') }
353863
354157
  #isRerendering = false;
353864
354158
  #selectionSync = new SelectionSyncCoordinator;
353865
354159
  #fontGate = null;
354160
+ #fontResolver = createFontResolver();
354161
+ #nextFontsChangedSource = null;
354162
+ #fontController = new DocumentFontController({
354163
+ resolver: this.#fontResolver,
354164
+ getGate: () => this.#fontGate,
354165
+ onDocumentFontConfigApplied: () => {
354166
+ this.#nextFontsChangedSource = "config-change";
354167
+ }
354168
+ });
353866
354169
  #fontPlanBlocks = null;
353867
354170
  #lastFontsChangedKey = null;
353868
354171
  #lastFontsChangedPayload = null;
@@ -354094,7 +354397,8 @@ function print() { __p += __j.call(arguments, '') }
354094
354397
  isDebug: this.#options.isDebug,
354095
354398
  initBudgetMs: HEADER_FOOTER_INIT_BUDGET_MS,
354096
354399
  defaultPageSize: DEFAULT_PAGE_SIZE,
354097
- defaultMargins: DEFAULT_MARGINS
354400
+ defaultMargins: DEFAULT_MARGINS,
354401
+ getFontSignature: () => this.#fontResolver.signature
354098
354402
  });
354099
354403
  this.#headerFooterSession.setHoverElements({
354100
354404
  hoverOverlay: this.#hoverOverlay,
@@ -354148,18 +354452,9 @@ function print() { __p += __j.call(arguments, '') }
354148
354452
  getDocumentFonts: () => {
354149
354453
  return this.#editor.converter?.getDocumentFonts?.() ?? [];
354150
354454
  },
354151
- requestReflow: () => {
354152
- this.#layoutState = {
354153
- ...this.#layoutState,
354154
- blocks: [],
354155
- measures: [],
354156
- layout: null
354157
- };
354158
- this.#pendingDocChange = true;
354159
- this.#scheduleRerender();
354160
- },
354161
- getRequiredFaces: () => planRequiredFontFaces(this.#fontPlanBlocks),
354162
- resolveFamilies: resolvePhysicalFamilies,
354455
+ requestReflow: () => this.#requestFontReflow(),
354456
+ getRequiredFaces: () => planRequiredFontFaces(this.#fontPlanBlocks, this.#fontResolver),
354457
+ fontResolver: this.#fontResolver,
354163
354458
  onRegistryResolved: (registry2) => installBundledSubstitutes(registry2, {
354164
354459
  assetBaseUrl: this.#options.fontAssets?.assetBaseUrl,
354165
354460
  resolveAssetUrl: this.#options.fontAssets?.resolveAssetUrl
@@ -354175,6 +354470,7 @@ function print() { __p += __j.call(arguments, '') }
354175
354470
  } : null;
354176
354471
  }
354177
354472
  });
354473
+ this.#fontController.applyInitialConfig(this.#options.fontAssets);
354178
354474
  if (typeof this.#options.disableContextMenu === "boolean")
354179
354475
  this.setContextMenuDisabled(this.#options.disableContextMenu);
354180
354476
  this.#setupHeaderFooterSession();
@@ -355134,6 +355430,28 @@ function print() { __p += __j.call(arguments, '') }
355134
355430
  getMissingFonts() {
355135
355431
  return this.getFontReport().filter((record) => record.missing).map((record) => record.logicalFamily);
355136
355432
  }
355433
+ mapFonts(mappings) {
355434
+ this.#fontController.map(mappings);
355435
+ }
355436
+ unmapFonts(families) {
355437
+ this.#fontController.unmap(families);
355438
+ }
355439
+ addFonts(families) {
355440
+ this.#fontController.add(families);
355441
+ }
355442
+ async preloadFonts(families) {
355443
+ await this.#fontController.preload(families);
355444
+ }
355445
+ #requestFontReflow() {
355446
+ this.#layoutState = {
355447
+ ...this.#layoutState,
355448
+ blocks: [],
355449
+ measures: [],
355450
+ layout: null
355451
+ };
355452
+ this.#pendingDocChange = true;
355453
+ this.#scheduleRerender();
355454
+ }
355137
355455
  #emitFontsChangedIfChanged(summary) {
355138
355456
  const gate = this.#fontGate;
355139
355457
  if (!gate)
@@ -355144,6 +355462,9 @@ function print() { __p += __j.call(arguments, '') }
355144
355462
  return;
355145
355463
  const isInitial = this.#lastFontsChangedKey === null;
355146
355464
  this.#lastFontsChangedKey = key2;
355465
+ const pendingSource = this.#nextFontsChangedSource;
355466
+ this.#nextFontsChangedSource = null;
355467
+ const source = isInitial ? "initial" : pendingSource ?? "late-load";
355147
355468
  let resolutions;
355148
355469
  try {
355149
355470
  resolutions = gate.getReport();
@@ -355161,7 +355482,7 @@ function print() { __p += __j.call(arguments, '') }
355161
355482
  fallbackUsed: 0,
355162
355483
  results: []
355163
355484
  },
355164
- source: isInitial ? "initial" : "late-load",
355485
+ source,
355165
355486
  version: version$1
355166
355487
  };
355167
355488
  this.#lastFontsChangedPayload = payload;
@@ -355172,6 +355493,11 @@ function print() { __p += __j.call(arguments, '') }
355172
355493
  getLastFontsChangedPayload() {
355173
355494
  return this.#lastFontsChangedPayload;
355174
355495
  }
355496
+ #resetFontReportStateForDocumentChange() {
355497
+ this.#nextFontsChangedSource = null;
355498
+ this.#lastFontsChangedKey = null;
355499
+ this.#lastFontsChangedPayload = null;
355500
+ }
355175
355501
  getLayoutOptions() {
355176
355502
  return { ...this.#layoutOptions };
355177
355503
  }
@@ -355319,7 +355645,8 @@ function print() { __p += __j.call(arguments, '') }
355319
355645
  layout,
355320
355646
  flowMode: this.#layoutOptions.flowMode ?? "paginated",
355321
355647
  blocks: blocks2,
355322
- measures
355648
+ measures,
355649
+ fontSignature: this.#fontResolver.signature
355323
355650
  });
355324
355651
  const isSemanticFlow = this.#layoutOptions.flowMode === "semantic";
355325
355652
  this.#ensurePainter();
@@ -356039,6 +356366,7 @@ function print() { __p += __j.call(arguments, '') }
356039
356366
  this.#postPaintPipeline.destroy();
356040
356367
  this.#proofingManager?.dispose();
356041
356368
  this.#proofingManager = null;
356369
+ this.#fontController.dispose();
356042
356370
  this.#fontGate?.dispose();
356043
356371
  this.#fontGate = null;
356044
356372
  if (this.#cursorUpdateTimer !== null) {
@@ -356399,6 +356727,10 @@ function print() { __p += __j.call(arguments, '') }
356399
356727
  });
356400
356728
  const handleDocumentReplaced = () => {
356401
356729
  this.#fontGate?.resetForDocumentChange();
356730
+ this.#fontController.reset();
356731
+ this.#layoutFontSignature = "";
356732
+ this.#fontController.applyInitialConfig(this.#options.fontAssets);
356733
+ this.#resetFontReportStateForDocumentChange();
356402
356734
  this.#refreshHeaderFooterStructureThenRerender({ purgeCachedEditors: true });
356403
356735
  };
356404
356736
  this.#editor.on("documentReplaced", handleDocumentReplaced);
@@ -357523,6 +357855,13 @@ function print() { __p += __j.call(arguments, '') }
357523
357855
  const previousBlocks = this.#layoutState.blocks;
357524
357856
  const previousLayout = this.#layoutState.layout;
357525
357857
  const previousMeasures = this.#layoutState.measures;
357858
+ const resolvePhysical = (css) => this.#fontResolver.resolvePhysicalFamily(css);
357859
+ const fontSignature = this.#fontResolver.signature;
357860
+ const previousFontSignature = this.#layoutFontSignature;
357861
+ const fontMeasureContext = {
357862
+ resolvePhysical,
357863
+ fontSignature
357864
+ };
357526
357865
  let layout;
357527
357866
  let measures;
357528
357867
  let resolvedLayout;
@@ -357546,7 +357885,10 @@ function print() { __p += __j.call(arguments, '') }
357546
357885
  } catch {}
357547
357886
  try {
357548
357887
  const incrementalLayoutStart = perfNow();
357549
- const result = await incrementalLayout(previousBlocks, previousLayout, blocksForLayout, layoutOptions, (block, constraints) => measureBlock(block, constraints), headerFooterInput ?? undefined, previousMeasures);
357888
+ const result = await incrementalLayout(previousBlocks, previousLayout, blocksForLayout, layoutOptions, (block, constraints) => measureBlock(block, constraints, fontMeasureContext), headerFooterInput ?? undefined, previousMeasures, {
357889
+ fontContext: fontMeasureContext,
357890
+ previousFontSignature
357891
+ });
357550
357892
  perfLog(`[Perf] incrementalLayout: ${(perfNow() - incrementalLayoutStart).toFixed(2)}ms`);
357551
357893
  if (!result || typeof result !== "object") {
357552
357894
  this.#handleLayoutError("render", /* @__PURE__ */ new Error("incrementalLayout returned invalid result"));
@@ -357573,7 +357915,8 @@ function print() { __p += __j.call(arguments, '') }
357573
357915
  layout,
357574
357916
  flowMode: this.#layoutOptions.flowMode ?? "paginated",
357575
357917
  blocks: bodyBlocksForPaint,
357576
- measures: bodyMeasuresForPaint
357918
+ measures: bodyMeasuresForPaint,
357919
+ fontSignature
357577
357920
  });
357578
357921
  headerLayouts = result.headers;
357579
357922
  footerLayouts = result.footers;
@@ -357597,6 +357940,7 @@ function print() { __p += __j.call(arguments, '') }
357597
357940
  bookmarks,
357598
357941
  anchorMap
357599
357942
  };
357943
+ this.#layoutFontSignature = fontSignature;
357600
357944
  this.#layoutLookupBlocks = resolveBlocks;
357601
357945
  this.#layoutLookupMeasures = resolveMeasures;
357602
357946
  const tocStorage = this.#editor.storage?.tableOfContents;
@@ -357694,7 +358038,8 @@ function print() { __p += __j.call(arguments, '') }
357694
358038
  ruler: this.#layoutOptions.ruler,
357695
358039
  pageGap: this.#layoutState.layout?.pageGap ?? effectiveGap,
357696
358040
  showFormattingMarks: this.#layoutOptions.showFormattingMarks ?? false,
357697
- contentControlsChrome: this.#layoutOptions.contentControlsChrome ?? "default"
358041
+ contentControlsChrome: this.#layoutOptions.contentControlsChrome ?? "default",
358042
+ resolvePhysical: (css) => this.#fontResolver.resolvePhysicalFamily(css)
357698
358043
  });
357699
358044
  const currentZoom = this.#layoutOptions.zoom ?? 1;
357700
358045
  if (currentZoom !== 1)
@@ -358446,7 +358791,7 @@ function print() { __p += __j.call(arguments, '') }
358446
358791
  }
358447
358792
  async#layoutPerRIdHeaderFooters(headerFooterInput, layout, sectionMetadata) {
358448
358793
  if (this.#headerFooterSession)
358449
- await this.#headerFooterSession.layoutPerRId(headerFooterInput, layout, sectionMetadata);
358794
+ await this.#headerFooterSession.layoutPerRId(headerFooterInput, layout, sectionMetadata, this.#fontResolver);
358450
358795
  }
358451
358796
  #updateDecorationProviders(resolvedLayout) {
358452
358797
  this.#headerFooterSession?.updateDecorationProviders(resolvedLayout);
@@ -360393,7 +360738,7 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
360393
360738
 
360394
360739
  // ../../packages/superdoc/dist/super-editor.es.js
360395
360740
  var init_super_editor_es = __esm(() => {
360396
- init_src_CEhzpYi5_es();
360741
+ init_src_B1aSE_tB_es();
360397
360742
  init_SuperConverter_B9mZiCO9_es();
360398
360743
  init_jszip_C49i9kUs_es();
360399
360744
  init_xml_js_CqGKpaft_es();