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
Copy file name to clipboardExpand all lines: apps/docs/getting-started/fonts.mdx
+52-5Lines changed: 52 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,66 @@ keywords: 'fonts, font loading, calibri, cambria, aptos, font fallback, custom f
6
6
7
7
SuperDoc keeps the font name from the Word document. When SuperDoc ships an approved fallback for that font, it renders with the fallback but keeps the original name for export. When no fallback is available, load the real font in your app.
8
8
9
-
## Load fonts in your app
9
+
## Bundled fallback fonts
10
10
11
-
Fonts are your host page's responsibility. `@font-face`, a hosted stylesheet, or a font CDN: anything the browser can resolve.
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
+
13
+
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
+
15
+
### Recommended: the `@superdoc/fonts` package
16
+
17
+
Install the optional pack and pass it. Your bundler (Vite, Webpack, Next, Nuxt) emits the files and rewrites the URLs. No copy step. No path config.
18
+
19
+
```bash
20
+
npm install @superdoc/fonts
21
+
```
22
+
23
+
```js
24
+
import { SuperDoc } from'superdoc';
25
+
import { superdocFonts } from'@superdoc/fonts';
26
+
27
+
newSuperDoc({
28
+
selector:'#editor',
29
+
document:'contract.docx',
30
+
fonts: superdocFonts,
31
+
});
32
+
```
33
+
34
+
### Alternative: host the files yourself
35
+
36
+
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/`.
37
+
38
+
```js
39
+
newSuperDoc({
40
+
selector:'#editor',
41
+
document:'contract.docx',
42
+
fonts: { assetBaseUrl:'/fonts/' },
43
+
});
44
+
```
45
+
46
+
Use `fonts.resolveAssetUrl` instead for signed or versioned URLs.
47
+
48
+
### CDN script build
49
+
50
+
The CDN build loads the fonts from a path relative to the script. Loading from a public CDN (jsDelivr or unpkg) needs no setup: the fonts resolve to `superdoc@<version>/dist/fonts/...` automatically. If you self-host `superdoc.min.js`, serve its `dist/fonts/` folder beside it.
51
+
52
+
### Skipping the pack
53
+
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.
55
+
56
+
## Load your own fonts
57
+
58
+
For a brand font, a licensed font, or any family SuperDoc does not ship a fallback for, load the real file yourself. Use `@font-face`, a hosted stylesheet, or a font CDN. Anything the browser can resolve.
For custom or licensed fonts, load the real file yourself. SuperDoc's built-in fallbacks cover only the fonts it ships and verifies.
68
+
SuperDoc's built-in fallbacks cover only the fonts it ships and verifies. For everything else, the real file is yours to provide. To register it through SuperDoc instead of CSS, pass it in `fonts.families` (which composes with `@superdoc/fonts`).
Copy file name to clipboardExpand all lines: apps/docs/getting-started/quickstart.mdx
+10-3Lines changed: 10 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,12 @@ By the end of this page you'll have a working DOCX editor in your app: load a Wo
14
14
<Tabs>
15
15
<Tabtitle="npm">
16
16
```bash
17
-
npm install superdoc
17
+
npm install superdoc @superdoc/fonts
18
18
```
19
19
</Tab>
20
20
<Tabtitle="React">
21
21
```bash
22
-
npm install @superdoc-dev/react
22
+
npm install @superdoc-dev/react @superdoc/fonts
23
23
```
24
24
</Tab>
25
25
<Tabtitle="CDN">
@@ -31,6 +31,10 @@ By the end of this page you'll have a working DOCX editor in your app: load a Wo
31
31
</Tab>
32
32
</Tabs>
33
33
34
+
<Info>
35
+
`@superdoc/fonts` serves SuperDoc's bundled fallback fonts so Word fonts render without copying assets. It's optional. See [Font support](/getting-started/fonts).
36
+
</Info>
37
+
34
38
## 2. Render the editor
35
39
36
40
<Tabs>
@@ -40,21 +44,24 @@ By the end of this page you'll have a working DOCX editor in your app: load a Wo
0 commit comments