From 71c751be9c3498c01a56d683434f91ac2cb6c2e4 Mon Sep 17 00:00:00 2001 From: Logan Besecker <3487677+lbesecker195@users.noreply.github.com> Date: Mon, 14 Sep 2026 01:24:29 -0700 Subject: [PATCH] docs: document the font option of table cells The cell options only said "Font options for the cell". Describe src, family and size, show how to use a registered font, and note how the font of a cell combines with its row and column. Fixes #1737 Co-Authored-By: Claude Opus 5 --- docs/table.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/table.md b/docs/table.md index 81b88c6c3..7d4e2cfbc 100644 --- a/docs/table.md +++ b/docs/table.md @@ -351,6 +351,9 @@ is added to the document. This way, any calls to `text` or `table` will be place - `border` - The border for the cell (default `1pt`) - `borderColor` - The border colors for the cell (default `black`) - `font` - Font options for the cell + - `src` - The font to use: the name of a font registered with `doc.registerFont()`, a standard font name such as `Helvetica-Bold`, or a font file path or buffer. This is the same as the first argument of `doc.font()` + - `family` - The name of the font to use from a collection (`.ttc`, `.dfont`) or variable font given in `src`, like the second argument of `doc.font()`. It only applies when there is a `src` on the cell, its row or its column, so use `src` for a registered font name + - `size` - The font size - `backgroundColor` - Set the background color of the cell - `align` - The alignment of the cell text (default `{x: 'left', y: 'top'}`) - `textStroke` - The text stroke (default `0`) @@ -360,6 +363,18 @@ is added to the document. This way, any calls to `text` or `table` will be place - `textOptions` - Sets any text options you wish to provide (such as rotation) - `debug` - Whether to show the debug lines for the cell (default `false`) +A registered font can be used by its name: + + doc.registerFont('Icons', 'fonts/fa-regular-400.ttf'); + + doc.table({ + data: [ + ['Label', { text: '\uf118', font: { src: 'Icons', size: 20 } }] + ] + }) + +The `font` of a cell is combined with the `font` of its row and column. A more specific `src` also replaces the `family`, while a `family` or `size` on its own refines what is inherited. + ## Column options Extends the [cell options](#cell-options) above with: