ooxml-ui 1.45.0 → 1.47.0

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 (89) hide show
  1. package/README.md +1 -1
  2. package/dist/chart/format-pane-effects.d.ts +0 -1
  3. package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
  4. package/dist/chart/format-pane-space.d.ts +0 -1
  5. package/dist/chart/format-pane-targets.d.ts +0 -1
  6. package/dist/chunk-G5CALQUW.js +278 -0
  7. package/dist/{chunk-LPI7LT4B.js → chunk-J3ROBM74.js} +1 -1
  8. package/dist/docx/backstage-options.d.ts +4 -0
  9. package/dist/docx/backstage-trust.d.ts +11 -0
  10. package/dist/docx/docx-webfonts.d.ts +75 -0
  11. package/dist/docx/editor-core.d.ts +3 -0
  12. package/dist/docx/element-api.d.ts +14 -0
  13. package/dist/docx/font-downloads.d.ts +8 -0
  14. package/dist/docx/locales/en.d.ts +6 -0
  15. package/dist/docx/locales/options.d.ts +6 -0
  16. package/dist/docx/locales/trust.d.ts +15 -0
  17. package/dist/docx/localization-strings.d.ts +6 -0
  18. package/dist/docx/print-layout-view.d.ts +2 -0
  19. package/dist/docx.js +229 -14
  20. package/dist/fonts/font-download-policy.d.ts +23 -0
  21. package/dist/fonts/webfonts.d.ts +118 -0
  22. package/dist/fonts/webfonts.d.ts.map +1 -0
  23. package/dist/form/color-swatches.d.ts +0 -1
  24. package/dist/index.js +2 -2
  25. package/dist/picture-artistic-filters.d.ts +0 -1
  26. package/dist/pptx/{chunk-CWBVJ4DC.cjs → chunk-6XIUBQPL.cjs} +403 -2398
  27. package/dist/pptx/{chunk-HGT3CA36.mjs → chunk-BV24XNBQ.mjs} +301 -2351
  28. package/dist/pptx/{chunk-MZCAYJ7H.cjs → chunk-JHI42PNB.cjs} +42 -42
  29. package/dist/pptx/{chunk-6JTQ7AG6.mjs → chunk-XMAQ23WE.mjs} +1 -1
  30. package/dist/pptx/dom/index.cjs +372 -371
  31. package/dist/pptx/dom/index.mjs +6 -5
  32. package/dist/pptx/dom/load-presentation.d.ts +8 -1
  33. package/dist/pptx/dom/load-presentation.d.ts.map +1 -1
  34. package/dist/pptx/index.cjs +3086 -3058
  35. package/dist/pptx/index.mjs +1 -1
  36. package/dist/pptx/render/deck-webfont-readiness.d.ts +24 -10
  37. package/dist/pptx/render/deck-webfont-readiness.d.ts.map +1 -1
  38. package/dist/pptx/render/font-weight-names.d.ts +2 -65
  39. package/dist/pptx/render/font-weight-names.d.ts.map +1 -1
  40. package/dist/pptx/render/google-fonts-catalogue.d.ts +2 -13
  41. package/dist/pptx/render/google-fonts-catalogue.d.ts.map +1 -1
  42. package/dist/pptx/render/google-fonts-lookup.d.ts +2 -6
  43. package/dist/pptx/render/google-fonts-lookup.d.ts.map +1 -1
  44. package/dist/pptx/render/google-webfonts-link.d.ts +2 -2
  45. package/dist/pptx/render/google-webfonts-link.d.ts.map +1 -1
  46. package/dist/pptx/render/google-webfonts-metric-clones.d.ts +2 -16
  47. package/dist/pptx/render/google-webfonts-metric-clones.d.ts.map +1 -1
  48. package/dist/pptx/render/google-webfonts.d.ts +11 -107
  49. package/dist/pptx/render/google-webfonts.d.ts.map +1 -1
  50. package/dist/pptx/render/index.d.ts +3 -0
  51. package/dist/pptx/render/index.d.ts.map +1 -1
  52. package/dist/pptx/render/inline-list-dom.d.ts.map +1 -1
  53. package/dist/pptx/render/inline-text-paragraph-marker.d.ts +3 -0
  54. package/dist/pptx/render/inline-text-paragraph-marker.d.ts.map +1 -0
  55. package/dist/pptx/render/inline-text-seed.d.ts +25 -0
  56. package/dist/pptx/render/inline-text-seed.d.ts.map +1 -0
  57. package/dist/pptx/render/inline-trailing-space.d.ts +14 -0
  58. package/dist/pptx/render/inline-trailing-space.d.ts.map +1 -0
  59. package/dist/pptx/render/status-bar-state.d.ts +10 -0
  60. package/dist/pptx/render/status-bar-state.d.ts.map +1 -1
  61. package/dist/pptx/{smartart-insert-preview-R7USUBIX.cjs → smartart-insert-preview-GE47FXVT.cjs} +3 -3
  62. package/dist/pptx/{smartart-insert-preview-ZKVFXFSI.mjs → smartart-insert-preview-WY6DHSAJ.mjs} +2 -2
  63. package/dist/pptx/web-components/status-bar.d.ts.map +1 -1
  64. package/dist/teams.js +1 -1
  65. package/dist/theme-bridge.d.ts +0 -1
  66. package/dist/visio/controller.d.ts +12 -0
  67. package/dist/visio/font-stack.d.ts +11 -0
  68. package/dist/visio/locales/trust-center.d.ts +7 -0
  69. package/dist/visio/viewer-behaviour.d.ts +5 -0
  70. package/dist/visio/viewer-element.d.ts +16 -0
  71. package/dist/visio/viewer-options-categories.d.ts +6 -0
  72. package/dist/visio/viewer-options-trust.d.ts +10 -0
  73. package/dist/visio/viewer-options.d.ts +6 -0
  74. package/dist/visio/viewer-webfonts.d.ts +42 -0
  75. package/dist/visio.js +323 -21
  76. package/dist/xlsx/backstage/options-trust.d.ts +9 -0
  77. package/dist/xlsx/backstage/parts.d.ts +4 -0
  78. package/dist/xlsx/editor-core.d.ts +3 -0
  79. package/dist/xlsx/element-api.d.ts +15 -0
  80. package/dist/xlsx/font-downloads.d.ts +8 -0
  81. package/dist/xlsx/grid/drawings.d.ts +2 -0
  82. package/dist/xlsx/grid/measure.d.ts +2 -0
  83. package/dist/xlsx/page-views/page-layout-css.d.ts +1 -1
  84. package/dist/xlsx/print-cell.d.ts +1 -1
  85. package/dist/xlsx/webfonts.d.ts +70 -0
  86. package/dist/xlsx.js +259 -18
  87. package/package.json +2 -2
  88. package/dist/chunk-MWDG776V.js +0 -90
  89. /package/dist/{chunk-2YRHRV4H.js → chunk-MUY444GW.js} +0 -0
package/dist/visio.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { trackPointerPan, ownsCaptureLoss } from './chunk-GSXOZCAN.js';
2
- import { attachShareDialog, connectedServicesLabels, chartExSpaceFormatSource } from './chunk-MWDG776V.js';
2
+ import { FONT_DOWNLOADS_DEFAULT, fontDownloadLock, prepareWebfonts, effectiveFontDownloads, prefetchWebfonts, syncGoogleWebfontStylesheet, attachShareDialog, connectedServicesLabels, chartExSpaceFormatSource } from './chunk-G5CALQUW.js';
3
3
  import { createRecoveryScheduler } from './chunk-DA57FPSN.js';
