You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(fonts): config-gated bundled font availability and curation (SD-3441)
Without a configured pack SuperDoc advertises and renders only a safe baseline (one font per CSS generic), so an unconfigured app never fetches a bundled substitute it cannot serve. Configuring the pack (@superdoc/fonts, fonts.assetBaseUrl/resolveAssetUrl, or the CDN build) lights up the full reviewed set, gated by config presence rather than a runtime probe.
createSuperDocFonts({ include / exclude }) curates the pack by Word family name, validated against the offerings so a typo fails fast at setup time. Activation is document-scoped in the resolver and offerings and folded into the resolver signature, so a no-pack or curated document never reuses a full-pack document's measures. A CI drift check keeps the generated curatable list in sync with the offerings.
Copy file name to clipboardExpand all lines: apps/docs/advanced/headless-toolbar.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -329,7 +329,7 @@ Snapshot values match the format you pass to `execute()`. What you read is what
329
329
330
330
For a font dropdown that also includes fonts used by the active document, use `useSuperDocFontOptions()` from `superdoc/ui/react` or `ui.fonts` from `superdoc/ui`.
331
331
332
-
`DEFAULT_FONT_FAMILY_OPTIONS`mirrors the built-in picker list. It can include bundled font choices beyond the core defaults; use the font report when you need per-font rendering details.
332
+
`DEFAULT_FONT_FAMILY_OPTIONS`is the conservative no-pack baseline - one Word font per CSS generic (Arial, Times New Roman, Courier New). For the full pack plus any curation and the active document's fonts, use `useSuperDocFontOptions()` from `superdoc/ui/react` or `ui.fonts` from `superdoc/ui`; they reflect the configured pack at runtime, which a static constant cannot.
333
333
334
334
For font family, font size, and other commands that apply to selected text, prefer a button menu or popover that prevents `mousedown` from moving focus out of the editor. Native selects can visually clear the editor selection while their menu is open.
335
335
@@ -361,7 +361,7 @@ const {
361
361
362
362
| Constant | Contents |
363
363
|----------|----------|
364
-
|`DEFAULT_FONT_FAMILY_OPTIONS`|Built-in picker list. Includes strict defaults plus explicitly advertised bundled fallback choices. |
364
+
|`DEFAULT_FONT_FAMILY_OPTIONS`|Conservative no-pack baseline: one font per CSS generic (Arial, Times New Roman, Courier New). Configure the pack for the full list, or use `useSuperDocFontOptions()` / `ui.fonts`. |
365
365
|`DEFAULT_FONT_SIZE_OPTIONS`| 8pt through 96pt (14 sizes) |
366
366
|`DEFAULT_TEXT_ALIGN_OPTIONS`| left, center, right, justify |
Copy file name to clipboardExpand all lines: apps/docs/editor/custom-ui/toolbar-and-commands.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ function FontSizePicker() {
101
101
102
102
## Font family picker
103
103
104
-
Use `useSuperDocFontOptions()` for a custom font dropdown. It returns the built-in defaults plus fonts used by the active document, sorted alphabetically.
104
+
Use `useSuperDocFontOptions()` for a custom font dropdown. It returns the fonts SuperDoc can render plus fonts used by the active document, sorted alphabetically. Without a configured font pack that is the conservative baseline; configure the pack (`@superdoc/fonts`, or `fonts.assetBaseUrl`) and it returns the full set, minus anything curated with `createSuperDocFonts`.
105
105
106
106
`label` is what you show. `value` is what you pass to the `font-family` command. `previewFamily` is only for rendering the option row.
Copy file name to clipboardExpand all lines: apps/docs/getting-started/fonts.mdx
+29-2Lines changed: 29 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ SuperDoc keeps the font name from the Word document. When SuperDoc ships an appr
10
10
11
11
A Word document asks for fonts like Calibri, Cambria, and Times New Roman. Most are proprietary, or not installed on every machine. SuperDoc renders them with reviewed open substitutes that match the metrics: Carlito for Calibri, Liberation Serif for Times New Roman, and more. The original name is kept for export.
12
12
13
+
Without the pack, the toolbar lists one widely available font per CSS generic: Arial for sans-serif, Times New Roman for serif, Courier New for monospace. Each is applied with that generic as a fallback, so it renders acceptably even where the exact font is absent - a readable floor, not an exact-typography guarantee. Wire the pack and the toolbar lists the full reviewed set, and SuperDoc renders the substitutes everywhere. Either way, the Word font name is kept for export.
14
+
13
15
These substitutes are real `.woff2` files. The browser fetches them from a URL. Installing SuperDoc from npm puts them in `node_modules`, which does not serve them to the browser. So you tell your app where they live. Pick one path.
14
16
15
17
### Recommended: the `@superdoc/fonts` package
@@ -31,6 +33,30 @@ new SuperDoc({
31
33
});
32
34
```
33
35
36
+
### Choose which bundled fonts
37
+
38
+
By default the pack enables every reviewed font. To narrow it, use `createSuperDocFonts` and name the families. Think in Word names (`Calibri`, not the substitute `Carlito`).
Curation changes the toolbar list and which families SuperDoc substitutes. It does not touch your own licensed fonts (see [Load your own fonts](#load-your-own-fonts)). A curated-out family a document still uses keeps its Word name for export and renders with a system font.
59
+
34
60
### Alternative: host the files yourself
35
61
36
62
Serve the `.woff2` from your own path or a CDN, then point SuperDoc at them. The files ship in the package at `node_modules/superdoc/dist/fonts/`.
@@ -51,7 +77,7 @@ The CDN build loads the fonts from a path relative to the script. Loading from a
51
77
52
78
### Skipping the pack
53
79
54
-
The pack is optional. Skip it if you load your own fonts for every family, or only need fonts the user's OS already has. When the bundled `.woff2` cannot be fetched, SuperDoc logs a one-time warning and falls back to the original font name. On a machine without that font, the text renders in a system fallback, so it can look unchanged.
80
+
The pack is optional. Skip it if you load your own fonts for every family, or only need fonts the user's OS already has. With no pack configured the toolbar shows the baseline and documents render with system fonts, quietly. If you do wire the pack but the `.woff2` cannot be fetched, SuperDoc logs a one-time warning that names the fix; until then text falls back to the original font name, so it can look unchanged on a machine that lacks it.
55
81
56
82
## Load your own fonts
57
83
@@ -69,7 +95,7 @@ SuperDoc's built-in fallbacks cover only the fonts it ships and verifies. For ev
69
95
70
96
## Toolbar font list
71
97
72
-
The built-in toolbar lists SuperDoc's defaults plus fonts used by the active document, sorted alphabetically. If you pass `modules.toolbar.fonts`, that custom list replaces the default list.
98
+
The built-in toolbar lists the fonts SuperDoc can render, plus the fonts the active document uses, sorted alphabetically. With no pack configured that is the baseline of one font per CSS generic (Arial, Times New Roman, Courier New); with the pack it is the full reviewed set, minus anything you curated out with `createSuperDocFonts`. If you pass `modules.toolbar.fonts`, that custom list replaces it entirely.
73
99
74
100
Each custom entry is a `{ label, key }` pair where `key` is the CSS `font-family` value:
75
101
@@ -108,6 +134,7 @@ editor.doc.format.apply({
108
134
109
135
-**Font name preserved, browser falls back.** SuperDoc keeps the DOCX font name. If no bundled fallback or loaded real font exists, the browser chooses its own fallback.
110
136
-**Custom toolbar list hides document fonts.** Passing `modules.toolbar.fonts` replaces the built-in list. Include every option you want users to pick.
137
+
-**Not every bundled family ships every weight and style.** A few substitutes are a single face. For a bold or italic run the substitute lacks, SuperDoc renders the faces it has and leaves the missing ones to the browser's fallback rather than synthesizing a face, so spacing stays predictable.
111
138
-**Office font licensing.** Calibri, Cambria, and Aptos are licensed Microsoft fonts. Self-hosting the real files requires a license.
console.log('[@superdoc/fonts] font-system source not present (standalone install); skipping curation-drift check');
19
+
process.exit(0);
20
+
}
21
+
22
+
// eslint-disable-next-line import-x/no-relative-packages -- build-only script (not shipped); @superdoc/fonts stays a dependency-free runtime package and font-system exposes no /src export, so reading its source relatively here is intentional
'[@superdoc/fonts] font-system source not present (standalone install); kept committed src/bundled-families.ts',
20
+
);
21
+
process.exit(0);
22
+
}
23
+
24
+
// eslint-disable-next-line import-x/no-relative-packages -- build-only script (not shipped); @superdoc/fonts stays a dependency-free runtime package and font-system exposes no /src export, so reading its source relatively here is intentional
0 commit comments