Skip to content

Commit f4a845a

Browse files
authored
docs(toolbar): clarify how fonts work in SuperDoc (#2848)
* docs(toolbar): clarify how fonts work in SuperDoc A .docx carries font names, not font data. Consumers often hit this when a document uses Cambria/Calibri/Aptos and the rendered text falls back to Helvetica in the browser. The existing docs were an empty redirect stub plus an inaccurate Info callout that claimed imported DOCX fonts auto-populate the toolbar dropdown (they don't). Rewrites the Font support getting-started page and the toolbar Font configuration section to separate two concerns cleanly: registration (selectability via `fonts`) vs. loading (real glyphs via `@font-face`). Adds a working alias example and a table of metric-compatible free substitutes for Office fonts. * docs(getting-started): keep fonts page as redirect stub Revert the expanded font-support page back to the one-line redirect stub. The real content already lives in the toolbar Font configuration section — the stub only needs the redirect target corrected from `/modules/toolbar#font-configuration` (which bounces to overview and has no matching anchor) to `/modules/toolbar/built-in#font-configuration`.
1 parent 5229852 commit f4a845a

2 files changed

Lines changed: 55 additions & 8 deletions

File tree

apps/docs/getting-started/fonts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
title: Font Support
33
---
44

5-
Loading toolbar <a href="/modules/toolbar#font-configuration">font config</a>...
5+
Loading toolbar <a href="/modules/toolbar/built-in#font-configuration">font config</a>...
66

7-
{(() => { window.location.href = '/modules/toolbar#font-configuration'; })()}
7+
{(() => { window.location.href = '/modules/toolbar/built-in#font-configuration'; })()}

apps/docs/modules/toolbar/built-in.mdx

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,24 +323,22 @@ Icons should be 24x24 viewBox SVGs with `fill="currentColor"` for proper theming
323323

324324
## Font configuration
325325

326+
The toolbar dropdown lists only what you register in `fonts`. Imported documents don't auto-populate the list — if a user opens a `.docx` that uses Cambria and Cambria isn't registered, the current-selection indicator shows "Cambria" but the user can't pick it from the dropdown.
327+
326328
<ParamField path="fonts" type="Array">
327329
<Expandable title="Font object properties">
328330
<ParamField path="label" type="string" required>
329-
Display name
331+
Display name shown in the dropdown
330332
</ParamField>
331333
<ParamField path="key" type="string" required>
332-
Font-family CSS value
334+
Font-family CSS value applied to text
333335
</ParamField>
334336
<ParamField path="fontWeight" type="number">
335337
Font weight
336338
</ParamField>
337339
</Expandable>
338340
</ParamField>
339341

340-
<Info>
341-
SuperDoc does not load fonts automatically. Custom fonts from imported DOCX files will display in the toolbar, but won't be selectable unless you load them in your application (via CSS `@font-face`, Google Fonts, etc.) and add them to the `fonts` array.
342-
</Info>
343-
344342
```javascript
345343
fonts: [
346344
{ label: 'Arial', key: 'Arial' },
@@ -349,6 +347,55 @@ fonts: [
349347
]
350348
```
351349

350+
<Info>
351+
Registering a font in `fonts` makes it **selectable**. It doesn't load any font files. To make the font actually render with its real glyphs, load it on your host page via `@font-face` or a `<link>` to a font service. Fonts the browser can't find fall back to the CSS generic.
352+
</Info>
353+
354+
### Loading web fonts
355+
356+
Any font loaded on your host page is available inside the editor. Load it, then register it in `fonts`:
357+
358+
```html
359+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter&display=swap" />
360+
```
361+
362+
```javascript
363+
modules: {
364+
toolbar: {
365+
fonts: [{ label: 'Inter', key: 'Inter, sans-serif' }]
366+
}
367+
}
368+
```
369+
370+
### Substituting Microsoft Office fonts
371+
372+
Most `.docx` files use Cambria, Calibri, or Aptos — fonts bundled with Word on desktop but not present in browsers. Google hosts free metric-compatible replacements:
373+
374+
| Office font | Free substitute | Notes |
375+
|---|---|---|
376+
| Calibri | [Carlito](https://fonts.google.com/specimen/Carlito) | Sans-serif, metric-identical — designed as a direct drop-in |
377+
| Cambria | [Tinos](https://fonts.google.com/specimen/Tinos) or [Gelasio](https://fonts.google.com/specimen/Gelasio) | Serif |
378+
| Aptos | [Carlito](https://fonts.google.com/specimen/Carlito) or [Inter](https://fonts.google.com/specimen/Inter) | Sans-serif — no free metric-identical match exists yet |
379+
380+
Download the `.woff2` files from Google Fonts, host them with your app, and alias each substitute to the original Word name via `@font-face`. The browser will then render real Carlito/Tinos glyphs whenever the document asks for Calibri/Cambria — no document or SuperDoc changes needed.
381+
382+
```html
383+
<style>
384+
@font-face {
385+
font-family: 'Calibri';
386+
src: url('/fonts/Carlito-Regular.woff2') format('woff2');
387+
font-display: swap;
388+
}
389+
@font-face {
390+
font-family: 'Cambria';
391+
src: url('/fonts/Tinos-Regular.woff2') format('woff2');
392+
font-display: swap;
393+
}
394+
</style>
395+
```
396+
397+
Self-hosting the `.woff2` files is more reliable than linking to Google Fonts CDN URLs directly — those URLs change when Google updates a font version.
398+
352399
## Responsive behavior
353400

354401
The toolbar adapts at these widths:

0 commit comments

Comments
 (0)