4
4
  import { syncRibbonAddIns, createHostBackstagePages, syncHostMenuChildren, tidyMenuSeparators } from './chunk-ZTLP52FH.js';
5
5
  export { RIBBON_ADD_IN_EVENT } from './chunk-ZTLP52FH.js';
@@ -13,8 +13,9 @@ import './chunk-FE5KE5TR.js';
13
13
  import './chunk-6EOS74O4.js';
14
14
  import { VISIO_CAPABILITY_COMMANDS, VISIO_TEXT_LANGUAGES, VISIO_BULLET_STYLES, FOREIGN_VECTOR_SCENE_LIMITS, EMPTY_TEXT_SEARCH, EMPTY_SELECTION, EMPTY_EDIT_STATE, assertViewableDocument, snapshotSelection, selectionKey, indexDocumentText, searchDocumentText, sameSelection, validateSearchQuery, MAX_INPUT_BYTES, createTemplateVsdx, DocumentHistory, snapshotEdits, visioWithContainerMembers, snapshotVisioGeometryExpectation, visioSelectionIsOnPage, visioContainerUpkeep, assertVisioGeometryExpectation, visioDuplicateCommand, visioGroupCommand, visioUngroupCommand, visioContainerCommand, visioCalloutCommand, visioPasteCommand, visioTextOccurrenceSelection, ForeignVectorBudget, VISIO_IDENTITY_TRANSFORM, hasVisibleShapeContent, composeVisioTransform, compatibilityNotes, compatibilityText, visioGradientInstances, visioRenderedGradientStopCount, inspectForeignVectorResource, VISIO_CAPABILITY_BACKSTAGE_PAGES, copySnapshotScene, editErrorMessage, eventKeys, isEditCancellation, propertyKeys, VISIO_TEXT_REPLACE_LIMITS, visioTextReplaceOccurrences, visioTextReplacePlan, visioTextReplaceCommands, visioClipboardShape, TEXT_SEARCH_LIMITS, VISIO_TEMPLATES, visioSizePositionCommand, visioSizePositionState, visioPageInsertCommand, visioQuarterTurnCommand, visioRotationShape, VISIO_INITIAL_PRESENCE, sanitizeVisioPresence, isVisioTemplateId, textSearchStatus, visioSvgStrokeStyle, visioLineDashLengths, visioStencilDropCommand, visioMovementShape, visioMoveCommands, visioMoveTargets, visioMarqueeBox, visioPageDragDelta, visioSnapResizeDrag, visioResizeSelectionFrame, visioResizeSelectionDrag, visioTextShape, visioTextDraftEdit, isVisioPathTool, visioPathDrawPlan, visioDrawPlan, visioDrawBounds, visioDrawIsLargeEnough, visioConnectorCreationCommand, visioConnectorRouteOf, visioPageEditToDrawing, visioNudgeCommands, VISIO_DIAGRAM_RULE_SETS, visioArrangeCommands, visioChangeMasterTargets, visioChangeMasterCommand, visioChangeShapeRefusal, visioChangeShapeCommand, visioChangeCaseShape, visioChangeCaseCommand, visioTextBlockShape, visioTextBlockFrame, visioTextBlockEdit, visioOrderingShape, visioFormatTargetShape, visioFormattingShape, visioTextFormattingState, visioTextIndentCommand, visioTextFontStepCommand, visioFontFamilies, visioChartObjectInsertCommand, visioPictureInsertCommand, normalizeVisioHyperlinkAddress, visioFitToDrawingEdits, VISIO_PAPER_SIZES, visioPageSizePresetEdits, visioOrientationEdits, visioPageDecorationState, visioNewPageId, visioMatchingPaperSize, visioPageBreaks, visioSwimlaneOptions, visioInsertSeparator, visioDeleteSwimlane, visioInsertSwimlane, visioOrgHierarchy, visioOrgPeople, visioOrgImportEdits, visioOrgReLayout, visioOrgAddPosition, VISIO_DATA_GRAPHIC_POSITIONS, visioDataGraphicFields, visioRemoveDataGraphicEdits, visioDataGraphicConfigs, visioAutoSpaceDataGraphicEdits, visioPositionDataGraphicEdits, visioDataGraphicEdits, visioSetDataGraphicItemEdits, visioShapeDataRow, VISIO_DATA_GRAPHIC_FILL_ROW, visioColorRules, visioLegendEdits, visioDataGraphicOwners, visioTextDialogValues, visioTextDialogPatch, visioFormatPainterSnapshot, visioFormatPainterEdits, VISIO_FORMAT_PAINTER_LIMITS, visioConnectableShape, visioAddConnectionPointCommand, visioSwimlaneInfo, visioWithCalloutLeaders, visioWithDataGraphics, visioOrgPosition, visioFillPatternTransform, visioRenderedGradientStops, visioStrokeGradient, visioMasterDropRefusal, visioMasterDropSize, visioFileMasterDropCommand, visioMasterDropCommand, visioDrawingPoint, visioMovePreviewTransform, visioMarqueeSelection, VISIO_RESIZE_HANDLES, visioResizeSwimlane, visioPathPreview, visioNearestConnectionPoint, visioRotationPreviewTransform, visioStraightLineHandles, visioConnectorEndHandles, VISIO_LAYOUT_STYLES, visioShapeFormattingState, visioGlowKey, visioShapeEffectValues, visioReflectionKey, visioFollowTarget, visioPaperSize, visioKeepAutoSize, VISIO_RULER_DENSITY_CHOICES, VISIO_GRID_DENSITY_CHOICES, visioGridSteps, visioRulerGridValues, visioRulerDensityFactor, visioRulerGridEdits, checkVisioDiagram, visioShapeReport, visioShapeReportTable, visioShapeReportCsv, visioShapeReportText, visioSubprocessCommand, visioParseRange, visioDataTable, visioWorkbookGrid, visioOrgDeletePosition, visioShapeDataText, visioOrgFollowData, visioDeleteDataGraphicItemEdits, visioDataGraphicItems, visioVisualizerShapes, visioParseVisualizerTable, visioDataVisualizerEdits, VISIO_VISUALIZER_COLUMNS, VISIO_LAYOUT_LABELS, visioAutoAlignCommands, visioReLayoutCommands, visioLayerAssignState, visioNewLayerNames, visioLayerAssignCommands, VISIO_SELECT_TYPES, VISIO_SELECT_TYPE_LABELS, visioPageMasters, visioSelectByType, visioPasteTextCommand, visioSnapMoveDelta, visioPageGuides, visioAutoConnectShape, visioAutoConnectArrows, visioAutoConnectNeighbor, visioAutoConnectPlan, visioShapePageBox, VISIO_FIELD_CATEGORIES, visioTextAppendEdit, visioTextSource, visioTextBlockMatrix, VISIO_TEXT_BLOCK_HANDLES, visioShapeLocalPoint, visioTextBlockDrag, visioShapeFrame, visioMasterPreviewBox, visioConnectorMovePreviews, visioConnectorPreviewPath, visioGlueableShape, visioDataGraphicMarker, visioGuideCreateCommand, visioGuideMoveCommand } from 'ooxml-core/visio/ui';
15
15
  export { TEXT_SEARCH_LIMITS, VISIO_CAPABILITY_IDS, compatibilityNotes, compatibilityText, demoDocument, eventKeys, propertyKeys } from 'ooxml-core/visio/ui';
