# Fonts in Documents

> Supply fonts with a TX Sheet Control document at load time, map font names with substitutions, and embed used fonts in TXWB, ODS and XLSX with embedUsedFonts.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Sheet Control > Document Processing > Fonts in Documents
- **892 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/document-processing/document-fonts/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/document-processing/document-fonts/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/document-processing/document-fonts/llms-full.txt

---

A workbook stores the names of its fonts in its cell styles, not the fonts themselves. TX Sheet Control renders it with the fonts of the deployment, as [Font Handling](https://docs.textcontrol.com/tx-sheet-control/deployment/fonts/llms-full.txt) describes. Beyond that, you can supply fonts with a single document when you load it, map font names to other families, and embed the used fonts in the files you save, so that another TX Sheet Control application shows the document with the same fonts.

### Fonts a Document Brings

When TX Sheet Control loads a file, it reads the fonts the file contains:

- **ODS** files with local font-face references and embedded TrueType fonts.
- **XLSX** files with font files in `xl/fonts` and the font catalog that TX Sheet Control writes.
- **TXWB** files with the fonts in the extension `com.txtextcontrol.fonts`.

The fonts of a document belong to that document only. They are not installed on the computer, and closing or replacing the document removes them. Input is limited to 64 font faces, 32 MiB per face and 64 MiB in total. Embedding flags of the fonts are checked, and fonts that cannot be used produce import warnings.

### Supply Fonts When Loading

Pass fonts in the `fonts` load option:

- **`sources`** lists complete font faces as Base64 bytes, each with its family and its bold and italic style.
- **`resolve`**, in JavaScript and TypeScript, is an asynchronous callback that TX Sheet Control calls for each missing family or incomplete character set. It receives the family, the style, the text and the reason. Loading waits for its results before it replaces the current document.
- **`substitutions`** maps a font name of the workbook to a deployed or supplied family, without changing the cell styles.

In .NET, pass `DocumentFontOptions` in `LoadOptions.Fonts`.

```typescript
await editor.load(inputBytes, StreamType.OpenDocumentSpreadsheet, {
    fonts: {
        resolve: async request => ({
            family: request.family,
            bold: request.bold,
            italic: request.italic,
            base64: await fontProvider(request)
        })
    }
});
```

`fontProvider` stands for a function of your application that returns the Base64 bytes of a licensed font. When a supplied font lacks a character, TX Sheet Control takes it from a fallback font, also for text added later by editing or mail merge.

### Embed the Used Fonts When Saving

Set `embedUsedFonts: true` in the save options, or `EmbedUsedFonts = true` in the .NET `SaveOptions`, to include the font files the document uses in a TXWB, ODS or XLSX file. The option is `false` by default, and PDF files always embed their fonts.

```javascript
const txwb = await control.save(StreamType.InternalWorkbookFormat, { embedUsedFonts: true });
```

- **What is embedded.** The fonts used for rendering: those of the document, of the editor's catalog or of the server's font folder, including the default font. When a cell uses Arial and Arial is replaced with Liberation Sans, the file carries Liberation Sans and records Arial as its original name. A deployed Arial takes precedence.
- **Where the fonts go.** TXWB stores them in the extension `com.txtextcontrol.fonts`, XLSX in `xl/fonts`. Microsoft Excel does not use these fonts; they are read by TX Sheet Control.
- **The size.** Each embedded font adds its full file. A TXWB file with one cell in Liberation Sans grows from about 1 KB to about 400 KB.
- **The open document.** The option changes only the saved file, not the cells, the styles or the fonts of the open document. A `Workbook` created without an editor or a server control has no font host and needs fonts supplied with `fonts.sources` instead.

### Next Steps

- [Font Handling](https://docs.textcontrol.com/tx-sheet-control/deployment/fonts/llms-full.txt): the fonts of the deployment and the replacement fonts.
- [Custom Fonts](https://docs.textcontrol.com/tx-sheet-control/deployment/custom-fonts/llms-full.txt): add fonts to the editor and the server for every document.
- [Loading and Saving Workbooks](https://docs.textcontrol.com/tx-sheet-control/document-processing/load-save/llms-full.txt): the load and save options of every format.

---

## Nearby

- **Previous:** [OpenDocument Spreadsheet](https://docs.textcontrol.com/tx-sheet-control/document-processing/ods/llms-full.txt)
- **Next:** [PDF Export](https://docs.textcontrol.com/tx-sheet-control/pdf/llms-full.txt)