16
- import { VISIO_VISIBILITY_LIMITS, VISIO_BASIC_STENCIL, VISIO_STENCILS, visioOutlineShape, VISIO_SNAP, VISIO_GLUE, VISIO_SHADOW_PRESETS, loadVisio, createVsdx, deserializeVisioClipboard, mergeVisioPages, getVisioPageLayers, resolveVisioPageVisibility, visioLineJumpPaths, VISIO_CLIPBOARD_MAX_CHARS, projectPathData, createProjection, projectionMatrix, visioSnapGlue, VISIO_SWIMLANE_STYLES, VISIO_GLOW_TRANSPARENCY, VISIO_METADATA_TEXT_LIMIT, VISIO_PICTURE_MAX_BYTES, inspectVisioRasterImage, visioPageLayout, VISIO_BUILT_IN_THEMES, VISIO_CONNECTOR_ROUTES, visioRotation3dMatrix, visioFilledArrow, layoutVisioFilledArrowLine, visioOpenArrowPath, bevelMaterial, bevelLight, bevelHeightTable, extrudePaths, extrusionPathData, visioBuiltInStencil, visioBuiltInMaster, isVisioChangeShapeTarget, VISIO_CONTAINER_STYLES, VISIO_CALLOUT_STYLES, visioFallbackQuickStyle, VISIO_GLOW_SIZES, VISIO_BEVEL_PRESETS, VISIO_ROTATION_PRESETS, VISIO_SOFT_EDGE_SIZES, VISIO_REFLECTION_PRESETS, encodeBitmapEmf, VISIO_BACKGROUND_STYLES, visioBackgroundShapes, VISIO_BORDER_STYLES, visioBorderShapes, checkVisioAlternativeText, visioRefreshReport, VISIO_SHAPE_DATA_TYPES, visioShapeDataRowName, VISIO_CLIPBOARD_MAGIC, visioThemeVariantColors, visioPageThemeColors, parseVsdx, parsePath, visioTabStarts, readVisioStencil, isVisioBuiltInThemeId, VISIO_QUICK_STYLE_COLORS, VISIO_SCALE_UNITS, BEVEL_BLUR_WIDTHS } from 'ooxml-core/visio';
16
+ import { VISIO_VISIBILITY_LIMITS, VISIO_BASIC_STENCIL, VISIO_STENCILS, visioOutlineShape, VISIO_SNAP, VISIO_GLUE, VISIO_SHADOW_PRESETS, loadVisio, createVsdx, deserializeVisioClipboard, mergeVisioPages, getVisioPageLayers, resolveVisioPageVisibility, visioLineJumpPaths, collectVisioWebfontRuns, VISIO_CLIPBOARD_MAX_CHARS, projectPathData, createProjection, projectionMatrix, visioSnapGlue, VISIO_SWIMLANE_STYLES, VISIO_GLOW_TRANSPARENCY, VISIO_METADATA_TEXT_LIMIT, VISIO_PICTURE_MAX_BYTES, inspectVisioRasterImage, visioPageLayout, VISIO_BUILT_IN_THEMES, VISIO_CONNECTOR_ROUTES, visioRotation3dMatrix, visioFilledArrow, layoutVisioFilledArrowLine, visioOpenArrowPath, bevelMaterial, bevelLight, bevelHeightTable, extrudePaths, extrusionPathData, visioBuiltInStencil, visioBuiltInMaster, isVisioChangeShapeTarget, VISIO_CONTAINER_STYLES, VISIO_CALLOUT_STYLES, visioFallbackQuickStyle, VISIO_GLOW_SIZES, VISIO_BEVEL_PRESETS, VISIO_ROTATION_PRESETS, VISIO_SOFT_EDGE_SIZES, VISIO_REFLECTION_PRESETS, encodeBitmapEmf, VISIO_BACKGROUND_STYLES, visioBackgroundShapes, VISIO_BORDER_STYLES, visioBorderShapes, checkVisioAlternativeText, visioRefreshReport, VISIO_SHAPE_DATA_TYPES, visioShapeDataRowName, VISIO_CLIPBOARD_MAGIC, visioThemeVariantColors, visioPageThemeColors, parseVsdx, parsePath, visioTabStarts, readVisioStencil, isVisioBuiltInThemeId, VISIO_QUICK_STYLE_COLORS, VISIO_SCALE_UNITS, BEVEL_BLUR_WIDTHS } from 'ooxml-core/visio';
17
17
  import { renderChartSvg, readEmbeddedChartSpace, readEmbeddedChartExSpace, writeEmbeddedChartSpace, writeEmbeddedChartExSpace } from 'ooxml-core/xlsx';
18
+ import { getSubstituteFontFamily, resolveGoogleFontsCss2Base, parseTrueType, subsetTrueType } from 'ooxml-core/text';
18
19
  import { resolveRotateHandlePlacement, createRotationDrag, snapAngle } from 'ooxml-core/geometry';
19
20
  import { interpolate, normalizeLocale } from 'ooxml-core/i18n';
20
21
  import { isCapabilityEnabled, capabilityHiddenActions, recoveryStoreOf, FILE_COMMAND_EVENT, fileCommandDetail, documentSaveMeta, saveToStorage } from 'ooxml-core/embedding';
@@ -22,7 +23,6 @@ import { createWriteBackScheduler, DEFAULT_WRITE_BACK_DEBOUNCE_MS, flushWriteBac
22
23
  import { INSERT_CHART_TYPES, GROUPED_CHART_TYPES, gridChartSvg, gridChart, parseChartGrid, readEmbeddedChart, chartGridText, gridChartWorkbook } from 'ooxml-core/xlsx/ui';
23
24
  import { applyChartSpaceDataSheetEdits, applyChartExSpaceDataSheetEdits, applyChartEditIntent, applyChartExEditIntent, chartSpaceDataSheet, renderChartSpaceSvg, chartExSpaceDataSheet, chartExSummaryFromModel, renderChartSummarySvg } from 'ooxml-core/chart';
24
25
  import { pushRecentColor, normalizePaletteHex } from 'ooxml-core/color';
25
- import { parseTrueType, subsetTrueType } from 'ooxml-core/text';
26
26
  import { zlibCompress } from 'ooxml-core/opc';
27
27
 
28
28
  function createWorkerEditor(factory, timeoutMs = 2e4) {
@@ -582,6 +582,8 @@ var ViewerController = class {
582
582
  #visible = documentVisibility(null);
583
583
  #clipboard;
584
584
  #clipboardQueued = false;
585
+ #beforeShow;
586
+ #beforeParse;
585
587
  get state() {
586
588
  return this.#state;
587
589
  }
@@ -662,6 +664,22 @@ var ViewerController = class {
662
664
  this.#events.add(listener);
663
665
  return () => this.#events.delete(listener);
664
666
  }
667
+ /**
668
+ * Run `hook` between parsing a drawing and showing it, while `loading` is still true (the
669
+ * viewer waits there, bounded, for the webfonts the drawing draws). A hook that returns
670
+ * nothing adds no wait; one that rejects is ignored. A newer load or `cancelLoad` wins.
671
+ */
672
+ setBeforeShow(hook) {
673
+ this.#beforeShow = hook;
674
+ }
675
+ /**
676
+ * Run `hook` with a file's bytes just before they are parsed (the viewer starts the drawing's
677
+ * webfonts there, so they download during the parse). It must not keep the bytes; one that
678
+ * throws is ignored.
679
+ */
680
+ setBeforeParse(hook) {
681
+ this.#beforeParse = hook;
682
+ }
665
683
  setDocument(document2) {
666
684
  this.#assertAlive();
667
685
  if (document2) assertViewableDocument(document2);
@@ -870,6 +888,10 @@ var ViewerController = class {
870
888
  if (bytes.byteLength > MAX_INPUT_BYTES)
871
889
  throw new Error("This viewer accepts files up to 32 MiB.");
872
890
  const owned = bytes instanceof Uint8Array ? Uint8Array.from(bytes) : new Uint8Array(bytes.slice(0));
891
+ try {
892
+ this.#beforeParse?.(owned);
893
+ } catch {
894
+ }
873
895
  document2 = await this.parser(Uint8Array.from(owned));
874
896
  if (this.#destroyed || id !== this.#loadId) return;
875
897
  assertViewableDocument(document2);
@@ -885,6 +907,11 @@ var ViewerController = class {
885
907
  if (!this.#destroyed && id === this.#loadId) this.#emit("document-error", error);
886
908
  throw error;
887
909
  }
910
+ const ready = this.#beforeShow?.(document2);
911
+ if (ready) {
912
+ await ready.catch(() => void 0);
913
+ if (this.#destroyed || id !== this.#loadId) return;
914
+ }
888
915
  this.#history = history;
889
916
  this.#selectionHistory = /* @__PURE__ */ new WeakMap();
890
917
  this.#sourceFormat = document2.format;
@@ -2166,6 +2193,25 @@ function applyArrowheads(path, style2, defs, warnings) {
2166
2193
  warnings.add("Common arrowhead shapes are rendered; arrowhead sizing is approximate.");
2167
2194
  }
2168
2195
  }
2196
+ var MAX_CACHED = 512;
2197
+ var stacks = /* @__PURE__ */ new Map();
2198
+ function visioFontStack(family) {
2199
+ const cached = stacks.get(family);
2200
+ if (cached !== void 0) return cached;
2201
+ const stack2 = getSubstituteFontFamily(family);
2202
+ if (stacks.size >= MAX_CACHED) stacks.clear();
2203
+ stacks.set(family, stack2);
2204
+ return stack2;
2205
+ }
2206
+ function primaryFontFamily(value) {
2207
+ const trimmed = value.trim();
2208
+ const quote = trimmed[0];
2209
+ if (quote === '"' || quote === "'") {
2210
+ const end = trimmed.indexOf(quote, 1);
2211
+ return end < 0 ? trimmed.slice(1) : trimmed.slice(1, end);
2212
+ }
2213
+ return (trimmed.split(",")[0] ?? "").trim();
2214
+ }
2169
2215
 
2170
2216
  // src/visio/text-run-style.ts
2171
2217
  var POSITION_SIZE = 2 / 3;
@@ -2307,7 +2353,7 @@ var measureBrowserText = (text2, run) => {
2307
2353
  const spacing = (run.letterSpacing ?? 0) * count;
2308
2354
  const size = runDisplaySize(run);
2309
2355
  if (!canvas) return Math.max(0, count * size * 0.55 + spacing);
2310
- canvas.font = `${run.italic ? "italic " : ""}${run.textCase === "small-caps" ? "small-caps " : ""}${run.bold ? "bold " : ""}${size * 96}px ${JSON.stringify(run.fontFamily)}`;
2356
+ canvas.font = `${run.italic ? "italic " : ""}${run.textCase === "small-caps" ? "small-caps " : ""}${run.bold ? "bold " : ""}${size * 96}px ${visioFontStack(run.fontFamily)}`;
2311
2357
  return Math.max(0, canvas.measureText(runDisplayText(text2, run)).width / 96 + spacing);
2312
2358
  };
2313
2359
  function wrapText(runs, width, measure = measureBrowserText, firstLineIndent = 0, budget = createTextLayoutBudget()) {
@@ -2529,7 +2575,7 @@ function appendRuns(row, runs, text2) {
2529
2575
  for (const run of runs) {
2530
2576
  const span = svgElement("tspan");
2531
2577
  span.textContent = runDisplayText(run.text, run);
2532
- span.setAttribute("font-family", run.fontFamily);
2578
+ span.setAttribute("font-family", visioFontStack(run.fontFamily));
2533
2579
  span.setAttribute("font-size", String(runDisplaySize(run)));
2534
2580
  if (run.textCase === "small-caps") span.setAttribute("font-variant", "small-caps");
2535
2581
  if (run.letterSpacing) span.setAttribute("letter-spacing", String(run.letterSpacing));
@@ -2558,7 +2604,7 @@ function renderText(text2, warnings, budget) {
2558
2604
  group2.append(backgrounds);
2559
2605
  const node = svgElement("text");
2560
2606
  node.style.whiteSpace = "pre";
2561
- node.setAttribute("font-family", text2.fontFamily);
2607
+ node.setAttribute("font-family", visioFontStack(text2.fontFamily));
2562
2608
  node.setAttribute("font-size", String(text2.fontSize));
2563
2609
  node.setAttribute("fill", safeColor(text2.color));
2564
2610
  let layout;
@@ -2626,7 +2672,7 @@ function renderText(text2, warnings, budget) {
2626
2672
  bullet.textContent = line.bullet.text;
2627
2673
  bullet.setAttribute("x", String(line.bullet.x));
2628
2674
  bullet.setAttribute("y", String(y + line.y));
2629
- bullet.setAttribute("font-family", line.bullet.fontFamily);
2675
+ bullet.setAttribute("font-family", visioFontStack(line.bullet.fontFamily));
2630
2676
  bullet.setAttribute("font-size", String(line.bullet.fontSize));
2631
2677
  bullet.setAttribute("fill", safeColor(text2.color));
2632
2678
  bullet.setAttribute("fill-opacity", String(text2.opacity ?? 1));
@@ -4470,6 +4516,11 @@ var ViewerInlineText = class {
4470
4516
  );
4471
4517
  session.group?.setAttribute("data-editing-text", "");
4472
4518
  this.#style(shape, state.zoom || 1);
4519
+ } else if (!session.group?.isConnected) {
4520
+ session.group = this.viewport.querySelector(
4521
+ `svg.paper [data-shape-id="${CSS.escape(shape.id)}"]`
4522
+ );
4523
+ session.group?.setAttribute("data-editing-text", "");
4473
4524
  }
4474
4525
  if (!this.input.isConnected) {
4475
4526
  const { selectionStart, selectionEnd } = this.input;
@@ -4492,7 +4543,7 @@ var ViewerInlineText = class {
4492
4543
  #style(shape, zoom) {
4493
4544
  const text2 = shape.text;
4494
4545
  const style2 = this.input.style;
4495
- style2.fontFamily = text2?.fontFamily ? `"${text2.fontFamily}", var(--office-font)` : "";
4546
+ style2.fontFamily = text2?.fontFamily ? visioFontStack(text2.fontFamily) : "";
4496
4547
  style2.fontSize = `${Math.max(8, (text2?.fontSize ?? 12 / 72) * 96 * zoom)}px`;
4497
4548
  style2.color = text2?.color ?? "";
4498
4549
  style2.textAlign = text2?.horizontalAlign === "justify" ? "justify" : text2?.horizontalAlign ?? "center";
@@ -10204,14 +10255,63 @@ var zhCNBackstage = {
10204
10255
  "Could not update {provider}. Try again.": "\u65E0\u6CD5\u66F4\u65B0 {provider}\u3002\u8BF7\u91CD\u8BD5\u3002"
10205
10256
  };
10206
10257
 
10258
+ // src/visio/locales/trust-center.ts
10259
+ var VISIO_TRUST_STRINGS = {
10260
+ en: {
10261
+ "Trust Center": "Trust Center",
10262
+ "Help keep your documents safe and secure.": "Help keep your documents safe and secure.",
10263
+ "Security settings": "Security settings",
10264
+ "These settings help keep the content you open safe. We recommend the defaults.": "These settings help keep the content you open safe. We recommend the defaults.",
10265
+ "Download fonts that are not installed or embedded (Google Fonts)": "Download fonts that are not installed or embedded (Google Fonts)",
10266
+ "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.": "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.",
10267
+ "This setting is managed by your organization": "This setting is managed by your organization"
10268
+ },
10269
+ de: {
10270
+ "Trust Center": "Trust Center",
10271
+ "Help keep your documents safe and secure.": "Sorgen Sie f\xFCr die Sicherheit Ihrer Dokumente.",
10272
+ "Security settings": "Sicherheitseinstellungen",
10273
+ "These settings help keep the content you open safe. We recommend the defaults.": "Diese Einstellungen tragen dazu bei, ge\xF6ffnete Inhalte sicher zu halten. Wir empfehlen die Standardwerte.",
10274
+ "Download fonts that are not installed or embedded (Google Fonts)": "Nicht installierte oder eingebettete Schriftarten herunterladen (Google Fonts)",
10275
+ "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.": "Wenn aktiviert, ruft Ihr Browser fehlende Schriftarten von fonts.googleapis.com und fonts.gstatic.com (oder vom Schriftartserver Ihrer Organisation) ab. Wenn deaktiviert, verwendet Text installierte, eingebettete oder Ersatzschriftarten, sodass Zeilenumbr\xFCche von Visio abweichen k\xF6nnen.",
10276
+ "This setting is managed by your organization": "Diese Einstellung wird von Ihrer Organisation verwaltet"
10277
+ },
10278
+ es: {
10279
+ "Trust Center": "Centro de confianza",
10280
+ "Help keep your documents safe and secure.": "Ayude a mantener sus documentos seguros y protegidos.",
10281
+ "Security settings": "Configuraci\xF3n de seguridad",
10282
+ "These settings help keep the content you open safe. We recommend the defaults.": "Esta configuraci\xF3n ayuda a mantener seguro el contenido que abre. Recomendamos los valores predeterminados.",
10283
+ "Download fonts that are not installed or embedded (Google Fonts)": "Descargar fuentes que no est\xE1n instaladas ni incrustadas (Google Fonts)",
10284
+ "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.": "Cuando est\xE1 activado, el navegador se conecta a fonts.googleapis.com y fonts.gstatic.com (o al servidor de fuentes de su organizaci\xF3n) para obtener las fuentes que faltan. Cuando est\xE1 desactivado, el texto usa fuentes instaladas, incrustadas o sustitutas, por lo que los saltos de l\xEDnea pueden diferir de Visio.",
10285
+ "This setting is managed by your organization": "Esta configuraci\xF3n la administra su organizaci\xF3n"
10286
+ },
10287
+ fr: {
10288
+ "Trust Center": "Centre de gestion de la confidentialit\xE9",
10289
+ "Help keep your documents safe and secure.": "Assurez la s\xE9curit\xE9 et la protection de vos documents.",
10290
+ "Security settings": "Param\xE8tres de s\xE9curit\xE9",
10291
+ "These settings help keep the content you open safe. We recommend the defaults.": "Ces param\xE8tres contribuent \xE0 la s\xE9curit\xE9 du contenu que vous ouvrez. Nous recommandons les valeurs par d\xE9faut.",
10292
+ "Download fonts that are not installed or embedded (Google Fonts)": "T\xE9l\xE9charger les polices non install\xE9es ni incorpor\xE9es (Google Fonts)",
10293
+ "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.": "Lorsque cette option est activ\xE9e, votre navigateur contacte fonts.googleapis.com et fonts.gstatic.com (ou le serveur de polices de votre organisation) pour obtenir les polices manquantes. Lorsqu'elle est d\xE9sactiv\xE9e, le texte utilise des polices install\xE9es, incorpor\xE9es ou de substitution, et les sauts de ligne peuvent donc diff\xE9rer de Visio.",
10294
+ "This setting is managed by your organization": "Ce param\xE8tre est g\xE9r\xE9 par votre organisation"
10295
+ },
10296
+ "zh-CN": {
10297
+ "Trust Center": "\u4FE1\u4EFB\u4E2D\u5FC3",
10298
+ "Help keep your documents safe and secure.": "\u5E2E\u52A9\u786E\u4FDD\u60A8\u7684\u6587\u6863\u5B89\u5168\u53EF\u9760\u3002",
10299
+ "Security settings": "\u5B89\u5168\u8BBE\u7F6E",
10300
+ "These settings help keep the content you open safe. We recommend the defaults.": "\u8FD9\u4E9B\u8BBE\u7F6E\u6709\u52A9\u4E8E\u786E\u4FDD\u60A8\u6253\u5F00\u7684\u5185\u5BB9\u5B89\u5168\u3002\u6211\u4EEC\u5EFA\u8BAE\u4F7F\u7528\u9ED8\u8BA4\u503C\u3002",
10301
+ "Download fonts that are not installed or embedded (Google Fonts)": "\u4E0B\u8F7D\u672A\u5B89\u88C5\u6216\u672A\u5D4C\u5165\u7684\u5B57\u4F53\uFF08Google Fonts\uFF09",
10302
+ "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.": "\u5F00\u542F\u65F6\uFF0C\u6D4F\u89C8\u5668\u4F1A\u8FDE\u63A5 fonts.googleapis.com \u548C fonts.gstatic.com\uFF08\u6216\u8D35\u7EC4\u7EC7\u8BBE\u7F6E\u7684\u5B57\u4F53\u670D\u52A1\u5668\uFF09\u4EE5\u83B7\u53D6\u7F3A\u5C11\u7684\u5B57\u4F53\u3002\u5173\u95ED\u65F6\uFF0C\u6587\u672C\u4F7F\u7528\u5DF2\u5B89\u88C5\u3001\u5DF2\u5D4C\u5165\u6216\u66FF\u4EE3\u5B57\u4F53\uFF0C\u56E0\u6B64\u6362\u884C\u53EF\u80FD\u4E0E Visio \u4E0D\u540C\u3002",
10303
+ "This setting is managed by your organization": "\u6B64\u8BBE\u7F6E\u7531\u4F60\u7684\u7EC4\u7EC7\u7BA1\u7406"
10304
+ }
10305
+ };
10306
+
10207
10307
  // src/visio/ribbon-locale.ts
10208
10308
  var VISIO_LOCALES = ["en", "de", "es", "fr", "zh-CN"];
10209
10309
  var VISIO_RIBBON_STRINGS = {
10210
- en: { ...enCommands, ...enText, ...enBackstage },
10211
- de: { ...deCommands, ...deText, ...deBackstage },
10212
- es: { ...esCommands, ...esText, ...esBackstage },
10213
- fr: { ...frCommands, ...frText, ...frBackstage },
10214
- "zh-CN": { ...zhCNCommands, ...zhCNText, ...zhCNBackstage }
10310
+ en: { ...enCommands, ...enText, ...enBackstage, ...VISIO_TRUST_STRINGS.en },
10311
+ de: { ...deCommands, ...deText, ...deBackstage, ...VISIO_TRUST_STRINGS.de },
10312
+ es: { ...esCommands, ...esText, ...esBackstage, ...VISIO_TRUST_STRINGS.es },
10313
+ fr: { ...frCommands, ...frText, ...frBackstage, ...VISIO_TRUST_STRINGS.fr },
10314
+ "zh-CN": { ...zhCNCommands, ...zhCNText, ...zhCNBackstage, ...VISIO_TRUST_STRINGS["zh-CN"] }
10215
10315
  };
10216
10316
  function normalizeVisioLocale(value) {
10217
10317
  return normalizeLocale(value, VISIO_LOCALES, "en");
@@ -14789,6 +14889,7 @@ var DEFAULT_BEHAVIOUR = {
14789
14889
  checkSpelling: true,
14790
14890
  autoRecover: false,
14791
14891
  autoRecoverMinutes: 10,
14892
+ allowFontDownloads: FONT_DOWNLOADS_DEFAULT,
14792
14893
  ...tabDefaults,
14793
14894
  ...qatDefaults
14794
14895
  };
@@ -15667,6 +15768,94 @@ function createBackstage(doc) {
15667
15768
  );
15668
15769
  return root;
15669
15770
  }
15771
+ var VISIO_WEBFONT_LINK_ID = "visio-viewer-webfonts";
15772
+ var viewers = 0;
15773
+ var ViewerWebfonts = class {
15774
+ constructor(host, prepare = prepareWebfonts) {
15775
+ this.host = host;
15776
+ this.prepare = prepare;
15777
+ const index = ++viewers;
15778
+ this.linkId = index === 1 ? VISIO_WEBFONT_LINK_ID : `${VISIO_WEBFONT_LINK_ID}-${index}`;
15779
+ }
15780
+ host;
15781
+ prepare;
15782
+ #option;
15783
+ #readerAllows = FONT_DOWNLOADS_DEFAULT;
15784
+ linkId;
15785
+ /** Bumped by every request and option change, so a superseded wait is ignored. */
15786
+ #generation = 0;
15787
+ get option() {
15788
+ return this.#option;
15789
+ }
15790
+ set option(value) {
15791
+ this.#option = value;
15792
+ this.#changed();
15793
+ }
15794
+ /** The reader's Trust Center choice, used only while the host left `option` unset. */
15795
+ get readerAllows() {
15796
+ return this.#readerAllows;
15797
+ }
15798
+ set readerAllows(value) {
15799
+ this.#readerAllows = value;
15800
+ this.#changed();
15801
+ }
15802
+ #changed() {
15803
+ ++this.#generation;
15804
+ if (this.base() === null) this.remove();
15805
+ }
15806
+ /**
15807
+ * The CSS2 base requested, or `null` when the fallback is off: the host's option when set,
15808
+ * else Google Fonts when the reader allowed downloads (`effectiveFontDownloads`).
15809
+ */
15810
+ base() {
15811
+ return resolveGoogleFontsCss2Base(
15812
+ effectiveFontDownloads(this.#option, this.#readerAllows),
15813
+ null,
15814
+ "visio-viewer"
15815
+ );
15816
+ }
15817
+ /**
15818
+ * Load the faces the drawing draws in families the reader has neither installed nor gets from
15819
+ * the bundled catalogue under another name. Resolves `undefined` when off, superseded or when
15820
+ * no webfont was needed; otherwise the readiness, after the bounded wait. Never rejects.
15821
+ */
15822
+ async load(document2) {
15823
+ const generation = ++this.#generation;
15824
+ const base = this.base();
15825
+ if (base === null || !document2) return void 0;
15826
+ let readiness;
15827
+ try {
15828
+ readiness = await this.prepare({
15829
+ document: this.host(),
15830
+ linkId: this.linkId,
15831
+ runs: collectVisioWebfontRuns(document2),
15832
+ base
15833
+ });
15834
+ } catch {
15835
+ return void 0;
15836
+ }
15837
+ if (generation !== this.#generation || readiness.families.length === 0) return void 0;
15838
+ return readiness;
15839
+ }
15840
+ /**
15841
+ * Start downloading the faces the file declares before it is parsed (see `prefetchWebfonts`),
15842
+ * so they are usually ready when {@link load} waits. Never throws.
15843
+ */
15844
+ prefetch(bytes) {
15845
+ try {
15846
+ prefetchWebfonts({ document: this.host(), linkId: this.linkId, bytes, base: this.base() });
15847
+ } catch {
15848
+ }
15849
+ }
15850
+ /** Remove this viewer's stylesheet (option off, viewer destroyed). */
15851
+ remove() {
15852
+ ++this.#generation;
15853
+ try {
15854
+ syncGoogleWebfontStylesheet(this.host(), this.linkId, null);
15855
+ } catch {
15856
+ }
15857
+ }
15858
+ };
15670
15859
 
15671
15860
  // src/visio/locales/cloud-files.ts
15672
15861
  var VISIO_CLOUD_FILES_LABELS = {
@@ -16003,14 +16192,16 @@ function estimatePageSvgBytes(model, page3, maxBytes) {
16003
16192
  let characters = 0;
16004
16193
  for (const run of runs) {
16005
16194
  characters += run.text.length;
16006
- reserve(run.text.length * (512 + run.fontFamily.length * 6 + run.color.length * 6));
16195
+ reserve(
16196
+ run.text.length * (512 + visioFontStack(run.fontFamily).length * 6 + run.color.length * 6)
16197
+ );
16007
16198
  }
16008
16199
  const lineCount = Math.min(5e3, characters + (text2.paragraphs?.length ?? 1));
16009
16200
  reserve(lineCount * (640 + (text2.backgroundColor ? 512 + text2.backgroundColor.length * 6 : 0)));
16010
16201
  for (const paragraph of text2.paragraphs ?? [])
16011
16202
  if (paragraph.bullet)
16012
16203
  reserve(
16013
- 512 + (paragraph.bullet.text.length + paragraph.bullet.fontFamily.length + text2.color.length) * 6
16204
+ 512 + (paragraph.bullet.text.length + visioFontStack(paragraph.bullet.fontFamily).length + text2.color.length) * 6
16014
16205
  );
16015
16206
  }
16016
16207
  return maxBytes - remaining;
@@ -17812,6 +18003,35 @@ var ViewerPanZoom = class {
17812
18003
  }
17813
18004
  };
17814
18005
 
18006
+ // src/visio/viewer-options-trust.ts
18007
+ var FONT_DOWNLOADS_KEY = "allowFontDownloads";
18008
+ var FONT_DOWNLOADS_INFO = "When on, your browser contacts fonts.googleapis.com and fonts.gstatic.com (or the font server your organisation set up) to get missing fonts. When off, text uses installed, embedded or substitute fonts, so line breaks can differ from Visio.";
18009
+ function visioTrustCategory(locale = "en", locked) {
18010
+ const t = (text2) => translateRibbonText(locale, text2);
18011
+ const toggle = {
18012
+ kind: "toggle",
18013
+ key: FONT_DOWNLOADS_KEY,
18014
+ label: t("Download fonts that are not installed or embedded (Google Fonts)"),
18015
+ info: t(FONT_DOWNLOADS_INFO),
18016
+ ...locked === void 0 ? {} : { disabled: t("This setting is managed by your organization") }
18017
+ };
18018
+ return {
18019
+ id: "trust",
18020
+ label: t("Trust Center"),
18021
+ description: t("Help keep your documents safe and secure."),
18022
+ sections: [
18023
+ {
18024
+ id: "trustSettings",
18025
+ title: t("Security settings"),
18026
+ description: t(
18027
+ "These settings help keep the content you open safe. We recommend the defaults."
18028
+ ),
18029
+ controls: [toggle]
18030
+ }
18031
+ ]
18032
+ };
18033
+ }
18034
+
17815
18035
  // src/visio/viewer-options-categories.ts
17816
18036
  var visio = { product: "Visio", t: (text2) => text2 };
17817
18037
  var disabled = (reason) => ({ disabled: `Not available. ${reason}` });
@@ -18032,8 +18252,13 @@ var VISIO_OPTION_CATEGORIES = [
18032
18252
  ]
18033
18253
  },
18034
18254
  unavailableCategory(visio, "addins"),
18035
- unavailableCategory(visio, "trust")
18255
+ visioTrustCategory()
18036
18256
  ];
18257
+ function visioOptionCategories(locale, fontDownloadsLocked) {
18258
+ return VISIO_OPTION_CATEGORIES.map(
18259
+ (category) => category.id === "trust" ? visioTrustCategory(locale, fontDownloadsLocked) : category
18260
+ );
18261
+ }
18037
18262
 
18038
18263
  // src/visio/viewer-options.ts
18039
18264
  var THEME_KEY = "ooxml-visio-office-theme";
@@ -18053,9 +18278,11 @@ function writeStatusBarTheme(theme) {
18053
18278
  }
18054
18279
  }
18055
18280
  var isOfficeThemeChoice = (value) => value === "dark" || isStatusBarTheme(value);
18056
- function profileValues(profile, officeTheme, behaviour) {
18281
+ function profileValues(profile, officeTheme, behaviour, fontDownloadsLocked) {
18057
18282
  return {
18058
18283
  ...behaviour,
18284
+ // A host decision shows read-only in place of the reader's own choice.
18285
+ ...fontDownloadsLocked === void 0 ? {} : { [FONT_DOWNLOADS_KEY]: fontDownloadsLocked },
18059
18286
  officeTheme,
18060
18287
  userName: profile.displayName,
18061
18288
  userInitials: profile.initial ?? ""
@@ -18094,14 +18321,27 @@ var ViewerProfile = class {
18094
18321
  onBehaviour;
18095
18322
  #profile = readOfficeProfile();
18096
18323
  #behaviour = readBehaviour();
18324
+ #locale = "en";
18325
+ #fontDownloadsLocked;
18097
18326
  #dialog;
18098
18327
  #account;
18099
18328
  get profile() {
18100
18329
  return { ...this.#profile };
18101
18330
  }
18331
+ /**
18332
+ * The Trust Center's language and the host's font download decision (`fontDownloadLock`):
18333
+ * `undefined` leaves the toggle to the reader, a boolean shows it read-only with that value.
18334
+ */
18335
+ setTrust(locale, fontDownloadsLocked) {
18336
+ if (locale === this.#locale && fontDownloadsLocked === this.#fontDownloadsLocked) return;
18337
+ this.#locale = locale;
18338
+ this.#fontDownloadsLocked = fontDownloadsLocked;
18339
+ this.#dialog.categories = visioOptionCategories(locale, fontDownloadsLocked);
18340
+ this.#sync();
18341
+ }
18102
18342
  /** Open Visio Options, on General as Visio does. */
18103
18343
  showOptions(category = "general") {
18104
- this.#dialog.values = profileValues(this.#profile, this.theme.get(), this.#behaviour);
18344
+ this.#dialog.values = this.#values();
18105
18345
  this.#dialog.category = category;
18106
18346
  this.#dialog.show();
18107
18347
  }
@@ -18117,7 +18357,10 @@ var ViewerProfile = class {
18117
18357
  this.theme.set(values.officeTheme);
18118
18358
  if (values.officeTheme !== "dark") writeStatusBarTheme(values.officeTheme);
18119
18359
  }
18120
- const next = mergeBehaviour(this.#behaviour, values);
18360
+ const next = mergeBehaviour(
18361
+ this.#behaviour,
18362
+ this.#fontDownloadsLocked === void 0 ? values : { ...values, [FONT_DOWNLOADS_KEY]: this.#behaviour.allowFontDownloads }
18363
+ );
18121
18364
  if (behaviourChanged(next, this.#behaviour)) {
18122
18365
  this.#behaviour = next;
18123
18366
  writeBehaviour(next);
@@ -18147,7 +18390,15 @@ var ViewerProfile = class {
18147
18390
  }
18148
18391
  #sync() {
18149
18392
  if (this.#account) this.#account.profile = this.#profile;
18150
- this.#dialog.values = profileValues(this.#profile, this.theme.get(), this.#behaviour);
18393
+ this.#dialog.values = this.#values();
18394
+ }
18395
+ #values() {
18396
+ return profileValues(
18397
+ this.#profile,
18398
+ this.theme.get(),
18399
+ this.#behaviour,
18400
+ this.#fontDownloadsLocked
18401
+ );
18151
18402
  }
18152
18403
  };
18153
18404
 
@@ -29884,6 +30135,10 @@ var urlId = (value) => value ? /^url\(\s*['"]?#([^'")\s]+)['"]?\s*\)$/.exec(valu
29884
30135
 
29885
30136
  // src/visio/pdf-svg-text.ts
29886
30137
  var MAX_RUNS = 1e5;
30138
+ function drawingFontFamily(value) {
30139
+ const primary = primaryFontFamily(value);
30140
+ return visioFontStack(primary) === value ? primary : value;
30141
+ }
29887
30142
  function drawSvgText(page3, text2, alpha, fonts) {
29888
30143
  const rows = Array.from(text2.children).filter((child) => child.localName === "tspan");
29889
30144
  if (!rows.length) {
@@ -29912,7 +30167,7 @@ function drawRow(page3, row, spans, alpha, fonts) {
29912
30167
  if (!color3) continue;
29913
30168
  const size = number2(inherited(span, "font-size"), 12);
29914
30169
  const weight = inherited(span, "font-weight") ?? "";
29915
- const family = inherited(span, "font-family") ?? "";
30170
+ const family = drawingFontFamily(inherited(span, "font-family") ?? "");
29916
30171
  const bold = weight === "bold" || number2(weight) >= 600;
29917
30172
  const italic = (inherited(span, "font-style") ?? "") === "italic";
29918
30173
  const font = pdfBaseFont(family, bold, italic);
@@ -30841,6 +31096,27 @@ var VisioViewerElement = class extends BaseElement {
30841
31096
  * (nothing is bundled); a font whose licence forbids embedding is reported and skipped.
30842
31097
  */
30843
31098
  pdfFonts = [];
31099
+ /**
31100
+ * Webfont fallback for fonts the drawing uses that the reader has not installed (Calibri,
31101
+ * Cambria, Aptos and other Office fonts load as their metric-compatible clones Carlito,
31102
+ * Caladea and so on; other catalogue families load as themselves), so text wraps as saved.
31103
+ * This is the host's decision: unset leaves it to the reader's File > Options > Trust Center
31104
+ * toggle (off until the reader turns it on, then Google Fonts); a value set here shows that
31105
+ * toggle read-only. `false`: off, no request is made. `{ baseUrl }`: CSS2 requests go to that
31106
+ * mirror (an absolute http(s) URL without credentials, query or fragment; anything else warns
31107
+ * and stays off), for example `{ baseUrl: 'https://fonts.googleapis.com/css2' }` for Google
31108
+ * itself. Only public catalogue family names are sent, never text. Read when a drawing loads:
31109
+ * the first show waits briefly (150 ms, with the loading state up) for the faces, and a face that
31110
+ * arrives later redraws the page. Setting it applies to the open drawing at once.
31111
+ */
31112
+ get googleFonts() {
31113
+ return this.#webfonts.option;
31114
+ }
31115
+ set googleFonts(value) {
31116
+ this.#webfonts.option = value;
31117
+ this.#syncTrust();
31118
+ void this.#refreshWebfonts();
31119
+ }
30844
31120
  /** What `collaboration-change` last reported. */
30845
31121
  get collaborationState() {
30846
31122
  return this.#share.state;
@@ -30904,6 +31180,7 @@ var VisioViewerElement = class extends BaseElement {
30904
31180
  #preview;
30905
31181
  #suspended = false;
30906
31182
  #fontEvents;
31183
+ #webfonts = new ViewerWebfonts(() => this.ownerDocument);
30907
31184
  #fontsChanged = () => {
30908
31185
  if (this.#disposed) return;
30909
31186
  this.#canvas.invalidate();
@@ -31155,6 +31432,10 @@ var VisioViewerElement = class extends BaseElement {
31155
31432
  })
31156
31433
  });
31157
31434
  this.#disposeInputs = this.#wireInputs();
31435
+ this.controller.setBeforeParse((bytes) => this.#webfonts.prefetch(bytes));
31436
+ this.controller.setBeforeShow(
31437
+ (document2) => this.#webfonts.base() === null ? void 0 : this.#webfonts.load(document2)
31438
+ );
31158
31439
  this.#unsubscribe = this.controller.subscribe((state) => this.#render(state));
31159
31440
  this.#eventUnsubscribe = this.controller.onEvent((name, detail) => {
31160
31441
  this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
@@ -31168,6 +31449,7 @@ var VisioViewerElement = class extends BaseElement {
31168
31449
  this.#fileName = "";
31169
31450
  this.#forgetOpenedFile();
31170
31451
  this.controller.setDocument(value);
31452
+ void this.#refreshWebfonts();
31171
31453
  }
31172
31454
  get pageIndex() {
31173
31455
  return this.controller.state.pageIndex;
@@ -31255,6 +31537,13 @@ var VisioViewerElement = class extends BaseElement {
31255
31537
  this.#render(this.controller.state);
31256
31538
  this.#recover.opened();
31257
31539
  }
31540
+ /** Load the open drawing's webfonts, then redraw it once they arrived (relayout, same view). */
31541
+ async #refreshWebfonts() {
31542
+ const readiness = await this.#webfonts.load(this.controller.state.document);
31543
+ if (!readiness || this.#disposed) return;
31544
+ this.#canvas.invalidate();
31545
+ this.#render(this.controller.state);
31546
+ }
31258
31547
  #forgetOpenedFile() {
31259
31548
  this.#openedStorage = void 0;
31260
31549
  this.controller.setFileReadOnly(false);
@@ -31452,6 +31741,7 @@ var VisioViewerElement = class extends BaseElement {
31452
31741
  this.#disposeInputs();
31453
31742
  this.#fontEvents?.removeEventListener("loadingdone", this.#fontsChanged);
31454
31743
  this.#fontEvents = void 0;
31744
+ this.#webfonts.remove();
31455
31745
  this.#canvas.dispose();
31456
31746
  this.#unsubscribe();
31457
31747
  this.#eventUnsubscribe();
@@ -31461,9 +31751,20 @@ var VisioViewerElement = class extends BaseElement {
31461
31751
  attributeChangedCallback() {
31462
31752
  this.#localizeRibbon();
31463
31753
  }
31754
+ /** The Trust Center in the display language, locked while the host set `googleFonts`. */
31755
+ #syncTrust() {
31756
+ this.#profile?.setTrust(
31757
+ normalizeVisioLocale(this.#locale()),
31758
+ fontDownloadLock(this.#webfonts.option)
31759
+ );
31760
+ }
31464
31761
  /** Put the File > Options behaviour settings to work on the pieces they govern. */
31465
31762
  #applyBehaviour() {
31466
31763
  const behaviour = this.#behaviour;
31764
+ if (this.#webfonts.readerAllows !== behaviour.allowFontDownloads) {
31765
+ this.#webfonts.readerAllows = behaviour.allowFontDownloads;
31766
+ void this.#refreshWebfonts();
31767
+ }
31467
31768
  this.controller.undoLevels = behaviour.undoLevels;
31468
31769
  this.#edit.spellcheck = behaviour.checkSpelling;
31469
31770
  this.#edit.autoSize = behaviour.autoSizeText;
@@ -31499,6 +31800,7 @@ var VisioViewerElement = class extends BaseElement {
31499
31800
  restoreScreenTips(this.#toolbar);
31500
31801
  localizeRibbon(this.#toolbar, this.#locale());
31501
31802
  this.#backstage?.localize();
31803
+ this.#syncTrust();
31502
31804
  this.#shareUi.relocalize();
31503
31805
  applyScreenTips(this.#toolbar, this.#behaviour.screenTips);
31504
31806
  this.#overflow.refit();
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Excel's File > Options > Trust Center: PowerPoint's Security settings section with the one
3
+ * setting Excel has, "Download fonts that are not installed or embedded". When the host set
4
+ * `googleFonts` the toggle is read-only and shows the host's value.
5
+ */
6
+ import type { OfficeOptionCategory, OptionsContext } from '../../controls.js';
7
+ /** The option key of the font download toggle. */
8
+ export declare const FONT_DOWNLOADS_OPTION = "allowFontDownloads";
9
+ export declare function trustCategory(context: OptionsContext, locked: boolean): OfficeOptionCategory;
@@ -20,6 +20,10 @@ export interface EditorOptions {
20
20
  author: string;
21
21
  calculation: CalculationMode;
22
22
  iteration: IterationSettings;
23
+ /** Trust Center: download missing fonts (the host's locked value, or the reader's choice). */
24
+ allowFontDownloads?: boolean;
25
+ /** The host set `googleFonts`, so the font download toggle is read-only. */
26
+ fontDownloadsLocked?: boolean;
23
27
  }
24
28
  /** What the File view needs from the editor; every value is read when a page opens. */
25
29
  export interface BackstageHost {
@@ -14,6 +14,7 @@ import { type EditorLocale } from 'ooxml-core/xlsx/ui';
14
14
  import type { CalculationMode } from './backstage/index.js';
15
15
  import type { SurfaceHostActions } from './surface-actions.js';
16
16
  import { CalcPreparation } from './calc-preparation.js';
17
+ import { XlsxWebfonts } from './webfonts.js';
17
18
  import { type XlsxCollaboration } from './collaboration.js';
18
19
  import type { EditorThemeMode, XlsxTheme } from './theme/index.js';
19
20
  import type { ExcelCustomization } from 'ooxml-core/xlsx/ui';
@@ -76,6 +77,8 @@ export declare class EditorCore {
76
77
  readonly collab: XlsxCollaboration;
77
78
  /** Builds the formula graph in idle time after a workbook opens. */
78
79
  readonly calcPreparation: CalcPreparation;
80
+ /** The `googleFonts` webfont fallback (off unless the host sets it). */
81
+ readonly webfonts: XlsxWebfonts;
79
82
  private gridController;
80
83
  private readonly modelListeners;
81
84
  private stopSession;