@openpresentation/opf 0.34.0 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +14 -14
- package/dist/{chunk-F6BXO4AI.js → chunk-2B6GLT2O.js} +1 -1
- package/dist/{chunk-RUV7CCE6.js → chunk-6PMXVP5G.js} +5 -5
- package/dist/{chunk-DQ7QYOUV.js → chunk-AAWHOCXS.js} +1 -1
- package/dist/{chunk-WMFT5R7I.js → chunk-ABA2D6X5.js} +2 -2
- package/dist/{chunk-FAXO3SUE.js → chunk-AEHDXNZX.js} +4 -1
- package/dist/{chunk-HUGVYHZ2.js → chunk-AGYPRTEC.js} +1 -1
- package/dist/{chunk-36DLVJGW.js → chunk-CQXBGZQP.js} +4 -4
- package/dist/{chunk-3THGTDL2.js → chunk-FCSYIBVR.js} +1 -1
- package/dist/{chunk-42JBXJKW.js → chunk-L3MCLD3X.js} +1 -1
- package/dist/{chunk-QGTJF7HV.js → chunk-MAFJ5O2D.js} +5 -5
- package/dist/{chunk-FIQMAIZV.js → chunk-MUILZGRY.js} +3 -3
- package/dist/{chunk-QGJVOPLG.js → chunk-SR6T4LKI.js} +1 -1
- package/dist/{chunk-2HX4BGAS.js → chunk-X72WPTST.js} +3 -3
- package/dist/{chunk-U7TYSPYM.js → chunk-XLSWZSQS.js} +1 -1
- package/dist/{conversion-CMBGOTAC.js → conversion-CSQ5EHD2.js} +14 -14
- package/dist/{conversion-B_5AKTYQ.d.ts → conversion-CyNRlWGw.d.ts} +2 -2
- package/dist/convert.js +5 -5
- package/dist/deck.js +8 -8
- package/dist/diff.js +2 -2
- package/dist/docs.js +5 -5
- package/dist/ids.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -17
- package/dist/markdown.js +6 -6
- package/dist/node-engine.d.ts +2 -2
- package/dist/node-engine.js +16 -16
- package/dist/pagination.js +2 -2
- package/dist/patch.js +1 -1
- package/dist/schema.js +1 -1
- package/dist/source.js +8 -8
- package/dist/validator.js +1 -1
- package/dist/yaml.js +4 -4
- package/package.json +5 -5
package/dist/docs.js
CHANGED
|
@@ -36,7 +36,7 @@ var docsData = Object.freeze([
|
|
|
36
36
|
"slug": "cli",
|
|
37
37
|
"file": "docs/cli.md",
|
|
38
38
|
"title": "The `opf` CLI",
|
|
39
|
-
"markdown": '# The `opf` CLI\n\nThe CLI (`@openpresentation/cli`, binary `opf`, Node 22 or later; verified on Node 24) creates, checks, edits, converts and\ninspects decks (see [its README](../packages/cli/README.md)). `opf validate` is the one checker ([validate](validate.md)).\n`opf convert` is the one command that changes formats: a deck form, PDF, PPTX, PNG and SVG. Every command runs core\'s\nfunctions, the ones applications call from [`@openpresentation/opf`](node.md); the commands add the flags, the JSON report and\nthe exit codes.\n\nEverything is deterministic and local: no network, no model, no telemetry, no system fonts. The same document, options and\ninstalled package versions give the same bytes on every operating system.\n\n## Commands\n\n| Command | What it does |\n| --- | --- |\n| `opf create [output] [--title <text> \\| --example <slug>]` | A one-slide starter deck, or one of core\'s bundled examples (`opf catalog examples` lists them). |\n| `opf validate <file\\|dir\\|->...` | The one checker: format, references, policy, accessibility, layout, content. Several files, folders and stdin in one run; `--format json\\|text\\|github`. |\n| `opf convert <input> <output>` | Any change of format: `.json`, `.opf.yaml`, `.opf.md` (and a plain `.md` input), `.pptx`, `.pdf`, `.png`, `.svg`, `.zip`, or stdin and stdout. |\n| `opf edit <file> [output] --patch <patch>` | A JSON Patch, applied whole or not at all, the result checked. |\n| `opf format <file>... [output]` | Canonical key order and layout, in the form the file has. |\n| `opf diff <a> <b>` | What changed between two decks (`--format text\\|json\\|patch`). |\n| `opf merge <base> <ours> <theirs> [output]` | A three-way merge; conflicts are listed. |\n| `opf stats <file>` | Neutral facts about a deck (`--format json\\|text`). |\n| `opf paginate <input> [output]` | Overflowing slides split into continuation slides, measured with the renderer\'s fonts when it is installed. |\n| `opf embed <input> [output]` | The catalog records a deck references, copied into it. |\n| `opf fill <template> <data> [output]` | A template\'s variables filled: one deck per record (the output is a name pattern), or `--combine`. The second argument is always the data (`-` for stdin). |\n| `opf ingest <data> [output] --as table\\|chart` | CSV, TSV or JSON rows as a table or chart slide, alone or added `--into` a deck. |\n| `opf doctor [deck]` | Which formats this install can write, and the one command that installs what is missing. |\n| `opf schemas`, `opf schema [name] [pointer]` | The OPF schemas. `opf schemas` lists the `@openpresentation/opf` version each came from next to its id, and `opf --version` names the schema id ([schema versioning](schema-versioning.md)). |\n| `opf catalogs`, `opf catalog <kind> [id]`, `opf catalog examples [slug]` | The pptx.gallery catalog (`@openpresentation/gallery`) and the bundled example decks. |\n| `opf skills <install\\|update\\|status>` | The six bundled agent skills. |\n| `opf mcp` | Runs the MCP server of `@openpresentation/mcp` on stdio when that package is installed; otherwise prints `npx -y @openpresentation/mcp` and exits 2. See [the MCP server](mcp.md). |\n\n`opf <command> --help` (or `-h`, or `opf help <command>`) prints a command\'s flags and examples.\n\nRemoved in 0.18 (each is a usage error, exit 2, that names its replacement): `opf render`, `opf export`, `opf import`,\n`opf from-md`, `opf to-md`, `opf from-yaml` and `opf to-yaml` (all `opf convert`), `opf create --from` (`opf convert`), and the\nflags `--output`, `--out`, `--out-dir` and `--name` (a positional output), `--input-format` (`--from`), `--json` (reports are\nJSON), `--dry-run` (stdout), `--data` (fill\'s second argument) and the deck values of `--format` (`--to`).\n\n## One output convention\n\nEvery command that writes a deck takes the same arguments:\n\n| Form | Meaning |\n| --- | --- |\n| `opf embed deck.opf.json` | No output: the deck goes to stdout, the report to stderr. `-` says the same. |\n| `opf embed deck.opf.json out.opf.json` | An output after the inputs: written atomically (a temporary sibling, then a rename); an existing file needs `--force`. |\n| `opf embed deck.opf.json -i` | `-i` (`--in-place`) rewrites the input, refusing if it changed since it was read. Not for stdin, and not with an output. |\n| `opf embed deck.opf.json --check` | Writes nothing and exits 1 when the command would change something: `format --check` (not canonical), `embed --check` (not self-contained) and `paginate --check` (a slide overflows). |\n\nThe form written is the output\'s extension (`.json`, `.opf.yaml`/`.yml`, `.opf.md`), else `--to json|yaml|md`, else the form\nthat was read. An existing output is refused before anything is printed or written.\n\n`opf fill` writes one deck per record through a file name pattern: `{n}` is the record number (padded to the width of the largest, the rule of `opf convert`), `{column}` a slug of that\ncolumn\'s value (`opf fill t.opf.md clients.csv decks/qbr-{client}.opf.md`); `--combine` writes one deck with every record\'s slides.\n\n## What each flag means\n\n| Flag | Meaning |\n| --- | --- |\n| `--format json\\|text\\|github\\|patch` | The report format only: `json` (the default), `text`, `github` (validate\'s workflow annotations) or `patch` (diff\'s JSON Patch). |\n| `--from json\\|yaml\\|md` | The form of a deck input: stdin, and names that say none. Without it, a name ending `.json`, `.opf.yaml`, `.yaml`, `.yml` or `.opf.md` says the form, and text that starts with `{` or `[` is JSON; anything else is a usage error that asks for `--from yaml\\|md`. `opf convert` also takes `--from pptx`. |\n| `--to json\\|yaml\\|md` | The form of a deck output, for stdout and names that say none. `opf convert` also takes `pdf`, `pptx`, `png`, `svg` and `zip`. A `--to` that disagrees with the output\'s extension is refused. |\n| `--data-format csv\\|tsv\\|json` | The form of the data of `opf fill` and `opf ingest` (default: the extension, else JSON when it starts with `{` or `[`, else CSV). |\n| `--fail-on error\\|warning\\|info` | Findings at or above this severity fail the command (exit 1) and nothing is written (default `error`). |\n| `--force` | Replace an existing output. |\n\n## Install\n\n**Published set (2026-10-24):** CLI 0.26.1 (core `^0.26.1`, Gallery `^0.26.1`,\noptional renderer/PPTX `^0.26.1`) with core, renderer, PPTX, editor and Gallery 0.26.1. Use the complete pinned [quickstart installation](quickstart.md#versions) and its\nrequired font/converter peers.\n\nDeck forms (JSON, YAML, Markdown) need nothing beyond the CLI. PDF, PNG and SVG need `@openpresentation/opf-render`; PPTX output\nand `.pptx` input also need `@openpresentation/opf-pptx`. Both are **optional peer dependencies** of the CLI and of core (decision\nRR-27, below), loaded the first time a command needs them, from beside the CLI first and from the working directory second.\n\n`opf doctor` says what this install can write and prints the one command that installs the rest:\n\n```sh\nopf doctor --format text # per format: ready, or what is missing; then one install command\nopf doctor deck.opf.md # JSON; with a deck, a PDF needs sharp only when the deck has pictures\n```\n\nThe command matches the package manager that runs the CLI (`npm_config_user_agent`: npm, pnpm, yarn or bun) and the way the CLI\nis installed: global (`npm install -g ...`), a project (`npm install ...`), or one npx run (`npx -p @openpresentation/cli -p ... opf <command>`).\nA conversion that misses a peer exits 2 with `code: "peer-not-installed"` (or `peer-too-old`), and its `install` field and message\ncarry that one command for the format asked for. What each output needs beside `@openpresentation/opf-render`:\n\n| Output | Also install |\n| --- | --- |\n| every drawn format (the office font pack) | `@expo-google-fonts/roboto@0.4.3 @expo-google-fonts/roboto-mono@0.4.2 @expo-google-fonts/caladea@0.4.2 @expo-google-fonts/arimo@0.4.3 @expo-google-fonts/tinos@0.4.2 @expo-google-fonts/cousine@0.4.3 @expo-google-fonts/gelasio@0.4.1 @expo-google-fonts/noto-sans@0.4.2` |\n| `png` | `@resvg/resvg-js@^2.6.2 sharp@^0.35.5` |\n| `pdf` | nothing for text in the default vector mode; `pdf-lib@^1.17.1` for `--raster`; `sharp@^0.35.5` when the deck has pictures |\n| `svg` | the fonts only |\n| `pptx`, a `.pptx` input | `@openpresentation/opf-pptx` |\n\n## From code\n\nThe engine the commands run is core\'s `@openpresentation/opf` in Node, which an application imports instead of spawning `opf`.\nIn Node, `validate`, `stats`, `paginate`, `embed` and `edit` register the gallery (`@openpresentation/gallery`) when a call names none, as the commands\ndo, so `opf validate deck` and `validate(deck)` agree:\n\n```ts\nimport * as opf from "@openpresentation/opf";\n\nawait opf.convert("deck.opf.md", "deck.pdf"); // opf convert deck.opf.md deck.pdf\nconst deck = await opf.open("deck.pptx"); // opf convert deck.pptx -\nconst { files } = await opf.convert(deck, { format: "png", scale: 2 }); // bytes, nothing written\nconst { presentation } = opf.edit(deck, patch); // opf edit deck --patch patch.json\nconst { decks } = opf.fill(template, csvText); // opf fill template data.csv out-{n}.opf.json\n```\n\nThe options are the flags in camel case (`--raster` is `raster: true`, `--fonts` is `fonts` (a folder or a list of folders),\n`--asset-dir` is `assetDir`, `--include-hidden` is `includeHidden`). The commands refuse an existing output without `--force`;\n`convert` replaces it unless `overwrite: false`. See [OPF files in Node](node.md).\n\n## `opf convert`\n\n```sh\nopf convert deck.opf.md deck.pdf\nopf convert deck.opf.md slides/deck.png --slides 1,3-5 --scale 2 # slides/deck-1.png, -3, -4, -5\nopf convert deck.opf.md "slides/slide-{n}.png" # slides/slide-1.png, slide-2.png, ... (always numbered)\nopf convert deck.opf.md slides.zip --to svg\nopf convert deck.pptx deck.opf.md --signals signals.json\nopf convert outline.md deck.opf.yaml # a plain .md input is OPF Markdown\nopf convert deck.opf.json deck.opf.yaml --schema-comment\nopf convert deck.opf.md - --to pdf > deck.pdf\n```\n\n| Output | Written as |\n| --- | --- |\n| `.pdf`, `.pptx` | one file |\n| `.png`, `.svg` | one file per slide beside the output, named after it: `slides/deck.png` writes `slides/deck-1.png`, `-2`, ... (the deck\'s slide numbers). One selected slide, or a one-slide deck, is written to the output itself. The extension is the format: `deck.png` is always PNG. With `{n}` in the output (`"slides/slide-{n}.png"`) the files are always numbered, even for one slide or one selected slide, and `{n}` is the deck\'s slide number (2 and 5 with `--slides 2,5`). `{n}` is the only placeholder: any other `{key}`, and `{n}` in `.pdf`, `.pptx`, `.zip` or a deck form, is a usage error (exit 2, `invalid-option`). |\n\nNumbers are padded with zeros to the width of the largest number written: `1`...`9` for slides 1 to 9, `01`...`99` up to 99, `001` from 100. With `--slides` the width comes from the largest slide selected (`--slides 2,5` gives `deck-2.png`, `deck-5.png`). The same rule pads `{n}` in `opf fill` (the largest record number) and the zip entries below.\n| `.zip` | one archive of the slides, its entries named as the plain `.png` and `.svg` files above (`slides.zip` holds `slides-1.png`, ...; always numbered, and no `{n}` in the archive\'s own name): PNG, or SVG with `--to svg`. Entries are stored with a fixed timestamp, so the archive is byte-identical everywhere. |\n| `.json`, `.opf.yaml`, `.yml`, `.opf.md` | the deck in that form |\n| `-` | stdout, with `--to`: one file (`pdf`, `pptx`, `zip`, a deck form, or one slide as `png` or `svg`) |\n\nA flag applies only when its format is involved; anywhere else it is a usage error (exit 2, `option-not-applicable`):\n\n| Involved | Flags |\n| --- | --- |\n| a Markdown input | `--split auto\\|rules\\|headings` (default `auto`: slides at `---` lines, and an outline with none at its `#` headings), `--title <text>` (the deck name unless the front matter sets one) |\n| a YAML input | `--aliases` (expand anchors, aliases and merge keys, at most 100) |\n| a `.pptx` input | `--signals <file>` (also write the raw per-shape layout and style signals, `fromPptx` with `signals: true`) |\n| a YAML output | `--schema-comment` (the `# yaml-language-server: $schema=...` line) |\n| a Markdown output | `--drop-unsupported` (leave out what the dialect has no syntax for and list it as loss, instead of embedding it as YAML in a fence) |\n| pdf, png, svg | `--slides 1,3-5` (one-based; `2-` to the end), `--include-hidden` |\n| pdf, png, svg, pptx | `--paginate` or `--keep-slides`, `--date YYYY-MM-DD`, `--fonts <dir>` (repeatable), `--asset-dir <dir>` |\n| png, raster pdf, pptx `--as images` | `--scale 0.1-8` (1 draws the 1280 x 720 reference slide at 1280 x 720 pixels; the pictures of `--as images` default to 2) |\n| pdf | `--raster` (each page a picture instead of selectable vector text) |\n| svg | `--text fonts\\|system\\|paths` (embed the faces the slide uses, none, or draw glyph outlines) |\n| pptx | `--charts auto\\|native\\|picture`, `--diagrams shapes\\|picture`, `--images compatible\\|preserve`, `--provenance full\\|references-only\\|none`, `--body-text measured\\|native`, `--slide-numbers static\\|live`, `--typefaces selected\\|safe`, `--as native\\|images` |\n\nA `.pptx` input is imported, checked and then written or drawn; `findings` holds both steps (`import/` rules from the importer).\nPer-slide images and the PDF skip slides marked `hidden: true` unless `--include-hidden`; slides named with `--slides` are always\nwritten, and the report lists the slides left out in `skippedHidden`. The PPTX keeps a hidden slide as a hidden slide.\n\n**Overfull slides (LH-90).** By default a slide of sibling blocks of one kind (eight timelines, five tables; each block may\nbring the notes that follow it) that overflows at its readability floor is drawn as several slides of the same layout, split\nbetween whole blocks, in every format, so the preview and the PPTX agree. Each such slide is a `render/slide-continued` or\n`pptx/slide-continued` warning and an entry of the report field `continued` (`slide`, the `slides` it became, `kind`, and\n`blocks` and `units` per slide); `--slides` and the file names count the slides drawn. `--paginate` splits every overflowing\nslide instead (as `opf paginate` does), and `--keep-slides` draws every slide as written, overlapping where it overflows.\n\n### PPTX text (RR-88, RR-91)\n\nBy default (`--body-text measured`) a wrapped paragraph becomes one text box per line, laid out exactly as the preview draws it, so editing a line in PowerPoint or Keynote does not reflow the rest. `--body-text native` opts in to whole paragraphs: a text, bullets or numbered-list region is one body that the application re-wraps when edited. In both modes every slide title is the Title placeholder (opf-pptx 0.34.0): a wrapped title is re-wrapped by the application where its line breaks are proven to match the preview, and otherwise keeps the preview\'s lines as fixed line breaks. What native mode cannot carry (groups, cards, nested or described lists, restarted numbering) stays measured and is reported as `native-body-fallback`. A slide recomposed as the automatic grid at the readability floor (LH-83) keeps its native bodies too (LH-91): the first binds to the Body placeholder of a variant of its layout named `<layout> (automatic grid)`. `--slide-numbers` decides a footer such as `{{slide.number}} / {{deck.slideCount}}`: `live` (the default since RR-102) keeps the slide-number field in PowerPoint\'s Slide Number placeholder, so Insert > Header & Footer shows Slide number checked and PowerPoint renumbers it, and Keynote draws it as the digit alone because it drops the words next to a live number; `static` writes the number as fixed text, so Keynote shows the words around it. A footer that is only `{{slide.number}}` stays a live field in both modes (the total is always fixed text). Both flags need an opf-pptx that reads them (0.22.0 or later); an older one is refused (`peer-too-old`) rather than ignoring them, and they are exit 2 for any other output.\n\n**Which to choose.** Pick `measured` (the default) when the deck is final and the PPTX is a delivery format: every line sits where the preview put it, and the deck is edited in OPF. Pick `native` when people will edit the text in PowerPoint or Keynote: a longer bullet wraps and numbered lists renumber. Native text is re-wrapped by the application\'s own fonts and engine, so line breaks can differ from the preview; native wrapping is not yet qualified in every application, and anything it cannot carry (see above) stays measured with a `native-body-fallback` finding, so read the findings. `--slide-numbers live` is the default because the PPTX is a PowerPoint file first: the number is PowerPoint\'s own and follows slides moved, added or deleted there. Choose `static` for a deck that will be opened in Keynote, which replaces any paragraph that holds a live slide-number field with the number alone, so `{{slide.number}} / {{deck.slideCount}}` shows only the digit; the cost is that PowerPoint does not renumber a static number. The total, `{{deck.slideCount}}`, is fixed text in both (PowerPoint has no slide-count field).\n\n### PPTX fonts and pictures (LH-28, LH-20)\n\nA PPTX names its fonts; it does not embed them. A viewer that lacks a named family substitutes another one, and its lines can break where the preview\'s did not. The default (`--typefaces selected`) writes the families the deck chose, and the report notes the ones that are not Office-safe (`pptx/typeface-not-office-safe`, info). Office-safe means two things: the family ships with every Windows and macOS machine, and OPF measures it exactly through a metric-compatible open face. The font policy table gives four: Arial, Courier New, Georgia and Times New Roman. `--typefaces safe` writes each Latin text family as one of them and lays the text out with it, so every viewer breaks lines where the file does. A metric twin keeps its exact widths (Arimo and Liberation Sans become Arial, Tinos Times New Roman, Cousine Courier New, Gelasio Georgia). Any other family follows its font scheme\'s type: sans-serif becomes Arial, serif Georgia, monospace Courier New. The line breaks then follow the safe family, not the preview\'s. East Asian and complex-script fonts, symbol, emoji and math families keep their names. Each replacement is reported once (`pptx/typeface-replaced`, info).\n\nFor a file that will be opened in LibreOffice, `--charts picture` writes the chartex types (treemap, waterfall, funnel, box and whisker, ...) as clustered column charts, which LibreOffice draws; with the default `auto` it shows them as unsupported ([LibreOffice interoperability](libreoffice.md#charts)).\n\n`--as images` is a fidelity fallback: each slide becomes one full-bleed PNG picture, drawn by the same renderer and fonts as the PNG preview (at `--scale`, default 2, which gives 2560 x 1440 for a 16:9 slide). The speaker notes, hidden slides and sections are kept, and each picture\'s alternative text is the slide\'s text, so screen readers can read it. The file looks the same in every viewer and needs no fonts, but nothing in it is editable text, and an import gives picture slides, not the deck. The options that shape text, charts and records (`--typefaces`, `--body-text`, `--charts`, `--diagrams`, `--images`, `--provenance`, `--slide-numbers`) do not apply to it (exit 2).\n\n## The other commands\n\n- **`opf create`** writes a starter deck (`--title`) or a bundled example (`--example <slug>`, from `opf catalog examples`).\n- **`opf validate`** checks files, folders (their `*.opf.json`, `*.opf.yaml`, `*.opf.yml` and `*.opf.md`, sorted, skipping\n `node_modules` and dot folders) and `-`. One input prints its report; several print `{ command, ok, files: [reports], counts }`.\n The exit status is the worst over every file. `--format github` prints `::error`, `::warning` and `::notice` annotations with the\n file, line and column. See [validate](validate.md).\n- **`opf paginate`** measures the page breaks with the fonts `opf convert --paginate` draws with when `@openpresentation/opf-render`\n is installed (`layout: "measured"`); without it they are estimated (`layout: "estimated"`) and `hint` names the install command.\n- **`opf fill`** reads CSV, TSV or JSON data; a blank cell keeps the variable\'s declared value; an unfilled required variable fails\n unless `--partial`; `--examples` fills from the declared examples. The second argument is always the data, whatever its name\n (`-` reads it from stdin), and the third is the output; a template alone fills from its own values, to stdout.\n- **`opf ingest`** gives the same slide id and bytes for the same inputs; `--dataset <id>` stores the rows in the deck\'s datasets.\n\n## Reports and errors\n\nEvery command that reports prints one envelope:\n\n```json\n{ "command": "convert", "ok": true, "input": { "file": "/abs/deck.opf.md", "sha256": "\u2026", "bytes": 1234 },\n "outputs": [{ "file": "/abs/deck.pdf", "sha256": "\u2026", "bytes": 56789, "mediaType": "application/pdf" }],\n "findings": [], "counts": { "error": 0, "warning": 0, "info": 0 }, "format": "pdf", "\u2026": "\u2026" }\n```\n\n`input` is `null` when nothing was read and a list when several were (diff, merge, fill). The report is on stdout, or on stderr when\nstdout carries the document. Findings have the [`opf validate`](validate.md) shape (`ruleId`, `severity`, `category`, JSON Pointer\n`path`, `message`, `help`, and `location` when read from text); engine findings carry the prefix `render/`, `pptx/`, `pdf/`,\n`fonts/`, `import/` or `cli/`. The lookup commands (`schemas`, `schema`, `catalogs`, `catalog`, `--version`) print the data asked for.\n\nErrors are `{ command, ok: false, code, error, ... }` on stderr. The message states the fix: a missing argument names it and\nprints the usage, an unknown command, option or value suggests the nearest one ("Did you mean --check?"), and a removed command\nor flag names its replacement. Codes include `usage`, `unknown-command`, `unknown-option`, `removed-command`, `removed-option`,\n`missing-argument`, `extra-argument`, `missing-value`, `invalid-value`, `option-not-applicable`, `unknown-input-format`,\n`input-not-found`, `invalid-json`, `invalid-yaml`, `invalid-markdown`, `invalid-document`, `findings-at-fail-on`,\n`output-exists`, `merge-conflict`, `fill-failed`, `peer-not-installed` and `peer-too-old`.\n\nExit `0`: success (warnings allowed). Exit `1`: an invalid document, a finding at or above `--fail-on`, an existing output, a\nmerge conflict, or a `--check` that found a change. Exit `2`: usage, a read or I/O problem, text that is not valid JSON, YAML or\nMarkdown, or a missing or too-old peer. (`opf validate` reports text that does not parse as a finding, exit 1.)\n\n## Fonts\n\nThe renderer\'s bundled open font pack (the office pack: Carlito, Intos for Aptos, the open families font schemes select and the\nopen replacements the font policy routes proprietary families to) with the visual substitution policy, plus the files from\n`--fonts`. **System fonts are never loaded**, and nothing is downloaded. Font substitutions are listed under\n`fonts.substitutions` in the report. The PPTX keeps the font names the document chose.\n\nScripts beyond Latin, Greek and Cyrillic need the optional Noto script packages of the renderer (`@expo-google-fonts/noto-sans-jp`\nand so on); install the ones named in the `fonts/script-font-not-installed` diagnostic next to the CLI. A standalone SVG\n(`--text fonts`, the default) embeds the faces its text uses; `--text system` omits all font bytes; `--text paths` draws the text\nas glyph outlines (the real text kept invisible beside it for selection and search), so the SVG needs no font.\n\n## Images and assets\n\nRelative image paths and `file:` paths resolve against the input\'s folder (or `--asset-dir`). Only `.png`, `.jpg`, `.jpeg`,\n`.gif`, `.webp` and `.svg` files whose content matches are read, and only inside that folder (symlinks are resolved first). URLs\nare never fetched. For SVG and PNG an unreadable image draws the renderer\'s placeholder with an `unresolved-asset` or\n`cli/asset-blocked` warning. For PPTX (opf-pptx 0.24.1 and later) an unreadable or blocked local path and an unresolved remote URL\nare one case: the deck exports without that image (an unavailable-image placeholder, or the fallback background for a background\npicture) and the report carries a `pptx/unresolved-asset` warning. Use `--fail-on warning` to reject that output before any file is\nwritten. Before opf-pptx 0.24.1 an unreadable or blocked local path stopped the export (`pptx/asset-unresolved`, an error).\n\n## Markdown and YAML\n\nJSON stays the canonical form of a deck. YAML (`deck.opf.yaml`) and Markdown (`deck.opf.md`) are authoring forms of the same data,\nand every command that reads or writes a deck reads and writes all three:\n\n```sh\nopf convert deck.md deck.opf.json # Markdown in the OPF dialect (or an outline) to a deck\nopf convert deck.opf.json deck.opf.md # a deck as Markdown that reads back unchanged\nopf convert deck.opf.yaml deck.opf.json --aliases # strict YAML (--aliases expands anchors)\nopf validate deck.opf.yaml deck.opf.md # every command reads .yaml, .yml and .opf.md\nopf edit deck.opf.md --patch changes.json -i # the file stays Markdown\nopf format deck.opf.md --check # canonical Markdown\nopf validate - --from yaml < deck.txt # stdin and other names: --from\n```\n\nSee [Markdown and outlines](markdown.md) and [OPF as YAML](yaml.md). A syntax error exits 2 with the line and column (`opf\nvalidate` reports it as a `yaml/<rule>` or `markdown/<rule>` finding and exits 1); a command that rewrites a YAML file does not\nkeep its comments and says so on stderr, and one that has to put content into an `opf-slide`/`opf-block` fence says so too.\n\n## Runtime choices\n\n- **Peers, not bundled.** opf-render and opf-pptx are optional peer dependencies loaded lazily. opf-pptx pulls the native `sharp`\n engine, opf-render `resvg`, `fontkit` and the font packs (about 135 MB installed); bundling them would make the small CLI\n impossible to install offline or on a locked-down agent host, and validating or editing a deck would pay for it.\n- **JSON reports.** `--format text` gives human-readable output where a command has it; `--format github` gives CI annotations.\n- **No clock.** `--date` is explicit so a rerun tomorrow gives the same bytes.\n- **Fonts are the bundled pack plus `--fonts`.** Never system fonts (owner font policy).\n- **Stored zip entries.** Deflate output differs between zlib builds, which would make archive hashes host-dependent.\n\n## Catalog names\n\n`opf catalogs` lists canonical camelCase names such as `colorSchemes` and `fontSchemes`, and `examples`. `opf catalog` also\naccepts the website-style `color-schemes`, `font-schemes` and `chart-types` spellings.\n'
|
|
39
|
+
"markdown": '# The `opf` CLI\n\nThe CLI (`@openpresentation/cli`, binary `opf`, Node 22 or later; verified on Node 24) creates, checks, edits, converts and\ninspects decks (see [its README](../packages/cli/README.md)). `opf validate` is the one checker ([validate](validate.md)).\n`opf convert` is the one command that changes formats: a deck form, PDF, PPTX, PNG and SVG. Every command runs core\'s\nfunctions, the ones applications call from [`@openpresentation/opf`](node.md); the commands add the flags, the JSON report and\nthe exit codes.\n\nEverything is deterministic and local: no network, no model, no telemetry, no system fonts. The same document, options and\ninstalled package versions give the same bytes on every operating system.\n\n## Commands\n\n| Command | What it does |\n| --- | --- |\n| `opf create [output] [--title <text> \\| --example <slug>]` | A one-slide starter deck, or one of core\'s bundled examples (`opf catalog examples` lists them). |\n| `opf validate <file\\|dir\\|->...` | The one checker: format, references, policy, accessibility, layout, content. Several files, folders and stdin in one run; `--format json\\|text\\|github`. |\n| `opf convert <input> <output>` | Any change of format: `.json`, `.opf.yaml`, `.opf.md` (and a plain `.md` input), `.pptx`, `.pdf`, `.png`, `.svg`, `.zip`, or stdin and stdout. |\n| `opf edit <file> [output] --patch <patch>` | A JSON Patch, applied whole or not at all, the result checked. |\n| `opf format <file>... [output]` | Canonical key order and layout, in the form the file has. |\n| `opf diff <a> <b>` | What changed between two decks (`--format text\\|json\\|patch`). |\n| `opf merge <base> <ours> <theirs> [output]` | A three-way merge; conflicts are listed. |\n| `opf stats <file>` | Neutral facts about a deck (`--format json\\|text`). |\n| `opf paginate <input> [output]` | Overflowing slides split into continuation slides, measured with the renderer\'s fonts when it is installed. |\n| `opf embed <input> [output]` | The catalog records a deck references, copied into it. |\n| `opf fill <template> <data> [output]` | A template\'s variables filled: one deck per record (the output is a name pattern), or `--combine`. The second argument is always the data (`-` for stdin). |\n| `opf ingest <data> [output] --as table\\|chart` | CSV, TSV or JSON rows as a table or chart slide, alone or added `--into` a deck. |\n| `opf doctor [deck]` | Which formats this install can write, and the one command that installs what is missing. |\n| `opf schemas`, `opf schema [name] [pointer]` | The OPF schemas. `opf schemas` lists the `@openpresentation/opf` version each came from next to its id, and `opf --version` names the schema id ([schema versioning](schema-versioning.md)). |\n| `opf catalogs`, `opf catalog <kind> [id]`, `opf catalog examples [slug]` | The pptx.gallery catalog (`@openpresentation/gallery`) and the bundled example decks. |\n| `opf skills <install\\|update\\|status>` | The six bundled agent skills. |\n| `opf mcp` | Runs the MCP server of `@openpresentation/mcp` on stdio when that package is installed; otherwise prints `npx -y @openpresentation/mcp` and exits 2. See [the MCP server](mcp.md). |\n\n`opf <command> --help` (or `-h`, or `opf help <command>`) prints a command\'s flags and examples.\n\nRemoved in 0.18 (each is a usage error, exit 2, that names its replacement): `opf render`, `opf export`, `opf import`,\n`opf from-md`, `opf to-md`, `opf from-yaml` and `opf to-yaml` (all `opf convert`), `opf create --from` (`opf convert`), and the\nflags `--output`, `--out`, `--out-dir` and `--name` (a positional output), `--input-format` (`--from`), `--json` (reports are\nJSON), `--dry-run` (stdout), `--data` (fill\'s second argument) and the deck values of `--format` (`--to`).\n\n## One output convention\n\nEvery command that writes a deck takes the same arguments:\n\n| Form | Meaning |\n| --- | --- |\n| `opf embed deck.opf.json` | No output: the deck goes to stdout, the report to stderr. `-` says the same. |\n| `opf embed deck.opf.json out.opf.json` | An output after the inputs: written atomically (a temporary sibling, then a rename); an existing file needs `--force`. |\n| `opf embed deck.opf.json -i` | `-i` (`--in-place`) rewrites the input, refusing if it changed since it was read. Not for stdin, and not with an output. |\n| `opf embed deck.opf.json --check` | Writes nothing and exits 1 when the command would change something: `format --check` (not canonical), `embed --check` (not self-contained) and `paginate --check` (a slide overflows). |\n\nThe form written is the output\'s extension (`.json`, `.opf.yaml`/`.yml`, `.opf.md`), else `--to json|yaml|md`, else the form\nthat was read. An existing output is refused before anything is printed or written.\n\n`opf fill` writes one deck per record through a file name pattern: `{n}` is the record number (padded to the width of the largest, the rule of `opf convert`), `{column}` a slug of that\ncolumn\'s value (`opf fill t.opf.md clients.csv decks/qbr-{client}.opf.md`); `--combine` writes one deck with every record\'s slides.\n\n## What each flag means\n\n| Flag | Meaning |\n| --- | --- |\n| `--format json\\|text\\|github\\|patch` | The report format only: `json` (the default), `text`, `github` (validate\'s workflow annotations) or `patch` (diff\'s JSON Patch). |\n| `--from json\\|yaml\\|md` | The form of a deck input: stdin, and names that say none. Without it, a name ending `.json`, `.opf.yaml`, `.yaml`, `.yml` or `.opf.md` says the form, and text that starts with `{` or `[` is JSON; anything else is a usage error that asks for `--from yaml\\|md`. `opf convert` also takes `--from pptx`. |\n| `--to json\\|yaml\\|md` | The form of a deck output, for stdout and names that say none. `opf convert` also takes `pdf`, `pptx`, `png`, `svg` and `zip`. A `--to` that disagrees with the output\'s extension is refused. |\n| `--data-format csv\\|tsv\\|json` | The form of the data of `opf fill` and `opf ingest` (default: the extension, else JSON when it starts with `{` or `[`, else CSV). |\n| `--fail-on error\\|warning\\|info` | Findings at or above this severity fail the command (exit 1) and nothing is written (default `error`). |\n| `--force` | Replace an existing output. |\n\n## Install\n\n**Published set (2026-10-24):** CLI 0.26.1 (core `^0.26.1`, Gallery `^0.26.1`,\noptional renderer/PPTX `^0.26.1`) with core, renderer, PPTX, editor and Gallery 0.26.1. Use the complete pinned [quickstart installation](quickstart.md#versions) and its\nrequired font/converter peers.\n\nDeck forms (JSON, YAML, Markdown) need nothing beyond the CLI. PDF, PNG and SVG need `@openpresentation/opf-render`; PPTX output\nand `.pptx` input also need `@openpresentation/opf-pptx`. Both are **optional peer dependencies** of the CLI and of core (decision\nRR-27, below), loaded the first time a command needs them, from beside the CLI first and from the working directory second.\n\n`opf doctor` says what this install can write and prints the one command that installs the rest:\n\n```sh\nopf doctor --format text # per format: ready, or what is missing; then one install command\nopf doctor deck.opf.md # JSON; with a deck, a PDF needs sharp only when the deck has pictures, and the deck\'s script fonts are checked\n```\n\nThe command matches the package manager that runs the CLI (`npm_config_user_agent`: npm, pnpm, yarn or bun) and the way the CLI\nis installed: global (`npm install -g ...`), a project (`npm install ...`), or one npx run (`npx -p @openpresentation/cli -p ... opf <command>`).\nA conversion that misses a peer exits 2 with `code: "peer-not-installed"` (or `peer-too-old`), and its `install` field and message\ncarry that one command for the format asked for. What each output needs beside `@openpresentation/opf-render`:\n\n| Output | Also install |\n| --- | --- |\n| every drawn format (the office font pack) | `@expo-google-fonts/roboto@0.4.3 @expo-google-fonts/roboto-mono@0.4.2 @expo-google-fonts/caladea@0.4.2 @expo-google-fonts/arimo@0.4.3 @expo-google-fonts/tinos@0.4.2 @expo-google-fonts/cousine@0.4.3 @expo-google-fonts/gelasio@0.4.1 @expo-google-fonts/noto-sans@0.4.2` |\n| `png` | `@resvg/resvg-js@^2.6.2 sharp@^0.35.5` |\n| `pdf` | nothing for text in the default vector mode; `pdf-lib@^1.17.1` for `--raster`; `sharp@^0.35.5` when the deck has pictures |\n| `svg` | the fonts only |\n| `pptx`, a `.pptx` input | `@openpresentation/opf-pptx` |\n\n### Fonts for a deck in another script\n\n`opf doctor` with no deck reports what the install can write and says nothing about a deck\'s scripts. `opf doctor deck.opf.json` also runs the script-font check `opf convert` runs (it prepares the bundled fonts for the deck, so it needs `@openpresentation/opf-render`; nothing is drawn): the script packages the deck\'s text needs that are not installed are listed with their versions under `scriptFonts.missing` (and as `fonts/script-font-not-installed` findings), are added to `missing` and to the one `install` command, and make `svg`, `png`, `pdf`, `pdf-raster` and `pptx` not `ready`. `scriptFonts.checked` is `false`, with a `reason`, when the check could not run (no renderer, or fonts that cannot be prepared), and the text output then does not say the deck is ready. (Before CLI 0.34.1, doctor listed `svg` and `pdf` as `ready` for a deck with an Arabic slide and the conversion then failed.) The office pack covers Latin, Greek and Cyrillic; each other script (Arabic, Hebrew, Thai, the Indic scripts, Chinese, Japanese, Korean and the rest) is one optional `@expo-google-fonts/noto-*` package, and a deck needs the ones for the scripts it draws. To find them and install them:\n\n1. Ask doctor: `opf doctor deck.opf.json --format text` lists the missing script packages and prints the install command (skip to step 2). Or convert the deck once to a throwaway file: `opf convert deck.opf.json check.svg --force`. A missing script font exits 1 with a `fonts/script-font-not-installed` finding per package, each naming the package and the version, for example `@expo-google-fonts/noto-naskh-arabic@0.4.5` and `@expo-google-fonts/noto-sans-arabic@0.4.3` for Arabic text, followed by a `render/missing-glyph` error. (A slide that sets a Noto font scheme itself, such as `noto-sans-arabic`, gets the same finding for the package of the scheme\'s font, and the error names it too: "No local font face for \'Noto Naskh Arabic\'... install @expo-google-fonts/noto-naskh-arabic@0.4.5". Before 0.34.1 that error said only "load the \'scripts\' font pack", and `opf validate` still reports the failed layout as `opf/layout-failed` with that message, not as a `fonts/` finding.)\n2. Install what the findings name, at the versions they name, next to the CLI: `npm install @expo-google-fonts/noto-naskh-arabic@0.4.5 @expo-google-fonts/noto-sans-arabic@0.4.3` in the project that holds `@openpresentation/cli` (a global CLI takes `npm install -g`; `pnpm add`, `yarn add` and `bun add` work the same way).\n3. Convert again. When it succeeds, the report\'s `fonts.scripts` lists `detected` (for example `Arab`), `packages` (the ones used) and `notInstalled` (empty when nothing is missing). Check that list for every deck with more than one script, then export the PDF, PNG, SVG or PPTX.\n\n`opf stats deck.opf.json` lists `fonts.families` (the families the deck names, such as `Noto Naskh Arabic`) but not the packages, and not the script of text that has no font of its own. The package versions are pinned by `@openpresentation/opf-render` (its `package.json` lists every `@expo-google-fonts/*` package it uses, including those for Hebrew, Thai, Devanagari, `noto-sans-jp`, `noto-sans-kr`, `noto-sans-sc` and `noto-sans-tc`). The site\'s starter project ships the eight office-pack fonts only, so a deck with an Arabic slide needs the two Arabic packages above added to it.\n\n## From code\n\nThe engine the commands run is core\'s `@openpresentation/opf` in Node, which an application imports instead of spawning `opf`.\nIn Node, `validate`, `stats`, `paginate`, `embed` and `edit` register the gallery (`@openpresentation/gallery`) when a call names none, as the commands\ndo, so `opf validate deck` and `validate(deck)` agree:\n\n```ts\nimport * as opf from "@openpresentation/opf";\n\nawait opf.convert("deck.opf.md", "deck.pdf"); // opf convert deck.opf.md deck.pdf\nconst deck = await opf.open("deck.pptx"); // opf convert deck.pptx -\nconst { files } = await opf.convert(deck, { format: "png", scale: 2 }); // bytes, nothing written\nconst { presentation } = opf.edit(deck, patch); // opf edit deck --patch patch.json\nconst { decks } = opf.fill(template, csvText); // opf fill template data.csv out-{n}.opf.json\n```\n\nThe options are the flags in camel case (`--raster` is `raster: true`, `--fonts` is `fonts` (a folder or a list of folders),\n`--asset-dir` is `assetDir`, `--include-hidden` is `includeHidden`). The commands refuse an existing output without `--force`;\n`convert` replaces it unless `overwrite: false`. See [OPF files in Node](node.md).\n\n## `opf convert`\n\n```sh\nopf convert deck.opf.md deck.pdf\nopf convert deck.opf.md slides/deck.png --slides 1,3-5 --scale 2 # slides/deck-1.png, -3, -4, -5\nopf convert deck.opf.md "slides/slide-{n}.png" # slides/slide-1.png, slide-2.png, ... (always numbered)\nopf convert deck.opf.md slides.zip --to svg\nopf convert deck.pptx deck.opf.md --signals signals.json\nopf convert outline.md deck.opf.yaml # a plain .md input is OPF Markdown\nopf convert deck.opf.json deck.opf.yaml --schema-comment\nopf convert deck.opf.md - --to pdf > deck.pdf\n```\n\n| Output | Written as |\n| --- | --- |\n| `.pdf`, `.pptx` | one file |\n| `.png`, `.svg` | one file per slide beside the output, named after it: `slides/deck.png` writes `slides/deck-1.png`, `-2`, ... (the deck\'s slide numbers). One selected slide, or a one-slide deck, is written to the output itself. The extension is the format: `deck.png` is always PNG. With `{n}` in the output (`"slides/slide-{n}.png"`) the files are always numbered, even for one slide or one selected slide, and `{n}` is the deck\'s slide number (2 and 5 with `--slides 2,5`). `{n}` is the only placeholder: any other `{key}`, and `{n}` in `.pdf`, `.pptx`, `.zip` or a deck form, is a usage error (exit 2, `invalid-option`). |\n\nNumbers are padded with zeros to the width of the largest number written: `1`...`9` for slides 1 to 9, `01`...`99` up to 99, `001` from 100. With `--slides` the width comes from the largest slide selected (`--slides 2,5` gives `deck-2.png`, `deck-5.png`). The same rule pads `{n}` in `opf fill` (the largest record number) and the zip entries below.\n| `.zip` | one archive of the slides, its entries named as the plain `.png` and `.svg` files above (`slides.zip` holds `slides-1.png`, ...; always numbered, and no `{n}` in the archive\'s own name): PNG, or SVG with `--to svg`. Entries are stored with a fixed timestamp, so the archive is byte-identical everywhere. |\n| `.json`, `.opf.yaml`, `.yml`, `.opf.md` | the deck in that form |\n| `-` | stdout, with `--to`: one file (`pdf`, `pptx`, `zip`, a deck form, or one slide as `png` or `svg`) |\n\nA flag applies only when its format is involved; anywhere else it is a usage error (exit 2, `option-not-applicable`):\n\n| Involved | Flags |\n| --- | --- |\n| a Markdown input | `--split auto\\|rules\\|headings` (default `auto`: slides at `---` lines, and an outline with none at its `#` headings), `--title <text>` (the deck name unless the front matter sets one) |\n| a YAML input | `--aliases` (expand anchors, aliases and merge keys, at most 100) |\n| a `.pptx` input | `--signals <file>` (also write the raw per-shape layout and style signals, `fromPptx` with `signals: true`) |\n| a YAML output | `--schema-comment` (the `# yaml-language-server: $schema=...` line) |\n| a Markdown output | `--drop-unsupported` (leave out what the dialect has no syntax for and list it as loss, instead of embedding it as YAML in a fence) |\n| pdf, png, svg | `--slides 1,3-5` (one-based; `2-` to the end), `--include-hidden` |\n| pdf, png, svg, pptx | `--paginate` or `--keep-slides`, `--date YYYY-MM-DD`, `--fonts <dir>` (repeatable), `--asset-dir <dir>` |\n| png, raster pdf, pptx `--as images` | `--scale 0.1-8` (1 draws the 1280 x 720 reference slide at 1280 x 720 pixels; the pictures of `--as images` default to 2) |\n| pdf | `--raster` (each page a picture instead of selectable vector text) |\n| svg | `--text fonts\\|system\\|paths` (embed the faces the slide uses, none, or draw glyph outlines) |\n| pptx | `--charts auto\\|native\\|picture`, `--diagrams shapes\\|picture`, `--images compatible\\|preserve`, `--provenance full\\|references-only\\|none`, `--body-text measured\\|native`, `--slide-numbers static\\|live`, `--typefaces selected\\|safe`, `--as native\\|images` |\n\nA `.pptx` input is imported, checked and then written or drawn; `findings` holds both steps (`import/` rules from the importer).\nPer-slide images and the PDF skip slides marked `hidden: true` unless `--include-hidden`; slides named with `--slides` are always\nwritten, and the report lists the slides left out in `skippedHidden`. The PPTX keeps a hidden slide as a hidden slide.\n\n**Overfull slides (LH-90).** By default a slide of sibling blocks of one kind (eight timelines, five tables; each block may\nbring the notes that follow it) that overflows at its readability floor is drawn as several slides of the same layout, split\nbetween whole blocks, in every format, so the preview and the PPTX agree. Each such slide is a `render/slide-continued` or\n`pptx/slide-continued` warning and an entry of the report field `continued` (`slide`, the `slides` it became, `kind`, and\n`blocks` and `units` per slide); `--slides` and the file names count the slides drawn. `--paginate` splits every overflowing\nslide instead (as `opf paginate` does), and `--keep-slides` draws every slide as written, overlapping where it overflows.\n\n### PPTX text (RR-88, RR-91)\n\nBy default (`--body-text measured`) a wrapped paragraph becomes one text box per line, laid out exactly as the preview draws it, so editing a line in PowerPoint or Keynote does not reflow the rest. `--body-text native` opts in to whole paragraphs: a text, bullets or numbered-list region is one body that the application re-wraps when edited. In both modes every slide title is the Title placeholder (opf-pptx 0.34.0): a wrapped title is re-wrapped by the application where its line breaks are proven to match the preview, and otherwise keeps the preview\'s lines as fixed line breaks. What native mode cannot carry (groups, cards, nested or described lists, restarted numbering) stays measured and is reported as `native-body-fallback`. A slide recomposed as the automatic grid at the readability floor (LH-83) keeps its native bodies too (LH-91): the first binds to the Body placeholder of a variant of its layout named `<layout> (automatic grid)`. `--slide-numbers` decides a footer such as `{{slide.number}} / {{deck.slideCount}}`: `live` (the default since RR-102) keeps the slide-number field in PowerPoint\'s Slide Number placeholder, so Insert > Header & Footer shows Slide number checked and PowerPoint renumbers it, and Keynote draws it as the digit alone because it drops the words next to a live number; `static` writes the number as fixed text, so Keynote shows the words around it. A footer that is only `{{slide.number}}` stays a live field in both modes (the total is always fixed text). Both flags need an opf-pptx that reads them (0.22.0 or later); an older one is refused (`peer-too-old`) rather than ignoring them, and they are exit 2 for any other output.\n\n**Which to choose.** Pick `measured` (the default) when the deck is final and the PPTX is a delivery format: every line sits where the preview put it, and the deck is edited in OPF. Pick `native` when people will edit the text in PowerPoint or Keynote: a longer bullet wraps and numbered lists renumber. Native text is re-wrapped by the application\'s own fonts and engine, so line breaks can differ from the preview; native wrapping is not yet qualified in every application, and anything it cannot carry (see above) stays measured with a `native-body-fallback` finding, so read the findings. `--slide-numbers live` is the default because the PPTX is a PowerPoint file first: the number is PowerPoint\'s own and follows slides moved, added or deleted there. Choose `static` for a deck that will be opened in Keynote, which replaces any paragraph that holds a live slide-number field with the number alone, so `{{slide.number}} / {{deck.slideCount}}` shows only the digit; the cost is that PowerPoint does not renumber a static number. The total, `{{deck.slideCount}}`, is fixed text in both (PowerPoint has no slide-count field).\n\n### PPTX fonts and pictures (LH-28, LH-20)\n\nA PPTX names its fonts; it does not embed them. A viewer that lacks a named family substitutes another one, and its lines can break where the preview\'s did not. The default (`--typefaces selected`) writes the families the deck chose, and the report notes the ones that are not Office-safe (`pptx/typeface-not-office-safe`, info). Office-safe means two things: the family ships with every Windows and macOS machine, and OPF measures it exactly through a metric-compatible open face. The font policy table gives four: Arial, Courier New, Georgia and Times New Roman. `--typefaces safe` writes each Latin text family as one of them and lays the text out with it, so every viewer breaks lines where the file does. A metric twin keeps its exact widths (Arimo and Liberation Sans become Arial, Tinos Times New Roman, Cousine Courier New, Gelasio Georgia). Any other family follows its font scheme\'s type: sans-serif becomes Arial, serif Georgia, monospace Courier New. The line breaks then follow the safe family, not the preview\'s. East Asian and complex-script fonts, symbol, emoji and math families keep their names. Each replacement is reported once (`pptx/typeface-replaced`, info).\n\nFor a file that will be opened in LibreOffice, `--charts picture` writes the chartex types (treemap, waterfall, funnel, box and whisker, ...) as clustered column charts, which LibreOffice draws; with the default `auto` it shows them as unsupported ([LibreOffice interoperability](libreoffice.md#charts)).\n\n`--as images` is a fidelity fallback: each slide becomes one full-bleed PNG picture, drawn by the same renderer and fonts as the PNG preview (at `--scale`, default 2, which gives 2560 x 1440 for a 16:9 slide). The speaker notes, hidden slides and sections are kept, and each picture\'s alternative text is the slide\'s text, so screen readers can read it. The file looks the same in every viewer and needs no fonts, but nothing in it is editable text, and an import gives picture slides, not the deck. The options that shape text, charts and records (`--typefaces`, `--body-text`, `--charts`, `--diagrams`, `--images`, `--provenance`, `--slide-numbers`) do not apply to it (exit 2).\n\n## The other commands\n\n- **`opf create`** writes a starter deck (`--title`) or a bundled example (`--example <slug>`, from `opf catalog examples`).\n- **`opf validate`** checks files, folders (their `*.opf.json`, `*.opf.yaml`, `*.opf.yml` and `*.opf.md`, sorted, skipping\n `node_modules` and dot folders) and `-`. One input prints its report; several print `{ command, ok, files: [reports], counts }`.\n The exit status is the worst over every file. `--format github` prints `::error`, `::warning` and `::notice` annotations with the\n file, line and column. See [validate](validate.md).\n- **`opf paginate`** measures the page breaks with the fonts `opf convert --paginate` draws with when `@openpresentation/opf-render`\n is installed (`layout: "measured"`); without it they are estimated (`layout: "estimated"`) and `hint` names the install command.\n- **`opf fill`** reads CSV, TSV or JSON data; a blank cell keeps the variable\'s declared value; an unfilled required variable fails\n unless `--partial`; `--examples` fills from the declared examples. The second argument is always the data, whatever its name\n (`-` reads it from stdin), and the third is the output; a template alone fills from its own values, to stdout.\n- **`opf ingest`** gives the same slide id and bytes for the same inputs; `--dataset <id>` stores the rows in the deck\'s datasets.\n\n## Reports and errors\n\nEvery command that reports prints one envelope:\n\n```json\n{ "command": "convert", "ok": true, "input": { "file": "/abs/deck.opf.md", "sha256": "\u2026", "bytes": 1234 },\n "outputs": [{ "file": "/abs/deck.pdf", "sha256": "\u2026", "bytes": 56789, "mediaType": "application/pdf" }],\n "findings": [], "counts": { "error": 0, "warning": 0, "info": 0 }, "format": "pdf", "\u2026": "\u2026" }\n```\n\n`input` is `null` when nothing was read and a list when several were (diff, merge, fill). The report is on stdout, or on stderr when\nstdout carries the document. Findings have the [`opf validate`](validate.md) shape (`ruleId`, `severity`, `category`, JSON Pointer\n`path`, `message`, `help`, and `location` when read from text); engine findings carry the prefix `render/`, `pptx/`, `pdf/`,\n`fonts/`, `import/` or `cli/`. The lookup commands (`schemas`, `schema`, `catalogs`, `catalog`, `--version`) print the data asked for.\n\nErrors are `{ command, ok: false, code, error, ... }` on stderr. The message states the fix: a missing argument names it and\nprints the usage, an unknown command, option or value suggests the nearest one ("Did you mean --check?"), and a removed command\nor flag names its replacement. Codes include `usage`, `unknown-command`, `unknown-option`, `removed-command`, `removed-option`,\n`missing-argument`, `extra-argument`, `missing-value`, `invalid-value`, `option-not-applicable`, `unknown-input-format`,\n`input-not-found`, `invalid-json`, `invalid-yaml`, `invalid-markdown`, `invalid-document`, `findings-at-fail-on`,\n`output-exists`, `merge-conflict`, `fill-failed`, `peer-not-installed` and `peer-too-old`.\n\nExit `0`: success (warnings allowed). Exit `1`: an invalid document, a finding at or above `--fail-on`, an existing output, a\nmerge conflict, or a `--check` that found a change. Exit `2`: usage, a read or I/O problem, text that is not valid JSON, YAML or\nMarkdown, or a missing or too-old peer. (`opf validate` reports text that does not parse as a finding, exit 1.)\n\n## Fonts\n\nThe renderer\'s bundled open font pack (the office pack: Carlito, Intos for Aptos, the open families font schemes select and the\nopen replacements the font policy routes proprietary families to) with the visual substitution policy, plus the files from\n`--fonts`. **System fonts are never loaded**, and nothing is downloaded. Font substitutions are listed under\n`fonts.substitutions` in the report. The PPTX keeps the font names the document chose.\n\nScripts beyond Latin, Greek and Cyrillic need the optional Noto script packages of the renderer (`@expo-google-fonts/noto-sans-jp`\nand so on); install the ones named in the `fonts/script-font-not-installed` diagnostic next to the CLI. A standalone SVG\n(`--text fonts`, the default) embeds the faces its text uses; `--text system` omits all font bytes; `--text paths` draws the text\nas glyph outlines (the real text kept invisible beside it for selection and search), so the SVG needs no font.\n\n## Images and assets\n\nRelative image paths and `file:` paths resolve against the input\'s folder (or `--asset-dir`). Only `.png`, `.jpg`, `.jpeg`,\n`.gif`, `.webp` and `.svg` files whose content matches are read, and only inside that folder (symlinks are resolved first). URLs\nare never fetched. For SVG and PNG an unreadable image draws the renderer\'s placeholder with an `unresolved-asset` or\n`cli/asset-blocked` warning. For PPTX (opf-pptx 0.24.1 and later) an unreadable or blocked local path and an unresolved remote URL\nare one case: the deck exports without that image (an unavailable-image placeholder, or the fallback background for a background\npicture) and the report carries a `pptx/unresolved-asset` warning. Use `--fail-on warning` to reject that output before any file is\nwritten. Before opf-pptx 0.24.1 an unreadable or blocked local path stopped the export (`pptx/asset-unresolved`, an error).\n\n## Markdown and YAML\n\nJSON stays the canonical form of a deck. YAML (`deck.opf.yaml`) and Markdown (`deck.opf.md`) are authoring forms of the same data,\nand every command that reads or writes a deck reads and writes all three:\n\n```sh\nopf convert deck.md deck.opf.json # Markdown in the OPF dialect (or an outline) to a deck\nopf convert deck.opf.json deck.opf.md # a deck as Markdown that reads back unchanged\nopf convert deck.opf.yaml deck.opf.json --aliases # strict YAML (--aliases expands anchors)\nopf validate deck.opf.yaml deck.opf.md # every command reads .yaml, .yml and .opf.md\nopf edit deck.opf.md --patch changes.json -i # the file stays Markdown\nopf format deck.opf.md --check # canonical Markdown\nopf validate - --from yaml < deck.txt # stdin and other names: --from\n```\n\nSee [Markdown and outlines](markdown.md) and [OPF as YAML](yaml.md). A syntax error exits 2 with the line and column (`opf\nvalidate` reports it as a `yaml/<rule>` or `markdown/<rule>` finding and exits 1); a command that rewrites a YAML file does not\nkeep its comments and says so on stderr, and one that has to put content into an `opf-slide`/`opf-block` fence says so too.\n\n## Runtime choices\n\n- **Peers, not bundled.** opf-render and opf-pptx are optional peer dependencies loaded lazily. opf-pptx pulls the native `sharp`\n engine, opf-render `resvg`, `fontkit` and the font packs (about 135 MB installed); bundling them would make the small CLI\n impossible to install offline or on a locked-down agent host, and validating or editing a deck would pay for it.\n- **JSON reports.** `--format text` gives human-readable output where a command has it; `--format github` gives CI annotations.\n- **No clock.** `--date` is explicit so a rerun tomorrow gives the same bytes.\n- **Fonts are the bundled pack plus `--fonts`.** Never system fonts (owner font policy).\n- **Stored zip entries.** Deflate output differs between zlib builds, which would make archive hashes host-dependent.\n\n## Catalog names\n\n`opf catalogs` lists canonical camelCase names such as `colorSchemes` and `fontSchemes`, and `examples`. `opf catalog` also\naccepts the website-style `color-schemes`, `font-schemes` and `chart-types` spellings.\n'
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"slug": "compatibility-matrix",
|
|
@@ -84,7 +84,7 @@ var docsData = Object.freeze([
|
|
|
84
84
|
"slug": "diagrams",
|
|
85
85
|
"file": "docs/diagrams.md",
|
|
86
86
|
"title": "Diagrams",
|
|
87
|
-
"markdown": '# Diagrams\n\nA `diagram` is a diagram written as text. You write [Mermaid](https://mermaid.js.org), [Graphviz DOT](#graphviz-dot) or [PlantUML](#plantuml) source, and the engines draw it in the deck\'s own fonts and colors, so a flowchart, a sequence of messages or a mind map looks like the rest of the slide and not like a pasted screenshot. This guide covers when to use one, how to write it in JSON, YAML and Markdown, what it looks like, how it is sized, and how it exports. The field reference is [Content payloads](content-payloads.md#diagram); the schema definition is `$defs.Diagram` (`opf schema presentation \'/$defs/Diagram\'`).\n\n## When to use a diagram\n\nChoose the content kind by what the content is, not by how it should look.\n\n| The content is | Use |\n| --- | --- |\n| Steps, a decision flow, systems and how they connect, messages between parties, states and transitions, a hierarchy, an entity model | `diagram` |\n| Numbers plotted on axes or as shares of a whole, where the values should stay editable data | `chart` |\n| Dated or ordered milestones with progress (`done`, `current`, `planned`) | `timeline` (the payload, with its status design) |\n| Parallel entries with details, or a short sequence of one-line steps | a list (`items`) or layout `process` |\n\nA Mermaid `pie` or `timeline` diagram is a quick picture. A `chart` or `timeline` payload keeps the data editable and gets the engines\' chart and timeline design, with highlights and status words. Prefer the payload when it fits and the diagram when only a diagram can show the structure.\n\n## Writing one\n\nA string is shorthand for `{ "source": value }`. The object form adds `alt`, the text alternative, and `syntax`: `"mermaid"` (the default), `"dot"` for a [Graphviz DOT](#graphviz-dot) graph or `"plantuml"` for a [PlantUML](#plantuml) diagram. A diagram is a root payload, a block, or the content of a layout region that accepts it. It takes a `caption` like an image or a chart.\n\n```json\n{\n "title": "Every request is reviewed before it ships",\n "diagram": "flowchart LR\\n A[Request] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| D[Revise]\\n D --> A"\n}\n```\n\nThe slide this draws, in the engine\'s default design:\n\n\n\nWith an `alt` and a caption:\n\n```json\n{\n "title": "A rejected brief returns to its author",\n "diagram": {\n "source": "flowchart LR\\n A[Brief] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| A",\n "alt": "A brief goes to review. Approved work is built; rejected work returns to the brief."\n },\n "caption": "Figure 1. The review loop"\n}\n```\n\n\n\nAs YAML a block scalar keeps the source readable:\n\n```yaml\n- title: Every request is reviewed before it ships\n diagram:\n alt: A request is approved or revised, then built.\n source: |-\n flowchart LR\n A[Request] --> B{Approved?}\n B -->|yes| C[Build]\n B -->|no| D[Revise]\n D --> A\n```\n\nBeside text, give the slide `blocks`; the diagram takes its own cell:\n\n```json\n{\n "title": "The client talks to one API",\n "blocks": [\n { "bullets": ["The client creates a deck with one call", "The API validates it before it answers"] },\n { "diagram": "sequenceDiagram\\n Client->>API: POST /decks\\n API-->>Client: 201 Created" }\n ]\n}\n```\n\n\n\n### In Markdown\n\nA fenced block whose info word is `mermaid` is a diagram, one whose info word is `dot` is a [DOT diagram](#graphviz-dot) (`{ source, syntax: "dot" }`) and one whose info word is `plantuml` a [PlantUML diagram](#plantuml) (`{ source, syntax: "plantuml" }`). An optional `alt="..."` after the word is its text alternative. `toMarkdown` writes a diagram back the same way, so the round trip is lossless.\n\n````markdown\n# Every request is reviewed before it ships\n\n```mermaid alt="A request is approved or revised, then built."\nflowchart LR\n A[Request] --> B{Approved?}\n B -->|yes| C[Build]\n B -->|no| D[Revise]\n D --> A\n```\n````\n\nA source with a blank first or last line, or an `alt` that holds a backtick or a line break, cannot be written as a fence; the writer then uses an `opf-block`, which reads back exactly. See [Markdown and outlines](markdown.md). A runnable deck is [`examples/markdown/diagrams.opf.md`](../examples/markdown/diagrams.opf.md), and the JSON fixture [`examples/technical/diagrams.opf.json`](../examples/technical/diagrams.opf.json) has seven slides.\n\n## Supported Mermaid families\n\nOPF draws diagrams with [pele](https://pele.run), the shared layout/drawing library pinned as `pele@1.13.0` in this source. It parses Mermaid 12.1 syntax. OPF reads the supported DOT and PlantUML subsets itself and adapts them to the same engine; these are not separate Graphviz or PlantUML renderer installations. The first line of the source names the family. All the built-in families are supported; ZenUML is not.\n\n| Family | First line | Shows |\n| --- | --- | --- |\n| Flowchart | `flowchart LR` or `TB` | Steps, decisions and flow |\n| Sequence | `sequenceDiagram` | Messages between participants over time |\n| Class | `classDiagram` | Classes, members and relationships |\n| State | `stateDiagram-v2` | States and transitions |\n| Entity relationship | `erDiagram` | Entities, attributes and cardinalities |\n| Gantt | `gantt` | Tasks on a calendar |\n| Pie | `pie` | Shares of a whole |\n| Quadrant | `quadrantChart` | Points on two axes |\n| Mind map | `mindmap` | A hierarchy of ideas |\n| Timeline | `timeline` | Periods with events, in sections |\n| User journey | `journey` | Tasks with a satisfaction score |\n| XY chart | `xychart` | Bars and lines on axes |\n| Sankey | `sankey` | Flows between nodes |\n| Git graph | `gitGraph` | Commits, branches and merges |\n| C4 | `C4Context` and the other C4 headers | System context, containers, components |\n| Block | `block` | Blocks on a grid |\n| Architecture | `architecture-beta` | Services, groups and connections |\n| Kanban | `kanban` | Columns of cards |\n| Packet | `packet` | Bit fields of a protocol packet |\n| Radar | `radar-beta` | Several measures on radial axes |\n| Treemap | `treemap` | Nested rectangles sized by value |\n| Venn | `venn-beta` | Overlapping sets |\n| Ishikawa | `ishikawa-beta` | Causes of a problem (fishbone) |\n| Requirement | `requirementDiagram` | Requirements and what satisfies them |\n| Wardley map | `wardley-beta` | Components by visibility and evolution |\n| Tree view | `treeView-beta` | A folder-style hierarchy |\n| Event modeling | `eventmodeling` | Commands, events and views along a timeline |\n| Railroad | `railroad-beta` (also `railroad-ebnf-beta`, `railroad-abnf-beta`, `railroad-peg-beta`) | The syntax of a grammar |\n| Cynefin | `cynefin-beta` | Items placed in the Cynefin domains |\n| Use case | `usecase-beta` | Actors, use cases and system boundaries |\n| Swimlane | `swimlane-beta` | A flowchart in lanes |\n| Agent flow | `agentflow-beta` | The steps and tools of an agent workflow |\n\nThe six most useful, each as a complete source and the slide it draws in the default design:\n\n````text\nflowchart LR\n A[Idea] --> B{Worth testing?}\n B -->|yes| C[Prototype]\n B -->|no| D[Park it]\n````\n\n\n\n````text\nsequenceDiagram\n Client->>API: POST /decks\n API-->>Client: 201 Created\n````\n\n\n\n````text\nmindmap\n root((Strategy))\n Growth\n Efficiency\n People\n````\n\n\n\n````text\ntimeline\n title Regional rollout\n section Pilot\n 2026 Q1 : One operations team\n section Rollout\n 2026 Q3 : All regions\n````\n\n\n\n````text\nstateDiagram-v2\n [*] --> Queued\n Queued --> Building\n Building --> Live: success\n Building --> Failed: error\n Failed --> Queued: retry\n````\n\n\n\n````text\njourney\n title Onboarding\n section Sign up\n Create an account: 5: New user\n Verify the email: 3: New user\n section First week\n Build a first deck: 4: New user\n````\n\n\n\nFor the full syntax of each family, read the [Mermaid documentation](https://mermaid.js.org/intro/); pele follows it, but draws with its own layout (see [The engine](#the-engine)).\n\n## Graphviz DOT\n\nA [DOT](https://graphviz.org/doc/info/lang.html) graph (`graph` or `digraph`) is a diagram with `syntax: "dot"`. OPF reads the DOT language itself and gives the graph to pele\'s layered layout, the one that draws a Mermaid flowchart, so a DOT diagram is laid out in ranks as Graphviz\'s `dot` engine lays it out, sized, styled and exported exactly as a flowchart is. No Graphviz code ships or runs (Graphviz is EPL-2.0), and the drawing is pele\'s, so it does not match the pixels of a Graphviz rendering.\n\n```json\n{\n "title": "Every change passes the same pipeline",\n "diagram": {\n "syntax": "dot",\n "source": "digraph release {\\n rankdir=LR\\n node [shape=box, style=rounded]\\n subgraph cluster_ci {\\n label=\\"Continuous integration\\"\\n Commit -> Build -> Test\\n }\\n Review [shape=diamond, label=\\"Approved?\\"]\\n Test -> Review [label=\\"passes\\"]\\n Test -> Build [label=\\"fails\\", style=dashed]\\n Review -> Release [label=\\"yes\\"]\\n Release [shape=ellipse]\\n}"\n }\n}\n```\n\n\n\nIn Markdown, the `dot` fence:\n\n````markdown\n# A deck moves from draft to published\n\n```dot alt="A draft is submitted for review; review approves it or sends it back."\ndigraph states {\n rankdir=LR\n node [shape=circle]\n Draft -> Review [label="submit"]\n Review -> Draft [label="changes"]\n Review -> Published [label="approve"]\n Published [shape=doublecircle]\n}\n```\n````\n\n\n\nA runnable deck is [`examples/technical/dot-diagrams.opf.json`](../examples/technical/dot-diagrams.opf.json).\n\nWhat OPF draws from a DOT source:\n\n| DOT | Drawn as |\n| --- | --- |\n| `digraph` and `->`, `graph` and `--`, `strict` | Edges with an arrowhead in a digraph and without one in a graph; `strict` draws a repeated edge once |\n| `rankdir` (`TB`, `LR`, `BT`, `RL`) | The direction the ranks run (top to bottom by default) |\n| `label` on the graph | The diagram\'s title, drawn above it |\n| `subgraph cluster_*` (or `cluster=true`) and its `label` | A labeled group around its nodes, nested as written; a node is in the innermost cluster that mentions it. Other subgraphs only group statements (`rank=same` is not kept) |\n| `node [...]`, `edge [...]`, `graph [...]` | Defaults for the statements after them, scoped to their subgraph |\n| Node `label` | The node\'s text: `\\n`, `\\l` and `\\r` break lines, `\\N`, `\\G`, `\\E`, `\\T` and `\\H` are the node, graph, edge, tail and head names; a record\'s fields (`{a\\|b\\|<p> c}`) are its lines; an HTML-like label is read as text (`<br/>` breaks a line) |\n| Node `shape` | The shapes in the table below |\n| Node `style` | `rounded` rounds a box, `dashed` and `dotted` dash the outline, `bold` thickens it, `invis` leaves the node and its edges out |\n| Edge `label` (or `xlabel`) | The edge\'s label |\n| Edge `style` and `penwidth` | `dashed` and `dotted` are a dashed line, `bold` or a `penwidth` of 2 or more a thick one, `invis` an edge that only places its nodes |\n| `arrowhead`, `arrowtail`, `dir` | `none` is no marker, the `dot` and `odot` arrows a circle, `tee` and `box` a cross, every other arrow type an arrowhead; `dir=both` draws both ends (with the head\'s marker), `dir=none` neither, and `dir=back` draws the edge from its head to its tail, which the layout then ranks that way |\n| `minlen` | The number of ranks the edge spans (up to 8) |\n| Ports (`a:p:n`) | Read and not kept: the layout decides where an edge meets its node |\n\n| DOT shape | Drawn as | PowerPoint shape |\n| --- | --- | --- |\n| `box`, `rect`, `rectangle`, `square`, `Msquare`, `record` | A rounded box | Rounded rectangle |\n| `Mrecord`, `box` with `style=rounded` | A box with rounder corners | Rounded rectangle |\n| `ellipse` (the default), `oval`, `egg` | A stadium, which holds its label as an ellipse does | Rounded rectangle (fully rounded) |\n| `circle`, `Mcircle`, `doublecircle`, `point` | A circle, a double circle, a small filled circle | Ellipse |\n| `diamond`, `Mdiamond` | A diamond | Diamond |\n| `hexagon`, `octagon`, `doubleoctagon`, `tripleoctagon`, `septagon` | A hexagon | Hexagon |\n| `parallelogram`, `trapezium`, `invtrapezium` | A parallelogram, a trapezoid, an inverted trapezoid | Parallelogram, trapezoid, freeform |\n| `triangle`, `invtriangle` | A triangle, an inverted triangle | Triangle, freeform |\n| `cylinder`, `note`, `tab`, `folder` | A cylinder, a card with a cut corner, a folder | Freeform |\n| `box3d`, `component` | Stacked boxes, a framed box | Rounded rectangles and lines |\n| `plaintext`, `plain`, `none`, `underline` | Text without an outline | Text box |\n| Any other shape (`house`, `star`, `cds`, ...) | A rounded box | Rounded rectangle |\n\nThe deck decides colors, fonts and sizes, as it does for Mermaid: `color`, `fillcolor`, `fontcolor`, `fontname`, `fontsize`, `bgcolor`, `width`, `height`, `pos` and the other attributes of Graphviz\'s drawing are read and ignored, and so are `style=filled`, `constraint`, `weight`, `splines` and `rank`.\n\n**Layouts OPF does not draw are refused, not approximated.** A graph whose `layout` attribute names another Graphviz engine (`neato`, `fdp`, `sfdp`, `circo`, `twopi`, `osage`, `patchwork`) is not drawn: the slide reports a finding at the attribute\'s line and column ("OPF draws DOT graphs with a layered layout, as Graphviz\'s dot engine does; the neato layout is not drawn ...") and the engines draw the "Diagram unavailable" placeholder. Remove the attribute, or write `layout=dot`, to draw the graph in layers. An HTML-like label that holds a `<table>` is refused the same way; write the label as text, or as a record.\n\nIn a double-quoted string `\\"` is a quote and a backslash before a line break continues the line; every other backslash pair (`\\\\`, `\\n`, `\\l`, `\\N`) is a label escape, so `"c:\\\\"` is the text `c:\\`. Text arrives as written, backticks included.\n\nA DOT source holds one graph, at most 20,000 characters, 500 edges and 16 levels of nested subgraphs. A syntax error is a finding with its line and column in the DOT source; if pele rejects what OPF made of a source, the finding says so without a position (pele\'s would be in generated text).\n\n## PlantUML\n\nA [PlantUML](https://plantuml.com) diagram is a diagram with `syntax: "plantuml"`, written from its `@start` line to its `@end` line. OPF reads PlantUML itself and draws each kind as the Mermaid family of the same kind, so a PlantUML diagram is laid out by pele, sized, styled and exported exactly as that family is. No PlantUML code ships or runs (PlantUML is GPL), and the drawing is pele\'s, so it does not match the pixels of a PlantUML rendering.\n\n```json\n{\n "title": "The API answers every request with findings",\n "diagram": {\n "syntax": "plantuml",\n "source": "@startuml\\nactor Author\\nparticipant \\"Deck API\\" as API\\ndatabase Store\\nAuthor -> API : POST /decks\\nAPI -> Store : save\\nStore --> API : id\\nalt valid\\n API --> Author : 201 Created\\nelse invalid\\n API --> Author : 422 findings\\nend\\n@enduml"\n }\n}\n```\n\n\n\nIn Markdown, the `plantuml` fence:\n\n````markdown\n# Every brief is reviewed before it is built\n\n```plantuml\n@startuml\nstart\n:Write the brief;\nif (Approved?) then (yes)\n :Build the deck;\nelse (no)\n :Revise it;\nendif\nstop\n@enduml\n```\n````\n\n\n\nA runnable deck with every kind is [`examples/technical/plantuml-diagrams.opf.json`](../examples/technical/plantuml-diagrams.opf.json).\n\nThe kinds OPF draws, and what it reads of each:\n\n| PlantUML diagram | Drawn as | What is read |\n| --- | --- | --- |\n| Sequence (`participant`, `A -> B : message`) | Sequence | `participant`, `actor`, `boundary`, `control`, `entity`, `database`, `collections` and `queue` with `as` names; messages `->`, `-->` (dashed), `->>`, `-\\` and `-/` (the last three are drawn with the open head), `->x`, `<-`, `<->`; `++` and `--` activations, `activate`, `deactivate`, `create`, `destroy`, `return`; `alt`/`else`, `opt`, `loop`, `par`, `break`, `critical` and `group`; notes (`left of`, `right of`, `over`, one line or a block); `ref over`; `== dividers ==` and `...delays...` as notes over every participant; `box`; `autonumber` (plain; numbers from 1); `title` |\n| Class (`class`, `interface`, `enum`) | Class | Classes, abstract classes, interfaces, enums, annotations and the other class keywords, with `as` names, generics and stereotypes; members in braces or as `Name : member`, `{static}` and `{abstract}`; `extends` and `implements`; relations `<|--`, `<|..`, `*--`, `o--`, `-->`, `..>`, `--`, `..` (both ways) with cardinalities and labels; notes on a class and a floating `note "text" as N` that no link refers to; packages and namespaces |\n| State (`[*]`, `state`) | State | States with `as` names and descriptions, transitions with events, composite states, `--` and `||` regions, `<<choice>>`, `<<fork>>` and `<<join>>`, notes left of or right of a state, `left to right direction` |\n| Activity, the current syntax (`start`, `:action;`, `stop`) | Flowchart | `start`, `stop`, `end`, `kill`, `detach`; actions over one or several lines (an SDL ending `|`, `<`, `>`, `/`, `]` or `}` picks the shape); `if`/`elseif`/`else`/`endif`, `switch`/`case`, `while`/`endwhile`, `repeat`/`repeat while`, `fork`/`fork again`/`end fork` (bars), `split`; arrow labels (`-> label;`); `partition` and `group` blocks and `|swimlanes|` as groups; notes beside the last action; `(A)` connectors |\n| Use case (`actor`, `(use case)`) | Use case | Actors (`actor`, `:Name:`), use cases (`usecase`, `(Name)`) with `as` names (including `(Use the application) as (Use)`), `rectangle` and `package` boundaries around use cases (one level; a nested one is drawn beside its parent; an actor written inside a boundary is drawn outside it, and a boundary with no use case is not drawn), associations with labels, `<<include>>` and `<<extend>>` on dotted links, generalization, notes left of, right of, top of or bottom of an element, `left to right direction` |\n| Component and deployment (`[Component]`, `node`, `database`) | Flowchart | `[Component]`, `component`, `() Interface`, `interface`, `database`, `node`, `cloud`, `artifact`, `folder`, `queue`, `actor` and the other element keywords as shapes; `package`, `node`, `folder`, `frame`, `cloud`, `database` and `rectangle` blocks as groups (named, with `as`, or unnamed: `cloud {`), which a link can name; links with their line (`--`, `..`, `==`, `-[hidden]-`), direction, ends and labels; notes left of, right of, top of or bottom of an element |\n| Mind map (`@startmindmap`) | Mind map | `*` depth (and `+` and `-` for the two sides), Markdown indentation, boxless `*_` nodes as square ones, multi-line `:text;` nodes |\n| Gantt (`@startgantt`) | Gantt | `Project starts`, tasks that `last` or `require` days or weeks, `starts` and `ends` on a date or at another task\'s start or end (with days before or after), `then`, milestones that `happen`, `is N% complete` (100% done, more than 0 active), `-- sections --`, closed weekdays and dates. OPF schedules the tasks in working days and writes their dates; without `Project starts`, the days are numbered from 1 |\n\nIn `participant Participant as Foo`, `Foo` is the name later lines use and `Participant` is what is drawn (PlantUML\'s own example); a quoted side is always what is drawn (`participant "Web App" as W`, `participant W as "Web App"`). The same holds for classes, states, use cases, actors, components and gantt tasks (`[Prototype design] as [D1]`).\n\nPlantUML\'s styling is ignored, as Mermaid\'s themes are: `skinparam`, `!theme`, `<style>`, colors, `hide` and `show`, `scale`, headers, footers, captions, legends, `mainframe` and `autoactivate` (no activation bars). A keyword is a statement only in its own shape: an element named `Header`, `Show`, `Title`, `Node` or `Group` keeps its messages and relations. Spacing lines (`...`, `|||`, `||45||`) are ignored, since the layout spaces the messages; `...text...` and `== text ==` are notes.\n\n**What OPF does not draw is refused, not approximated.** The other PlantUML diagrams (timing, object, network, ArchiMate, entity relationship, Salt, JSON, YAML, work breakdown structures and the other `@start` kinds), the legacy activity syntax (`(*) --> "First"`), messages from outside a sequence diagram (`[->`), circle ends (`->o`), a cross or half head on a double-headed message, `autonumber` with arguments, `newpage`, history states (`[H]`), `label` and `goto`, `hide @unlinked` and `hide <<stereotype>>`, notes on a link or floating notes that a link names (a lone floating class note is drawn), a note above or below a state, a gantt `pauses` or `is deleted`, a ** after a message, a second diagram in one source, and the preprocessor (`!include`, `!define`, `!function`, `$variables`) report a finding at their line ("OPF does not draw PlantUML timing diagrams; it draws sequence, class, state, ...") and the engines draw the "Diagram unavailable" placeholder. So does a line OPF cannot read in a diagram it draws.\n\n`return` answers the call of the latest activation (`++`, `activate`) and deactivates it; without one it replies to the last unanswered call. A `destroy` followed by messages of others is drawn with the last message to or from the destroyed participant, as pele requires. If pele rejects what OPF made of a source, the finding says so without a position (pele\'s would be in generated text).\n\nA PlantUML source holds one diagram, at most 20,000 characters (2,000 on a line), 500 messages, relations or arrows, and 16 levels of nested blocks.\n\n## How the deck styles a diagram\n\nThe deck decides colors and fonts, so a diagram follows the slide it sits on:\n\n- **Node fills** are tints of the first accent of the slide\'s color scheme, in the slide variant\'s order, mixed over the surface the diagram sits on. That surface is the card when the block has one (see `emphasis` and cards in [Layout templates](layout-templates.md)), otherwise the slide background.\n- **Outlines and connectors** mix toward the accent and the text color, with enough contrast to read as structure without competing with the labels.\n- **Data series** (pie slices, xychart series, timeline sections, mind map branches and the like) use the same chart series palette as the slide\'s charts: the color scheme\'s accents in the variant\'s order.\n- **Text** keeps 4.5:1 against its fill.\n- **Fonts.** Labels use the font scheme\'s body font, and code-like labels (class members, for example) its code font.\n- **Dark backgrounds, dark variants and color maps** adapt with no change to the source: `design.variant: "dark1"` on a slide redraws its diagram from the dark surface.\n\nThe same slide, with the same source, in four designs from the default catalog:\n\n```json\n{\n "title": "Every request is reviewed before it ships",\n "diagram": "flowchart LR\\n A[Request] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| D[Revise]\\n D --> A\\n C --> E[Test]\\n E --> F{Passes?}\\n F -->|yes| G[Release]\\n F -->|no| C"\n}\n```\n\n| `classic`, `forest-green`, `aptos` | `bold`, `deep-purple`, `montserrat` |\n| --- | --- |\n|  |  |\n| **`minimal`, `burnt-orange`, `georgia`** | **`classic`, `steel-blue`, `open-sans`, slide `design.variant: "dark1"`** |\n|  |  |\n\nEvery image in this guide is the renderer\'s own SVG output for the source above it, drawn by `scripts/build-diagram-doc-images.mjs` (`pnpm check:diagram-doc-images` keeps them current).\n\nMermaid\'s own theming (`%%{init: ...}%%`, themes, `themeVariables`) and click callbacks are ignored. Authored `style`, `classDef` and C4 `UpdateElementStyle` colors are the exception: pele applies them and OPF\'s painter keeps them, so a shape with an authored color no longer follows the deck\'s colors, variant or contrast rules. Leave them out and let the deck decide; if one shape must stand out, prefer a different node shape or a label to a color.\n\n## Sizing\n\nCore lays a diagram out for its block with the deck\'s measured fonts, the same way it fits text:\n\n1. It tries the largest base size from 32 reference pixels down at which the drawing fits the block. A small diagram grows to the size of a list; a large one steps down.\n2. Node labels never go below the readability floor (`minFontSize`, 16 reference pixels by default). The smallest secondary label (an edge label, an axis tick, a score) never goes below 75% of it.\n3. A diagram is centered in its block. A region anchored to the bottom places it there.\n4. Pele lays the diagram out for the width it has, so a smaller size is a new layout, not a shrunken picture: a wide flowchart may turn to run downward.\n\nWhen the diagram does not fit even at the floor, a flowchart or a state diagram is first tried in the other main direction (`LR` and `TB` swap, `RL` and `BT` swap; a state diagram without a `direction` is top to bottom, so it tries `direction LR`). If the labels reach the floor there, the diagram is drawn that way and the slide reports an `arrangement-adapted` info finding ("The flowchart is drawn top to bottom because left to right does not fit at the readability floor"). This applies to a direction the author wrote too: the source keeps its text, only the drawing turns, and the preview and the PPTX export draw the same turned layout. A diagram that fits as written is never turned.\n\nWhen no direction holds the labels at the floor (or the diagram type has no direction), the diagram as written is drawn smaller to stay inside its block, and the slide reports a `text-overflow` finding at the diagram\'s path, naming the directions tried. Fix it in the content, not in `minFontSize`:\n\n- give the diagram a slide or a region of its own, or put it beside short text rather than under long text;\n- split it into two diagrams, or shorten the labels.\n\nThe overflow check needs composition or rendering with the resolved fonts; `opf validate` alone cannot see it.\n\n### Layouts that accept a diagram\n\nA layout region lists the kinds it `accepts` ([Layout templates](layout-templates.md#regions)); `diagram` is one of them. In the default catalog these regions take a diagram:\n\n| Layout | Region |\n| --- | --- |\n| `charts` | `chart` |\n| `chart` | `chart-beside` |\n| `media`, `image-beside`, `hero` | `image` |\n| `comparison`, `two-column` | `first` and `second` |\n| `three-column` | the three columns |\n| `process` | `steps` |\n| `timeline` | `timeline` |\n\nA block binds to a region by kind, role and reading order ([Binding content to regions](layout-templates.md#binding-content-to-regions)); a slide that pins a diagram to a region that does not accept it gets the warning `opf/region-kind` and the block is bound by kind instead.\n\n## Accessibility\n\n`alt` is the text alternative: say what the diagram shows, not that it is a diagram ("A brief goes to review; approved work is built, rejected work returns to the brief."). Without `alt`, engines derive one from the diagram type and its labels (for example "Flowchart: Request, Approved?, Build, Revise"), up to 400 characters. The preview draws the diagram as one `role="img"` named by that text, and the PPTX export writes it as the description of the picture (or of the group of shapes).\n\n## Exports\n\n| Output | What you get |\n| --- | --- |\n| SVG preview | The diagram as vector shapes and text in the slide\'s colors and fonts |\n| PNG | The preview rasterized |\n| PDF | Vector; the diagram\'s labels stay selectable text |\n| PPTX (the default, `diagrams: "shapes"`) | Native PowerPoint shapes, connectors and text in one group, drawn from the preview\'s own geometry, `alt` as the group\'s description. `fromPptx` brings an unchanged group back as a `diagram`, a DOT or PlantUML diagram with its own source. A diagram that cannot be written as shapes is the picture below. |\n| PPTX, `diagrams: "picture"` | A native SVG picture with a PNG fallback: crisp at any size, recolorable as a picture in PowerPoint, `alt` as the picture\'s description. `fromPptx` brings it back as a `diagram`. |\n\n### Native shapes in PowerPoint\n\nThe PPTX export writes each diagram as editable PowerPoint shapes that look like the preview (`diagrams: "shapes"`, the default). To get one SVG picture per diagram instead, as earlier releases did, opt out:\n\n```js\nconst bytes = await toPptx(deck, { diagrams: "picture" });\nawait convert(deck, "deck.pptx", { diagrams: "picture" });\n```\n\n```sh\nopf convert deck.opf.json deck.pptx --diagrams picture\n```\n\nThe shapes are built from pele\'s laid-out drawing, the same geometry the preview draws, never a second layout or PowerPoint\'s connector routing:\n\n- **Nodes** are shapes. An outline that is exactly a PowerPoint preset is that preset (`rect`, `roundRect`, `ellipse`, `diamond`, `hexagon`, `parallelogram`, `trapezoid`, `triangle`, checked against the [shape geometry](shapes.md)); any other outline (a cylinder, a flag, a stick figure, a pie slice) is a freeform of its exact path.\n- **Labels** are real text in the deck\'s fonts at the preview\'s size, weight, color and baseline, with no wrapping and no autofit. A node\'s label is the node\'s own text, so it moves with the node; other labels are text boxes.\n- **Edges** keep their exact path and arrowheads. A straight edge without arrowheads is a PowerPoint connector glued to the connection sites of the nodes it touches, so it follows a node you move. Every other edge is a freeform of its line and its arrowheads: PowerPoint opens a connector only with one of its preset routes (a connector of freeform geometry makes the file unreadable), and its largest line end is about a fifth shorter than pele\'s arrowhead, so a glued connector would not look like the preview.\n- **Fills and lines** keep their colors, opacity, gradients, widths, dashes, caps and joins.\n- Everything is one group named `OPF diagram N`, with the diagram\'s `alt` as its description.\n\nA diagram family is written as shapes only after PowerPoint\'s drawing of it has been compared with the preview, source by source. Every family below passed: in PowerPoint 365 for Windows, with an example source per family (the ones in this guide where it has one) and a harder one (more nodes, long labels, right to left where the family has a direction), each slide rendered through PowerPoint and compared with the preview pixel by pixel and by eye, in five designs: the engine default (a dark slide in Aptos), a light theme, a serif font scheme (Georgia), a deck in Segoe UI, and a Japanese deck in Yu Gothic for the families that take labels (flowchart, sequence, mind map, timeline, kanban). In every design the shapes, lines and fills match the preview to antialiasing and every label sits where the preview puts it; what differs is the glyphs where the preview draws a font with a stand-in (see below).\n\n| Family | Written as shapes | Family | Written as shapes |\n| --- | --- | --- | --- |\n| Flowchart | yes | Architecture | yes |\n| Sequence | yes | Kanban | yes |\n| Class | yes | Packet | yes |\n| State | yes | Radar | yes |\n| Entity relationship | yes | Treemap | yes |\n| Gantt | yes | Venn | yes |\n| Pie | yes | Ishikawa | yes |\n| Quadrant | yes | Requirement | yes |\n| Mind map | yes | Wardley map | yes |\n| Timeline | yes | Tree view | yes |\n| User journey | yes | Event modeling | yes |\n| XY chart | yes | Railroad | yes |\n| Sankey | yes | Cynefin | yes |\n| Git graph | yes | Use case | yes |\n| C4 | yes | Swimlane | yes |\n| Block | yes | Agent flow | yes |\n\nA DOT diagram is drawn as a flowchart, and a PlantUML diagram as its Mermaid family, so each is written as shapes as that family is. The list is core\'s `DIAGRAM_SHAPE_FAMILIES` (from `@openpresentation/opf/composition`). A diagram stays the picture, with the info finding `pptx/diagram-shapes-unavailable` naming its family and the reason, when:\n\n- its family is not in that list (a new pele diagram type, until it has been compared);\n- its drawing uses something PowerPoint has no native form for: a clip path, a mask, a filter, a pattern, an embedded image, text on a path, or right-to-left text (whose placement PowerPoint decides by its own bidirectional layout).\n\nWhat can differ from the preview is what differs for all of the deck\'s text: where the preview draws a font with a stand-in (Aptos, Segoe UI and Yu Gothic, for example, which OPF does not bundle), PowerPoint draws the real font, so the glyph shapes and weight differ a little, while every line starts, ends and sits where the preview puts it. For a diagram that must be the preview to the pixel, export with `diagrams: "picture"`.\n\n**Editing and import.** The shapes are ordinary PowerPoint shapes: restyle, move or retype them as you like. `fromPptx` reads an unchanged group back as the diagram, with its Mermaid, DOT or PlantUML source and the group\'s current description as `alt`. Once a member is moved, resized, retyped, added or removed, the group imports as its shapes and reports `invalid-diagram-provenance`: the edit is kept and the source is not reconstructed. To keep the source as the truth, edit it in OPF and export again. With `provenance: false` (`--provenance none`) the group carries no source and imports as its shapes.\n\nPowerPoint\'s own "Convert to Shape" on a picture diagram also gives shapes, but that is PowerPoint\'s conversion, not an OPF export, and it does not map back to the diagram. See the [compatibility matrix](compatibility-matrix.md).\n\n## Errors and limits\n\n- A source that cannot be parsed reports a finding with its position in the source, for example `The diagram cannot be drawn (line 2, column 9): Expecting ...`, and the engines draw a "Diagram unavailable" placeholder in the block instead. Fix the source at that line and column.\n- An empty source, a source over **20,000 characters** or a diagram with more than **500 edges** is refused the same way: a slide holds one readable drawing, not a document.\n- In Markdown, an unknown attribute on the fence is `markdown/diagram-attributes`, and an empty fence is `markdown/diagram-source`.\n\n## The engine\n\n[pele](https://pele.run) 1.13.0 (MIT, no runtime dependencies) is the engine; OPF\'s own DOT and PlantUML readers (`dotToMermaid` and `plantumlToMermaid`, from `@openpresentation/opf/composition`, which show the Mermaid a source becomes) hand it DOT graphs and PlantUML diagrams. It is synchronous and does not use the DOM, so the preview, the PDF and the PPTX export need no browser, and the drawing is deterministic for a given source and fonts. Core measures the text with the deck\'s fonts, so line breaks match the rest of the slide.\n\nNode, Bun and Deno load every diagram type with core and draw any diagram at once. A browser bundle or an edge Worker (Cloudflare Workers, Vercel Edge) loads only pele\'s core with OPF (about 12 KB gzipped) and each diagram type the first time a deck draws one (13 to 54 KB gzipped each), and OPF\'s PlantUML reader (about 10 KB gzipped) the first time a deck draws a PlantUML diagram, through the package\'s `#diagram-engine` import map; a Worker that never loads a diagram type does not carry their code. The renderer\'s browser fonts handle loads them in `ensure` (its `pending` lists them as `diagram:<type>`), so `<opf-deck>`, the player, browser export and the editor wait for them as they wait for fonts; `toPptx` loads them itself. A host that validates or draws with `validate`, `composeSlide` or `toSvg` directly calls `await ensureDiagrams(presentation)` (from `@openpresentation/opf` or `@openpresentation/opf/composition`) first; `diagramsPending(presentation)` lists what it would load. Shapes and icon sets load the same way, and one preload covers all three: see [Engines and icon sets that load on demand](how-opf-works.md#engines-and-icon-sets-that-load-on-demand). Until then a diagram draws as a "Loading diagram" placeholder and its source is not checked, which is not a finding.\n\nPele reads Mermaid 12.1 syntax but has its own layout and drawing, so a diagram does not match the pixels of mermaid.js, and an unusual construct may parse in one and not in the other. Write for the OPF drawing: check a diagram in the preview (`opf convert deck.opf.json slide-{n}.png`), not in Mermaid\'s live editor.\n\nPlantUML Gantt schedules refuse durations, offsets or task spans over 36,600 days and more than 366,000 calendar-day checks per diagram. These limits produce a located diagnostic where a source location is available; shorten the schedule or split it into separate diagrams. A calendar with every weekday closed, an invalid date, or a task ending before it starts is refused instead of normalized.\n\nPlantUML state transitions use one arrowhead. Write two separate transitions for both directions; a two-headed state arrow is a source-positioned syntax finding.\n'
|
|
87
|
+
"markdown": '# Diagrams\n\nA `diagram` is a diagram written as text. You write [Mermaid](https://mermaid.js.org), [Graphviz DOT](#graphviz-dot) or [PlantUML](#plantuml) source, and the engines draw it in the deck\'s own fonts and colors, so a flowchart, a sequence of messages or a mind map looks like the rest of the slide and not like a pasted screenshot. This guide covers when to use one, how to write it in JSON, YAML and Markdown, what it looks like, how it is sized, and how it exports. The field reference is [Content payloads](content-payloads.md#diagram); the schema definition is `$defs.Diagram` (`opf schema presentation \'/$defs/Diagram\'`).\n\n## When to use a diagram\n\nChoose the content kind by what the content is, not by how it should look.\n\n| The content is | Use |\n| --- | --- |\n| Steps, a decision flow, systems and how they connect, messages between parties, states and transitions, a hierarchy, an entity model | `diagram` |\n| Numbers plotted on axes or as shares of a whole, where the values should stay editable data | `chart` |\n| Dated or ordered milestones with progress (`done`, `current`, `planned`) | `timeline` (the payload, with its status design) |\n| Parallel entries with details, or a short sequence of one-line steps | a list (`items`) or layout `process` |\n\nA Mermaid `pie` or `timeline` diagram is a quick picture. A `chart` or `timeline` payload keeps the data editable and gets the engines\' chart and timeline design, with highlights and status words. Prefer the payload when it fits and the diagram when only a diagram can show the structure.\n\n## Writing one\n\nA string is shorthand for `{ "source": value }`. The object form adds `alt`, the text alternative, and `syntax`: `"mermaid"` (the default), `"dot"` for a [Graphviz DOT](#graphviz-dot) graph or `"plantuml"` for a [PlantUML](#plantuml) diagram. A diagram is a root payload, a block, or the content of a layout region that accepts it. It takes a `caption` like an image or a chart.\n\n```json\n{\n "title": "Every request is reviewed before it ships",\n "diagram": "flowchart LR\\n A[Request] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| D[Revise]\\n D --> A"\n}\n```\n\nThe slide this draws, in the engine\'s default design:\n\n\n\nWith an `alt` and a caption:\n\n```json\n{\n "title": "A rejected brief returns to its author",\n "diagram": {\n "source": "flowchart LR\\n A[Brief] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| A",\n "alt": "A brief goes to review. Approved work is built; rejected work returns to the brief."\n },\n "caption": "Figure 1. The review loop"\n}\n```\n\n\n\nAs YAML a block scalar keeps the source readable:\n\n```yaml\n- title: Every request is reviewed before it ships\n diagram:\n alt: A request is approved or revised, then built.\n source: |-\n flowchart LR\n A[Request] --> B{Approved?}\n B -->|yes| C[Build]\n B -->|no| D[Revise]\n D --> A\n```\n\nBeside text, give the slide `blocks`; the diagram takes its own cell:\n\n```json\n{\n "title": "The client talks to one API",\n "blocks": [\n { "bullets": ["The client creates a deck with one call", "The API validates it before it answers"] },\n { "diagram": "sequenceDiagram\\n Client->>API: POST /decks\\n API-->>Client: 201 Created" }\n ]\n}\n```\n\n\n\n### In Markdown\n\nA fenced block whose info word is `mermaid` is a diagram, one whose info word is `dot` is a [DOT diagram](#graphviz-dot) (`{ source, syntax: "dot" }`) and one whose info word is `plantuml` a [PlantUML diagram](#plantuml) (`{ source, syntax: "plantuml" }`). An optional `alt="..."` after the word is its text alternative. `toMarkdown` writes a diagram back the same way, so the round trip is lossless.\n\n````markdown\n# Every request is reviewed before it ships\n\n```mermaid alt="A request is approved or revised, then built."\nflowchart LR\n A[Request] --> B{Approved?}\n B -->|yes| C[Build]\n B -->|no| D[Revise]\n D --> A\n```\n````\n\nA source with a blank first or last line, or an `alt` that holds a backtick or a line break, cannot be written as a fence; the writer then uses an `opf-block`, which reads back exactly. See [Markdown and outlines](markdown.md). A runnable deck is [`examples/markdown/diagrams.opf.md`](../examples/markdown/diagrams.opf.md), and the JSON fixture [`examples/technical/diagrams.opf.json`](../examples/technical/diagrams.opf.json) has seven slides.\n\n## Supported Mermaid families\n\nOPF draws diagrams with [pele](https://pele.run), the shared layout/drawing library pinned as `pele@1.13.0` in this source. It parses Mermaid 12.1 syntax. OPF reads the supported DOT and PlantUML subsets itself and adapts them to the same engine; these are not separate Graphviz or PlantUML renderer installations. The first line of the source names the family. All the built-in families are supported; ZenUML is not.\n\n| Family | First line | Shows |\n| --- | --- | --- |\n| Flowchart | `flowchart LR` or `TB` | Steps, decisions and flow |\n| Sequence | `sequenceDiagram` | Messages between participants over time |\n| Class | `classDiagram` | Classes, members and relationships |\n| State | `stateDiagram-v2` | States and transitions |\n| Entity relationship | `erDiagram` | Entities, attributes and cardinalities |\n| Gantt | `gantt` | Tasks on a calendar |\n| Pie | `pie` | Shares of a whole |\n| Quadrant | `quadrantChart` | Points on two axes |\n| Mind map | `mindmap` | A hierarchy of ideas |\n| Timeline | `timeline` | Periods with events, in sections |\n| User journey | `journey` | Tasks with a satisfaction score |\n| XY chart | `xychart` | Bars and lines on axes |\n| Sankey | `sankey` | Flows between nodes |\n| Git graph | `gitGraph` | Commits, branches and merges |\n| C4 | `C4Context` and the other C4 headers | System context, containers, components |\n| Block | `block` | Blocks on a grid |\n| Architecture | `architecture-beta` | Services, groups and connections |\n| Kanban | `kanban` | Columns of cards |\n| Packet | `packet` | Bit fields of a protocol packet |\n| Radar | `radar-beta` | Several measures on radial axes |\n| Treemap | `treemap` | Nested rectangles sized by value |\n| Venn | `venn-beta` | Overlapping sets |\n| Ishikawa | `ishikawa-beta` | Causes of a problem (fishbone) |\n| Requirement | `requirementDiagram` | Requirements and what satisfies them |\n| Wardley map | `wardley-beta` | Components by visibility and evolution |\n| Tree view | `treeView-beta` | A folder-style hierarchy |\n| Event modeling | `eventmodeling` | Commands, events and views along a timeline |\n| Railroad | `railroad-beta` (also `railroad-ebnf-beta`, `railroad-abnf-beta`, `railroad-peg-beta`) | The syntax of a grammar |\n| Cynefin | `cynefin-beta` | Items placed in the Cynefin domains |\n| Use case | `usecase-beta` | Actors, use cases and system boundaries |\n| Swimlane | `swimlane-beta` | A flowchart in lanes |\n| Agent flow | `agentflow-beta` | The steps and tools of an agent workflow |\n\nThe six most useful, each as a complete source and the slide it draws in the default design:\n\n````text\nflowchart LR\n A[Idea] --> B{Worth testing?}\n B -->|yes| C[Prototype]\n B -->|no| D[Park it]\n````\n\n\n\n````text\nsequenceDiagram\n Client->>API: POST /decks\n API-->>Client: 201 Created\n````\n\n\n\n````text\nmindmap\n root((Strategy))\n Growth\n Efficiency\n People\n````\n\n\n\n````text\ntimeline\n title Regional rollout\n section Pilot\n 2026 Q1 : One operations team\n section Rollout\n 2026 Q3 : All regions\n````\n\n\n\n````text\nstateDiagram-v2\n [*] --> Queued\n Queued --> Building\n Building --> Live: success\n Building --> Failed: error\n Failed --> Queued: retry\n````\n\n\n\n````text\njourney\n title Onboarding\n section Sign up\n Create an account: 5: New user\n Verify the email: 3: New user\n section First week\n Build a first deck: 4: New user\n````\n\n\n\nFor the full syntax of each family, read the [Mermaid documentation](https://mermaid.js.org/intro/); pele follows it, but draws with its own layout (see [The engine](#the-engine)).\n\n## Graphviz DOT\n\nA [DOT](https://graphviz.org/doc/info/lang.html) graph (`graph` or `digraph`) is a diagram with `syntax: "dot"`. OPF reads the DOT language itself and gives the graph to pele\'s layered layout, the one that draws a Mermaid flowchart, so a DOT diagram is laid out in ranks as Graphviz\'s `dot` engine lays it out, sized, styled and exported exactly as a flowchart is. No Graphviz code ships or runs (Graphviz is EPL-2.0), and the drawing is pele\'s, so it does not match the pixels of a Graphviz rendering.\n\n```json\n{\n "title": "Every change passes the same pipeline",\n "diagram": {\n "syntax": "dot",\n "source": "digraph release {\\n rankdir=LR\\n node [shape=box, style=rounded]\\n subgraph cluster_ci {\\n label=\\"Continuous integration\\"\\n Commit -> Build -> Test\\n }\\n Review [shape=diamond, label=\\"Approved?\\"]\\n Test -> Review [label=\\"passes\\"]\\n Test -> Build [label=\\"fails\\", style=dashed]\\n Review -> Release [label=\\"yes\\"]\\n Release [shape=ellipse]\\n}"\n }\n}\n```\n\n\n\nIn Markdown, the `dot` fence:\n\n````markdown\n# A deck moves from draft to published\n\n```dot alt="A draft is submitted for review; review approves it or sends it back."\ndigraph states {\n rankdir=LR\n node [shape=circle]\n Draft -> Review [label="submit"]\n Review -> Draft [label="changes"]\n Review -> Published [label="approve"]\n Published [shape=doublecircle]\n}\n```\n````\n\n\n\nA runnable deck is [`examples/technical/dot-diagrams.opf.json`](../examples/technical/dot-diagrams.opf.json).\n\nWhat OPF draws from a DOT source:\n\n| DOT | Drawn as |\n| --- | --- |\n| `digraph` and `->`, `graph` and `--`, `strict` | Edges with an arrowhead in a digraph and without one in a graph; `strict` draws a repeated edge once |\n| `rankdir` (`TB`, `LR`, `BT`, `RL`) | The direction the ranks run (top to bottom by default) |\n| `label` on the graph | The diagram\'s title, drawn above it |\n| `subgraph cluster_*` (or `cluster=true`) and its `label` | A labeled group around its nodes, nested as written; a node is in the innermost cluster that mentions it. Other subgraphs only group statements (`rank=same` is not kept) |\n| `node [...]`, `edge [...]`, `graph [...]` | Defaults for the statements after them, scoped to their subgraph |\n| Node `label` | The node\'s text: `\\n`, `\\l` and `\\r` break lines, `\\N`, `\\G`, `\\E`, `\\T` and `\\H` are the node, graph, edge, tail and head names; a record\'s fields (`{a\\|b\\|<p> c}`) are its lines; an HTML-like label is read as text (`<br/>` breaks a line) |\n| Node `shape` | The shapes in the table below |\n| Node `style` | `rounded` rounds a box, `dashed` and `dotted` dash the outline, `bold` thickens it, `invis` leaves the node and its edges out |\n| Edge `label` (or `xlabel`) | The edge\'s label |\n| Edge `style` and `penwidth` | `dashed` and `dotted` are a dashed line, `bold` or a `penwidth` of 2 or more a thick one, `invis` an edge that only places its nodes |\n| `arrowhead`, `arrowtail`, `dir` | `none` is no marker, the `dot` and `odot` arrows a circle, `tee` and `box` a cross, every other arrow type an arrowhead; `dir=both` draws both ends (with the head\'s marker), `dir=none` neither, and `dir=back` draws the edge from its head to its tail, which the layout then ranks that way |\n| `minlen` | The number of ranks the edge spans (up to 8) |\n| Ports (`a:p:n`) | Read and not kept: the layout decides where an edge meets its node |\n\n| DOT shape | Drawn as | PowerPoint shape |\n| --- | --- | --- |\n| `box`, `rect`, `rectangle`, `square`, `Msquare`, `record` | A rounded box | Rounded rectangle |\n| `Mrecord`, `box` with `style=rounded` | A box with rounder corners | Rounded rectangle |\n| `ellipse` (the default), `oval`, `egg` | A stadium, which holds its label as an ellipse does | Rounded rectangle (fully rounded) |\n| `circle`, `Mcircle`, `doublecircle`, `point` | A circle, a double circle, a small filled circle | Ellipse |\n| `diamond`, `Mdiamond` | A diamond | Diamond |\n| `hexagon`, `octagon`, `doubleoctagon`, `tripleoctagon`, `septagon` | A hexagon | Hexagon |\n| `parallelogram`, `trapezium`, `invtrapezium` | A parallelogram, a trapezoid, an inverted trapezoid | Parallelogram, trapezoid, freeform |\n| `triangle`, `invtriangle` | A triangle, an inverted triangle | Triangle, freeform |\n| `cylinder`, `note`, `tab`, `folder` | A cylinder, a card with a cut corner, a folder | Freeform |\n| `box3d`, `component` | Stacked boxes, a framed box | Rounded rectangles and lines |\n| `plaintext`, `plain`, `none`, `underline` | Text without an outline | Text box |\n| Any other shape (`house`, `star`, `cds`, ...) | A rounded box | Rounded rectangle |\n\nThe deck decides colors, fonts and sizes, as it does for Mermaid: `color`, `fillcolor`, `fontcolor`, `fontname`, `fontsize`, `bgcolor`, `width`, `height`, `pos` and the other attributes of Graphviz\'s drawing are read and ignored, and so are `style=filled`, `constraint`, `weight`, `splines` and `rank`.\n\n**Layouts OPF does not draw are refused, not approximated.** A graph whose `layout` attribute names another Graphviz engine (`neato`, `fdp`, `sfdp`, `circo`, `twopi`, `osage`, `patchwork`) is not drawn: the slide reports a finding at the attribute\'s line and column ("OPF draws DOT graphs with a layered layout, as Graphviz\'s dot engine does; the neato layout is not drawn ...") and the engines draw the "Diagram unavailable" placeholder. Remove the attribute, or write `layout=dot`, to draw the graph in layers. An HTML-like label that holds a `<table>` is refused the same way; write the label as text, or as a record.\n\nIn a double-quoted string `\\"` is a quote and a backslash before a line break continues the line; every other backslash pair (`\\\\`, `\\n`, `\\l`, `\\N`) is a label escape, so `"c:\\\\"` is the text `c:\\`. Text arrives as written, backticks included.\n\nA DOT source holds one graph, at most 20,000 characters, 500 edges and 16 levels of nested subgraphs. A syntax error is a finding with its line and column in the DOT source; if pele rejects what OPF made of a source, the finding says so without a position (pele\'s would be in generated text).\n\n## PlantUML\n\nA [PlantUML](https://plantuml.com) diagram is a diagram with `syntax: "plantuml"`, written from its `@start` line to its `@end` line. OPF reads PlantUML itself and draws each kind as the Mermaid family of the same kind, so a PlantUML diagram is laid out by pele, sized, styled and exported exactly as that family is. No PlantUML code ships or runs (PlantUML is GPL), and the drawing is pele\'s, so it does not match the pixels of a PlantUML rendering.\n\n```json\n{\n "title": "The API answers every request with findings",\n "diagram": {\n "syntax": "plantuml",\n "source": "@startuml\\nactor Author\\nparticipant \\"Deck API\\" as API\\ndatabase Store\\nAuthor -> API : POST /decks\\nAPI -> Store : save\\nStore --> API : id\\nalt valid\\n API --> Author : 201 Created\\nelse invalid\\n API --> Author : 422 findings\\nend\\n@enduml"\n }\n}\n```\n\n\n\nIn Markdown, the `plantuml` fence:\n\n````markdown\n# Every brief is reviewed before it is built\n\n```plantuml\n@startuml\nstart\n:Write the brief;\nif (Approved?) then (yes)\n :Build the deck;\nelse (no)\n :Revise it;\nendif\nstop\n@enduml\n```\n````\n\n\n\nA runnable deck with every kind is [`examples/technical/plantuml-diagrams.opf.json`](../examples/technical/plantuml-diagrams.opf.json).\n\nThe kinds OPF draws, and what it reads of each:\n\n| PlantUML diagram | Drawn as | What is read |\n| --- | --- | --- |\n| Sequence (`participant`, `A -> B : message`) | Sequence | `participant`, `actor`, `boundary`, `control`, `entity`, `database`, `collections` and `queue` with `as` names; messages `->`, `-->` (dashed), `->>`, `-\\` and `-/` (the last three are drawn with the open head), `->x`, `<-`, `<->`; `++` and `--` activations, `activate`, `deactivate`, `create`, `destroy`, `return`; `alt`/`else`, `opt`, `loop`, `par`, `break`, `critical` and `group`; notes (`left of`, `right of`, `over`, one line or a block); `ref over`; `== dividers ==` and `...delays...` as notes over every participant; `box`; `autonumber` (plain; numbers from 1); `title` |\n| Class (`class`, `interface`, `enum`) | Class | Classes, abstract classes, interfaces, enums, annotations and the other class keywords, with `as` names, generics and stereotypes; members in braces or as `Name : member`, `{static}` and `{abstract}`; `extends` and `implements`; relations `<|--`, `<|..`, `*--`, `o--`, `-->`, `..>`, `--`, `..` (both ways) with cardinalities and labels; notes on a class and a floating `note "text" as N` that no link refers to; packages and namespaces |\n| State (`[*]`, `state`) | State | States with `as` names and descriptions, transitions with events, composite states, `--` and `||` regions, `<<choice>>`, `<<fork>>` and `<<join>>`, notes left of or right of a state, `left to right direction` |\n| Activity, the current syntax (`start`, `:action;`, `stop`) | Flowchart | `start`, `stop`, `end`, `kill`, `detach`; actions over one or several lines (an SDL ending `|`, `<`, `>`, `/`, `]` or `}` picks the shape); `if`/`elseif`/`else`/`endif`, `switch`/`case`, `while`/`endwhile`, `repeat`/`repeat while`, `fork`/`fork again`/`end fork` (bars), `split`; arrow labels (`-> label;`); `partition` and `group` blocks and `|swimlanes|` as groups; notes beside the last action; `(A)` connectors |\n| Use case (`actor`, `(use case)`) | Use case | Actors (`actor`, `:Name:`), use cases (`usecase`, `(Name)`) with `as` names (including `(Use the application) as (Use)`), `rectangle` and `package` boundaries around use cases (one level; a nested one is drawn beside its parent; an actor written inside a boundary is drawn outside it, and a boundary with no use case is not drawn), associations with labels, `<<include>>` and `<<extend>>` on dotted links, generalization, notes left of, right of, top of or bottom of an element, `left to right direction` |\n| Component and deployment (`[Component]`, `node`, `database`) | Flowchart | `[Component]`, `component`, `() Interface`, `interface`, `database`, `node`, `cloud`, `artifact`, `folder`, `queue`, `actor` and the other element keywords as shapes; `package`, `node`, `folder`, `frame`, `cloud`, `database` and `rectangle` blocks as groups (named, with `as`, or unnamed: `cloud {`), which a link can name; links with their line (`--`, `..`, `==`, `-[hidden]-`), direction, ends and labels; notes left of, right of, top of or bottom of an element |\n| Mind map (`@startmindmap`) | Mind map | `*` depth (and `+` and `-` for the two sides), Markdown indentation, boxless `*_` nodes as square ones, multi-line `:text;` nodes |\n| Gantt (`@startgantt`) | Gantt | `Project starts`, tasks that `last` or `require` days or weeks, `starts` and `ends` on a date or at another task\'s start or end (with days before or after), `then`, milestones that `happen`, `is N% complete` (100% done, more than 0 active), `-- sections --`, closed weekdays and dates. OPF schedules the tasks in working days and writes their dates; without `Project starts`, the days are numbered from 1 |\n\nIn `participant Participant as Foo`, `Foo` is the name later lines use and `Participant` is what is drawn (PlantUML\'s own example); a quoted side is always what is drawn (`participant "Web App" as W`, `participant W as "Web App"`). The same holds for classes, states, use cases, actors, components and gantt tasks (`[Prototype design] as [D1]`).\n\nPlantUML\'s styling is ignored, as Mermaid\'s themes are: `skinparam`, `!theme`, `<style>`, colors, `hide` and `show`, `scale`, headers, footers, captions, legends, `mainframe` and `autoactivate` (no activation bars). A keyword is a statement only in its own shape: an element named `Header`, `Show`, `Title`, `Node` or `Group` keeps its messages and relations. Spacing lines (`...`, `|||`, `||45||`) are ignored, since the layout spaces the messages; `...text...` and `== text ==` are notes.\n\n**What OPF does not draw is refused, not approximated.** The other PlantUML diagrams (timing, object, network, ArchiMate, entity relationship, Salt, JSON, YAML, work breakdown structures and the other `@start` kinds), the legacy activity syntax (`(*) --> "First"`), messages from outside a sequence diagram (`[->`), circle ends (`->o`), a cross or half head on a double-headed message, `autonumber` with arguments, `newpage`, history states (`[H]`), `label` and `goto`, `hide @unlinked` and `hide <<stereotype>>`, notes on a link or floating notes that a link names (a lone floating class note is drawn), a note above or below a state, a gantt `pauses` or `is deleted`, a ** after a message, a second diagram in one source, and the preprocessor (`!include`, `!define`, `!function`, `$variables`) report a finding at their line ("OPF does not draw PlantUML timing diagrams; it draws sequence, class, state, ...") and the engines draw the "Diagram unavailable" placeholder. So does a line OPF cannot read in a diagram it draws.\n\n`return` answers the call of the latest activation (`++`, `activate`) and deactivates it; without one it replies to the last unanswered call. A `destroy` followed by messages of others is drawn with the last message to or from the destroyed participant, as pele requires. If pele rejects what OPF made of a source, the finding says so without a position (pele\'s would be in generated text).\n\nA PlantUML source holds one diagram, at most 20,000 characters (2,000 on a line), 500 messages, relations or arrows, and 16 levels of nested blocks.\n\n## How the deck styles a diagram\n\nThe deck decides colors and fonts, so a diagram follows the slide it sits on:\n\n- **Node fills** are tints of the first accent of the slide\'s color scheme, in the slide variant\'s order, mixed over the surface the diagram sits on. That surface is the card when the block has one (see `emphasis` and cards in [Layout templates](layout-templates.md)), otherwise the slide background.\n- **Outlines and connectors** mix toward the accent and the text color, with enough contrast to read as structure without competing with the labels.\n- **Data series** (pie slices, xychart series, timeline sections, mind map branches and the like) use the same chart series palette as the slide\'s charts: the color scheme\'s accents in the variant\'s order.\n- **Text** keeps 4.5:1 against its fill.\n- **Fonts.** Labels use the font scheme\'s body font, and code-like labels (class members, for example) its code font.\n- **Dark backgrounds, dark variants and color maps** adapt with no change to the source: `design.variant: "dark1"` on a slide redraws its diagram from the dark surface.\n\nThe same slide, with the same source, in four designs from the default catalog:\n\n```json\n{\n "title": "Every request is reviewed before it ships",\n "diagram": "flowchart LR\\n A[Request] --> B{Approved?}\\n B -->|yes| C[Build]\\n B -->|no| D[Revise]\\n D --> A\\n C --> E[Test]\\n E --> F{Passes?}\\n F -->|yes| G[Release]\\n F -->|no| C"\n}\n```\n\n| `classic`, `forest-green`, `aptos` | `bold`, `deep-purple`, `montserrat` |\n| --- | --- |\n|  |  |\n| **`minimal`, `burnt-orange`, `georgia`** | **`classic`, `steel-blue`, `open-sans`, slide `design.variant: "dark1"`** |\n|  |  |\n\nEvery image in this guide is the renderer\'s own SVG output for the source above it, drawn by `scripts/build-diagram-doc-images.mjs` (`pnpm check:diagram-doc-images` keeps them current).\n\nMermaid\'s own theming (`%%{init: ...}%%`, themes, `themeVariables`) and click callbacks are ignored. Authored `style`, `classDef` and C4 `UpdateElementStyle` colors are the exception: pele applies them and OPF\'s painter keeps them, so a shape with an authored color no longer follows the deck\'s colors, variant or contrast rules. Leave them out and let the deck decide; if one shape must stand out, prefer a different node shape or a label to a color.\n\n## Sizing\n\nCore lays a diagram out for its block with the deck\'s measured fonts, the same way it fits text:\n\n1. It tries the largest base size from 32 reference pixels down at which the drawing fits the block. A small diagram grows to the size of a list; a large one steps down.\n2. Node labels never go below the readability floor (`minFontSize`, 16 reference pixels by default). The smallest secondary label (an edge label, an axis tick, a score) never goes below 75% of it.\n3. A diagram is centered in its block. A region anchored to the bottom places it there.\n4. Pele lays the diagram out for the width it has, so a smaller size is a new layout, not a shrunken picture: a wide flowchart may turn to run downward.\n\nWhen the diagram does not fit even at the floor, a flowchart or a state diagram is first tried in the other main direction (`LR` and `TB` swap, `RL` and `BT` swap; a state diagram without a `direction` is top to bottom, so it tries `direction LR`). If the labels reach the floor there, the diagram is drawn that way and the slide reports an `arrangement-adapted` info finding ("The flowchart is drawn top to bottom because left to right does not fit at the readability floor"). This applies to a direction the author wrote too: the source keeps its text, only the drawing turns, and the preview and the PPTX export draw the same turned layout. A diagram that fits as written is never turned.\n\nWhen no direction holds the labels at the floor (or the diagram type has no direction), the diagram as written is drawn smaller to stay inside its block, and the slide reports a `text-overflow` finding at the diagram\'s path, naming the directions tried. Fix it in the content, not in `minFontSize`:\n\n- give the diagram a slide or a region of its own, or put it beside short text rather than under long text;\n- split it into two diagrams, or shorten the labels.\n\n`opf validate` reports both findings, `text-overflow` and `arrangement-adapted`, whether or not `@openpresentation/opf-render` is installed, because it composes every slide and lays each diagram out. With the renderer it measures with the fonts `opf convert` draws with (the report says `layout (measured)`); without it, with core\'s portable estimate (`layout (estimated)`, and a hint says how to install the renderer). The two can disagree for a diagram near the limit: a flowchart of ten one-word branches gets `arrangement-adapted` measured and `text-overflow` estimated (checked 2026-11-14, CLI 0.34.0). Treat an estimated result as provisional and run `opf validate` or `opf convert` with the renderer installed for the final answer.\n\n### Write for readable labels\n\nA diagram is the slide\'s main content, so write it to be read from the back of a room: few nodes, few hops, short labels. Measured with this repository\'s renderer (core 0.34.0, `opf convert` to SVG, a titled slide at 1280 x 720 with the diagram alone in the body; sizes are reference pixels, 32 is the most a label gets and 16 the floor, a body list is 28 to 32):\n\n| Flowchart (nodes, longest path in hops) | Labels of one or two words | Labels of three or four words |\n| --- | --- | --- |\n| 3 nodes in a row | 32 | 32 |\n| 4 in a row | 32 | 21 |\n| 5 in a row | 32 | 17 |\n| 6 in a row | 27 | 15 (under the floor, `text-overflow`) |\n| 8 in a row | 20 | 11 (`text-overflow`) |\n| 10 in a row | 16 | 9 (`text-overflow`) |\n| 7 nodes, one parent with three children, each with one child (written `TB` or `LR`) | 32 | not measured |\n| 10 nodes in a tree three levels deep | 18 to 25 (`LR` 25, `TB` 18) | not measured |\n\nWhat the numbers say, and so what to write:\n\n- **Keep to 3 to 6 nodes on a slide, and to one or two words a label.** That keeps labels at 27 pixels or more, close to the body text. At 8 nodes labels are 20 pixels and the diagram reads as small print beside the slide\'s title; at 10 nodes they are at the floor.\n- **A label of three or four words costs about as much as two more nodes.** Put the detail in the slide\'s text or notes, or in a second slide, and keep the node to the noun.\n- **Split a long flow over several slides** (one stage or one decision per slide, each with its own title that says what happens there) instead of writing one chain of 8 or more. Each part is then drawn at 32.\n- **Direction follows the shape, and the engine tries both.** A chain is drawn best left to right on a wide slide: five nodes in a row are 32 pixels left to right and 18 top to bottom, because the slide is shorter than it is wide. A parent with many children is the other way: one parent with five children is 20 pixels left to right and 32 top to bottom. Write `TB` for a fan-out or a hierarchy and `LR` for a sequence; do not turn a long chain top to bottom to make it fit, and do not rely on the engine\'s turn (`arrangement-adapted`) to save a diagram that has too many nodes.\n- **Do not shrink to fit.** Never lower `minFontSize` or draw a diagram in a small region so that a large one fits; fewer nodes and shorter labels is the fix, and a `text-overflow` finding on a diagram means the slide has too much in it.\n- **Give the diagram the slide.** A title and the diagram, or the diagram beside a few short lines, not a diagram under a paragraph.\n\n### Layouts that accept a diagram\n\nA layout region lists the kinds it `accepts` ([Layout templates](layout-templates.md#regions)); `diagram` is one of them. In the default catalog these regions take a diagram:\n\n| Layout | Region |\n| --- | --- |\n| `charts` | `chart` |\n| `chart` | `chart-beside` |\n| `media`, `image-beside`, `hero` | `image` |\n| `comparison`, `two-column` | `first` and `second` |\n| `three-column` | the three columns |\n| `process` | `steps` |\n| `timeline` | `timeline` |\n\nA block binds to a region by kind, role and reading order ([Binding content to regions](layout-templates.md#binding-content-to-regions)); a slide that pins a diagram to a region that does not accept it gets the warning `opf/region-kind` and the block is bound by kind instead.\n\n## Accessibility\n\n`alt` is the text alternative: say what the diagram shows, not that it is a diagram ("A brief goes to review; approved work is built, rejected work returns to the brief."). Without `alt`, engines derive one from the diagram type and its labels (for example "Flowchart: Request, Approved?, Build, Revise"), up to 400 characters. The preview draws the diagram as one `role="img"` named by that text, and the PPTX export writes it as the description of the picture (or of the group of shapes).\n\n## Exports\n\n| Output | What you get |\n| --- | --- |\n| SVG preview | The diagram as vector shapes and text in the slide\'s colors and fonts |\n| PNG | The preview rasterized |\n| PDF | Vector; the diagram\'s labels stay selectable text |\n| PPTX (the default, `diagrams: "shapes"`) | Native PowerPoint shapes, connectors and text in one group, drawn from the preview\'s own geometry, `alt` as the group\'s description. `fromPptx` brings an unchanged group back as a `diagram`, a DOT or PlantUML diagram with its own source. A diagram that cannot be written as shapes is the picture below. |\n| PPTX, `diagrams: "picture"` | A native SVG picture with a PNG fallback: crisp at any size, recolorable as a picture in PowerPoint, `alt` as the picture\'s description. `fromPptx` brings it back as a `diagram`. |\n\n### Native shapes in PowerPoint\n\nThe PPTX export writes each diagram as editable PowerPoint shapes that look like the preview (`diagrams: "shapes"`, the default). To get one SVG picture per diagram instead, as earlier releases did, opt out:\n\n```js\nconst bytes = await toPptx(deck, { diagrams: "picture" });\nawait convert(deck, "deck.pptx", { diagrams: "picture" });\n```\n\n```sh\nopf convert deck.opf.json deck.pptx --diagrams picture\n```\n\nThe shapes are built from pele\'s laid-out drawing, the same geometry the preview draws, never a second layout or PowerPoint\'s connector routing:\n\n- **Nodes** are shapes. An outline that is exactly a PowerPoint preset is that preset (`rect`, `roundRect`, `ellipse`, `diamond`, `hexagon`, `parallelogram`, `trapezoid`, `triangle`, checked against the [shape geometry](shapes.md)); any other outline (a cylinder, a flag, a stick figure, a pie slice) is a freeform of its exact path.\n- **Labels** are real text in the deck\'s fonts at the preview\'s size, weight, color and baseline, with no wrapping and no autofit. A node\'s label is the node\'s own text, so it moves with the node; other labels are text boxes.\n- **Edges** keep their exact path and arrowheads. A straight edge without arrowheads is a PowerPoint connector glued to the connection sites of the nodes it touches, so it follows a node you move. Every other edge is a freeform of its line and its arrowheads: PowerPoint opens a connector only with one of its preset routes (a connector of freeform geometry makes the file unreadable), and its largest line end is about a fifth shorter than pele\'s arrowhead, so a glued connector would not look like the preview.\n- **Fills and lines** keep their colors, opacity, gradients, widths, dashes, caps and joins.\n- Everything is one group named `OPF diagram N`, with the diagram\'s `alt` as its description.\n\nA diagram family is written as shapes only after PowerPoint\'s drawing of it has been compared with the preview, source by source. Every family below passed: in PowerPoint 365 for Windows, with an example source per family (the ones in this guide where it has one) and a harder one (more nodes, long labels, right to left where the family has a direction), each slide rendered through PowerPoint and compared with the preview pixel by pixel and by eye, in five designs: the engine default (a dark slide in Aptos), a light theme, a serif font scheme (Georgia), a deck in Segoe UI, and a Japanese deck in Yu Gothic for the families that take labels (flowchart, sequence, mind map, timeline, kanban). In every design the shapes, lines and fills match the preview to antialiasing and every label sits where the preview puts it; what differs is the glyphs where the preview draws a font with a stand-in (see below).\n\n| Family | Written as shapes | Family | Written as shapes |\n| --- | --- | --- | --- |\n| Flowchart | yes | Architecture | yes |\n| Sequence | yes | Kanban | yes |\n| Class | yes | Packet | yes |\n| State | yes | Radar | yes |\n| Entity relationship | yes | Treemap | yes |\n| Gantt | yes | Venn | yes |\n| Pie | yes | Ishikawa | yes |\n| Quadrant | yes | Requirement | yes |\n| Mind map | yes | Wardley map | yes |\n| Timeline | yes | Tree view | yes |\n| User journey | yes | Event modeling | yes |\n| XY chart | yes | Railroad | yes |\n| Sankey | yes | Cynefin | yes |\n| Git graph | yes | Use case | yes |\n| C4 | yes | Swimlane | yes |\n| Block | yes | Agent flow | yes |\n\nA DOT diagram is drawn as a flowchart, and a PlantUML diagram as its Mermaid family, so each is written as shapes as that family is. The list is core\'s `DIAGRAM_SHAPE_FAMILIES` (from `@openpresentation/opf/composition`). A diagram stays the picture, with the info finding `pptx/diagram-shapes-unavailable` naming its family and the reason, when:\n\n- its family is not in that list (a new pele diagram type, until it has been compared);\n- its drawing uses something PowerPoint has no native form for: a clip path, a mask, a filter, a pattern, an embedded image, text on a path, or right-to-left text (whose placement PowerPoint decides by its own bidirectional layout).\n\nWhat can differ from the preview is what differs for all of the deck\'s text: where the preview draws a font with a stand-in (Aptos, Segoe UI and Yu Gothic, for example, which OPF does not bundle), PowerPoint draws the real font, so the glyph shapes and weight differ a little, while every line starts, ends and sits where the preview puts it. For a diagram that must be the preview to the pixel, export with `diagrams: "picture"`.\n\n**Editing and import.** The shapes are ordinary PowerPoint shapes: restyle, move or retype them as you like. `fromPptx` reads an unchanged group back as the diagram, with its Mermaid, DOT or PlantUML source and the group\'s current description as `alt`. Once a member is moved, resized, retyped, added or removed, the group imports as its shapes and reports `invalid-diagram-provenance`: the edit is kept and the source is not reconstructed. To keep the source as the truth, edit it in OPF and export again. With `provenance: false` (`--provenance none`) the group carries no source and imports as its shapes.\n\nPowerPoint\'s own "Convert to Shape" on a picture diagram also gives shapes, but that is PowerPoint\'s conversion, not an OPF export, and it does not map back to the diagram. See the [compatibility matrix](compatibility-matrix.md).\n\n## Errors and limits\n\n- A source that cannot be parsed reports a finding with its position in the source, for example `The diagram cannot be drawn (line 2, column 9): Expecting ...`, and the engines draw a "Diagram unavailable" placeholder in the block instead. Fix the source at that line and column.\n- An empty source, a source over **20,000 characters** or a diagram with more than **500 edges** is refused the same way: a slide holds one readable drawing, not a document.\n- In Markdown, an unknown attribute on the fence is `markdown/diagram-attributes`, and an empty fence is `markdown/diagram-source`.\n\n## The engine\n\n[pele](https://pele.run) 1.13.0 (MIT, no runtime dependencies) is the engine; OPF\'s own DOT and PlantUML readers (`dotToMermaid` and `plantumlToMermaid`, from `@openpresentation/opf/composition`, which show the Mermaid a source becomes) hand it DOT graphs and PlantUML diagrams. It is synchronous and does not use the DOM, so the preview, the PDF and the PPTX export need no browser, and the drawing is deterministic for a given source and fonts. Core measures the text with the deck\'s fonts, so line breaks match the rest of the slide.\n\nNode, Bun and Deno load every diagram type with core and draw any diagram at once. A browser bundle or an edge Worker (Cloudflare Workers, Vercel Edge) loads only pele\'s core with OPF (about 12 KB gzipped) and each diagram type the first time a deck draws one (13 to 54 KB gzipped each), and OPF\'s PlantUML reader (about 10 KB gzipped) the first time a deck draws a PlantUML diagram, through the package\'s `#diagram-engine` import map; a Worker that never loads a diagram type does not carry their code. The renderer\'s browser fonts handle loads them in `ensure` (its `pending` lists them as `diagram:<type>`), so `<opf-deck>`, the player, browser export and the editor wait for them as they wait for fonts; `toPptx` loads them itself. A host that validates or draws with `validate`, `composeSlide` or `toSvg` directly calls `await ensureDiagrams(presentation)` (from `@openpresentation/opf` or `@openpresentation/opf/composition`) first; `diagramsPending(presentation)` lists what it would load. Shapes and icon sets load the same way, and one preload covers all three: see [Engines and icon sets that load on demand](how-opf-works.md#engines-and-icon-sets-that-load-on-demand). Until then a diagram draws as a "Loading diagram" placeholder and its source is not checked, which is not a finding.\n\nPele reads Mermaid 12.1 syntax but has its own layout and drawing, so a diagram does not match the pixels of mermaid.js, and an unusual construct may parse in one and not in the other. Write for the OPF drawing: check a diagram in the preview (`opf convert deck.opf.json slide-{n}.png`), not in Mermaid\'s live editor.\n\nPlantUML Gantt schedules refuse durations, offsets or task spans over 36,600 days and more than 366,000 calendar-day checks per diagram. These limits produce a located diagnostic where a source location is available; shorten the schedule or split it into separate diagrams. A calendar with every weekday closed, an invalid date, or a task ending before it starts is refused instead of normalized.\n\nPlantUML state transitions use one arrowhead. Write two separate transitions for both directions; a two-headed state arrow is a source-positioned syntax finding.\n'
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"slug": "dynamic-composition",
|
|
@@ -96,7 +96,7 @@ var docsData = Object.freeze([
|
|
|
96
96
|
"slug": "ecosystem-development",
|
|
97
97
|
"file": "docs/ecosystem-development.md",
|
|
98
98
|
"title": "Local development across the packages",
|
|
99
|
-
"markdown": "# Local development across the packages\n\nUse Node 24 for the current source and published packages. All six packages live in this repository, one pnpm workspace, so there is nothing to link: `workspace:` dependencies resolve to the sibling directories, and a change that touches several packages is built and tested together.\n\n```sh\npnpm install\npnpm build # every package, in dependency order\npnpm check:changed # only what your branch changed (the check to run after each change)\npnpm test # everything; CI and the last run before a pull request\npnpm test:integration # the private tests that need several packages at once\n```\n\nFor a cheap checkout of one task (small blobless worktree, one shared pnpm store), use `node scripts/agent-worktree.mjs add <task>`.\n\nCI is `verify` (`.github/workflows/ci.yml`): one required check that runs the packages your change affects, with their dependents at the contract tier (`test:contract` of each package); `nightly.yml` runs the Windows, macOS, Node 22 and 26, packed-install and npm 12 consumer legs (the packed packages installed by npm 12 with its defaults: no install scripts, no git or remote dependencies; `pnpm test:npm12-consumer`) and the weekly `slow-checks.yml` the published-package consumers. See [the CI design](programs/monorepo/ci-design.md). Add the label `full-ci` to a pull request that touches OS- or Node-version-specific code (it starts `full-ci.yml`, which runs the nightly legs on the pull request; it is not part of `verify`). There is no `Depends-On`, no lock to roll and no merge queue.\n\nOn Windows, keep the checkout under a short path (esbuild and Biome exceed MAX_PATH deeper) and see the notes in `AGENTS.md`. npm and pnpm orchestration in the scripts invokes the package manager's JavaScript entrypoint with the selected Node runtime instead of a batch shim through a shell, so paths with spaces and shell metacharacters stay literal arguments.\n\nExecute the installed-package browser harnesses after their corresponding build:\n\n```sh\npnpm test:packages\npnpm test:packed-browser\npnpm test:registry-ecosystem\npnpm test:packed-browser registry\n```\n\nThe renderer package supplies the locked Playwright test dependency. Install Chromium with `pnpm --filter @openpresentation/opf-render exec playwright install --with-deps chromium` on Linux. Local Windows runs use Edge; `OPF_BROWSER_CHANNEL` can explicitly select another installed Playwright channel. CI uses the matching official Playwright container pinned by digest (one string in every workflow, `pnpm check:playwright-pin`), without installing OS packages during each run.\n\nEach build writes `artifacts/editor/packed-browser-manifest.json` with the mode, installed versions, consumer build ID, dependency-lock hash and exact font/HTML/JavaScript hashes. The runner rejects a different mode, stale consumer or changed asset. It serves only the verified bytes on loopback and rejects external requests and network writes. Rebuild before switching between candidate and registry modes. Reports include the browser and Node versions and are saved by mode/runtime; failures retain a screenshot.\n\n`node scripts/test-packed-browser-guards.mjs` verifies those four rejection cases against the current disposable harness and restores each changed fixture byte-for-byte. CI runs it after the registry browser checks.\n\nSeven suites exercise canvas, rich text, lists, creation, layout, block moves and styled tables. Real browser input covers divider resizing/cancellation/concurrent changes, block dragging, merged-cell typing/redo/undo, plain-to-rich conversion and bold formatting, and empty-cell typing/undo. Conversion and formatting currently create separate undo transactions. Harness DOM assertions also cover renderer agreement and preservation. These checks do not replace full application export/reimport, public deployment checks or native PowerPoint raster evidence.\n\n`pnpm test:ecosystem` validates the dynamic composition fixture, edits and undoes a composition, renders SVG/PNG/PDF, exports editable PPTX, checks OOXML text-box coordinates against the shared geometry, and imports the result back into schema-valid OPF. Artifacts are written to a temporary directory and its location is printed. For full gallery render coverage, run `pnpm test:gallery -- --render` (or invoke the script with `--render`): it validates all generated documents and can render them with the local SVG engine.\n\n`pnpm test:pagination` verifies long-text and table pagination through SVG and editable PPTX, including exact source reconstruction, table row counts, and absence of extra exporter-created pages. It writes review artifacts under `artifacts/pagination/`.\n\n`pnpm test:fonts` verifies actual-font measurement across editor, SVG, pagination, and PPTX. It also runs the offline font-switch matrix (`scripts/test-font-switch-ecosystem.mjs`, FF-09): a seeded pairwise covering array of 58 decks over the 14 gallery dimensions, plus fixed content-type, block-replacement, per-slide override, CJK-in-Latin, theme and language switches, each switched A to B and back to A. A value class is a group of catalog values that take the same path through the engines, derived from the catalogs in the script: font schemes by language family, then by licensing and preview policy (Office metric, Office visual-only, monospace, open Google); one language per script family in the array and every other catalog script in a language chain; every layout family; the eight content blocks; every distinct chart export path of the non-deprecated chart types; header/footer, background (theme, solid, gradient, pattern, image) and image treatments by kind; and the first and last record of the metadata dimensions. Dimensions that a deck can carry several times (font scheme states, layouts, blocks, charts, backgrounds, images) take several values per deck. Every state is exported and checked with the FF-08 typeface inventory, the catalog's literal theme fonts, a package structure check, a preview re-render and a re-import. It pins the office font pack with visual substitution and asserts every substitution; known engine limitations, including chart types the preview approximates or the exporter writes as bar charts, are named expected failures in the script that fail with a \"limitation resolved\" message when they go away. It runs no browser and no Office. Its report is written to `artifacts/font-switch-matrix/report.json`. The pairwise decks run on four worker threads with a fixed partition (deck i on worker i mod 4), so every host verifies each deck after the same earlier decks; `OPF_MATRIX_WORKERS=1` runs them in one thread, `OPF_MATRIX_WORKERS=n` on n workers. See [font fidelity](font-fidelity.md) for loading and embedding local fonts and for current native PowerPoint limits.\n\n## Regenerating the example goldens (MR-31)\n\nThe raster golden of the examples corpus lives in one place, `packages/render/test/golden/` (a directory per baseline, one file per deck; `packages/render/test/golden/README.md` has the layout and `notes/` the review notes). The corpus is this repository's `examples/` and the renderer, core and the gallery are the checkout's own, so there is no lock selection, no core fixture and no sibling renderer to pin. A pull request that changes `examples/`, the core code that composes them, the gallery's records or the renderer's drawing moves slide hashes (or only the corpus digest, as FA-33 did: `notes/MR-31.md`); `pnpm test` and the `goldens` job of `ci.yml` fail until the baseline follows.\n\n```sh\ngh workflow run golden.yml --ref <branch>\npnpm golden:update --local # a review candidate under packages/render/artifacts/golden/, never the baseline\n```\n\n- **The workflow.** `.github/workflows/golden.yml` has two jobs. `regenerate` (read-only token) runs `pnpm golden:update` on the branch in the pinned Playwright image: it builds core, the gallery and the renderer, renders every slide, rewrites only the per-deck files whose hashes differ and uploads the patch, `diff.json` and the review sheets of the changed slides. `push` (write token, no branch code) applies the patch only when it touches `packages/render/test/golden/`, pushes one commit and dispatches `ci.yml` on it (a push made with `GITHUB_TOKEN` starts no workflow). It refuses the default branch and a fork.\n- **`pnpm golden:update`.** `scripts/golden-update.mjs`: without `--local` it refuses to rewrite the baseline anywhere but GitHub Actions on Linux in the Playwright image (the check the renderer's `golden-pinned-image.mjs` made); with `--local` it writes the review candidate only. The comparison is never changed (exact hashes, the baseline's own scale and font policy).\n- **Review.** The commit is evidence, not an approval. Open the artifact, look at the changed slides, write the reason in `notes/<ID>.md` and in the pull request, then approve. A change that moves one slide for a reason other than the PR's intent is a bug in the PR.\n- **Merge rhythm.** A merge conflict in deck files is resolved by merging `main`, taking either side, and regenerating. One pull request changes a layout and the golden of every package together (risk 23 of the monorepo plan).\n\n## Trying the packages in a site checkout\n\nThe three sites (openpresentation.org, pptx.gallery, pptx.dev) live in their own repositories and install the published packages. To browse pptx.gallery with this checkout, keep `pptx-gallery` in the same parent directory as this repository, install its dependencies, build here, run `node scripts/link-ecosystem.mjs` (it replaces the installed `@openpresentation/*` packages in the site's `node_modules` with links to this checkout without saving paths in manifests or lockfiles; reinstalling replaces the links, so rerun it) and start the site with `OPF_LOCAL_WORKSPACE=1 pnpm dev`. Layout detail pages have an interactive composition example; the flag expands Turbopack's local root to include this checkout. Build before starting the site, and stop and restart it around clean rebuilds: removing a linked `dist` directory during compilation can leave Turbopack with stale missing-module errors.\n\nAfter a release, the sites are bumped by `bump-sites.yml` (`release-process.md`); nothing here deploys or changes a site.\n\n## Editor host bundle and font provenance\n\nContributor details moved from the [browser integration guide](live-editor.md); published-package users can start there.\n\nFor library development, build the tarballs of the six packages from this checkout and install them into a clean consumer:\n\n```sh\npnpm build\npnpm pack:ecosystem\npnpm test:packed-ecosystem\n```\n\nThe packed consumer installs actual tarballs without workspace aliases, exercises editing/SVG/PPTX, checks TypeScript declarations, and bundles a browser entry without Node shims. A public release is the one-click workflow in [the release process](release-process.md); it packs and smoke-tests the same way before it publishes.\n\nThe gallery host example also offers local PPTX file import with preview/diagnostics and editable PowerPoint download. It commits active canvas text before export, shares preview text measurements and applies imports as a single undoable change. Save OPF to preserve the original source; native PowerPoint positions, fonts and unsupported features can change during conversion. The browser E2E checks run offline after loading and inspect the downloaded native merged table, then reimport and undo/redo. Native edit/save/reopen is a separate targeted check, not a pixel-equivalence claim.\n\n`pnpm vendor:gallery-editor --version X.Y.Z [--ref vX.Y.Z]` builds the host controls of the pptx.gallery site's vendored editor (`public/opf-editor`) while resolving libraries only from a fresh npm consumer; the manifest records both the example source hashes and the registry package integrities. It reads the editor examples from `packages/editor/examples` at `--ref` (default `HEAD`; the release tag `vX.Y.Z` for a release) and installs the published set `--version` names (`registryPlan({ tag })` in `scripts/registry-plan.mjs`: all six packages share one version; `--pin <package>=<X.Y.Z>` builds against a published set that is not shared) into a clean consumer under `artifacts/npm/gallery-editor-consumer`, with no sibling checkout but the site (`--site <dir>`, default `../pptx-gallery`) and no `release-plan.json`. After a stable release `bump-sites.yml` runs it in the pptx.gallery leg and commits the bundle into the bump pull request (`docs/programs/monorepo/site-workflows/README.md`).\n\nScript fonts: when the pinned editor example loads faces from `./script-fonts/` and the pinned renderer has the script pack (0.10.0 and later), the registry build also writes `script-fonts.json` and lists its hash in `manifest.json`. The manifest is the reviewable half: every `@expo-google-fonts/noto-*` package, exact version, SPDX license, license-file hash and each face's SHA-256, taken from the published renderer. The faces are binaries (63 files, 66.9 MiB), so they are never committed to the gallery repository. The gallery build copies them from its own pinned npm dependencies into the untracked `public/opf-editor/script-fonts/` directory, verifying every hash, and writes the license notices beside them; nothing is fetched from a font CDN. See `scripts/gallery-script-fonts.mjs` and the gallery's `scripts/prepare-editor-script-fonts.mjs`.\n\nBase fonts (FF-41): when the pinned editor example loads `base-fonts.json` (opf-editor 0.10.5: the example passes the faces as the renderer's `extraLazyFonts`, renderer 0.11.7 and later; 0.10.4's example used its own `examples/base-font-gate.js`), the registry build starts the editor with Roboto Regular alone in `fonts.json` (217 KB instead of 12.8 MB) and writes every other eager face (Roboto in six more styles, Roboto Mono, the Office substitutes) as a separate file named after its hash beside it, listed with its SHA-256 in `base-fonts.json` and in `manifest.json`; the editor fetches only the faces a document draws, verified, through its font gate (`scripts/gallery-base-fonts.mjs`). An older pinned example keeps every eager face in `fonts.json`. A default Roboto deck loads about 0.7 MB of fonts instead of 12.8 MB.\n\nLazy fonts: when the pinned editor example calls `ensureLazyFonts` and the pinned renderer vendors faces (Intos for the default Aptos scheme and the open families, renderer 0.11.0 and later), the registry build also writes `lazy-fonts.json` and lists its hash in `manifest.json`. It pins every vendored package (exact version, SPDX license, license-file and notice hashes) and each face SHA-256, taken from the published renderer. The faces are binaries, so they are not committed either: the gallery build copies them from its pinned `@openpresentation/opf-render` package (`fonts/<name>/`) into the untracked `public/opf-editor/fonts/` directory, verifying every hash, and the editor fetches only the families a document uses, same-origin. See `scripts/gallery-lazy-fonts.mjs` and the gallery's `scripts/prepare-editor-lazy-fonts.mjs`.\n\nThe browser bundle links `playground.js.LEGAL.txt`, included in the hashed resources. It contains bundled license notices and package license files, including the vendored PptxGenJS MIT license. For dependencies that publish only an explicit MIT declaration in their README, the build retains that declaration/attribution and the standard terms; omitted upstream notices use a version-specific source URL and verified supplement hash. License collection runs offline from the verified installation and committed supplement. Runtime JavaScript is not rewritten to normalize comment whitespace.\n"
|
|
99
|
+
"markdown": "# Local development across the packages\n\nUse Node 24 for the current source and published packages. All six packages live in this repository, one pnpm workspace, so there is nothing to link: `workspace:` dependencies resolve to the sibling directories, and a change that touches several packages is built and tested together.\n\n```sh\npnpm install\npnpm build # every package, in dependency order\npnpm check:changed # only what your branch changed (the check to run after each change)\npnpm test # everything; CI and the last run before a pull request\npnpm test:integration # the private tests that need several packages at once\n```\n\nFor a cheap checkout of one task (small blobless worktree, one shared pnpm store), use `node scripts/agent-worktree.mjs add <task>`.\n\nCI is `verify` (`.github/workflows/ci.yml`): one required check that runs the packages your change affects, with their dependents at the contract tier (`test:contract` of each package); `nightly.yml` runs the Windows, macOS, Node 22 and 26, packed-install and npm 12 consumer legs, the editor's `perf` browser suite (absolute wall-clock budgets, which vary too much between shared runners to gate a pull request) and the editor playground suite on Linux (`verify` runs it only when `packages/editor` changed) (the packed packages installed by npm 12 with its defaults: no install scripts, no git or remote dependencies; `pnpm test:npm12-consumer`) and the weekly `slow-checks.yml` the published-package consumers. See [the CI design](programs/monorepo/ci-design.md). Add the label `full-ci` to a pull request that touches OS- or Node-version-specific code (it starts `full-ci.yml`, which runs the nightly legs on the pull request; it is not part of `verify`). There is no `Depends-On`, no lock to roll and no merge queue.\n\nOn Windows, keep the checkout under a short path (esbuild and Biome exceed MAX_PATH deeper) and see the notes in `AGENTS.md`. npm and pnpm orchestration in the scripts invokes the package manager's JavaScript entrypoint with the selected Node runtime instead of a batch shim through a shell, so paths with spaces and shell metacharacters stay literal arguments.\n\nExecute the installed-package browser harnesses after their corresponding build:\n\n```sh\npnpm test:packages\npnpm test:packed-browser\npnpm test:registry-ecosystem\npnpm test:packed-browser registry\n```\n\nThe renderer package supplies the locked Playwright test dependency. Install Chromium with `pnpm --filter @openpresentation/opf-render exec playwright install --with-deps chromium` on Linux. Local Windows runs use Edge; `OPF_BROWSER_CHANNEL` can explicitly select another installed Playwright channel. CI uses the matching official Playwright container pinned by digest (one string in every workflow, `pnpm check:playwright-pin`), without installing OS packages during each run.\n\nEach build writes `artifacts/editor/packed-browser-manifest.json` with the mode, installed versions, consumer build ID, dependency-lock hash and exact font/HTML/JavaScript hashes. The runner rejects a different mode, stale consumer or changed asset. It serves only the verified bytes on loopback and rejects external requests and network writes. Rebuild before switching between candidate and registry modes. Reports include the browser and Node versions and are saved by mode/runtime; failures retain a screenshot.\n\n`node scripts/test-packed-browser-guards.mjs` verifies those four rejection cases against the current disposable harness and restores each changed fixture byte-for-byte. CI runs it after the registry browser checks.\n\nSeven suites exercise canvas, rich text, lists, creation, layout, block moves and styled tables. Real browser input covers divider resizing/cancellation/concurrent changes, block dragging, merged-cell typing/redo/undo, plain-to-rich conversion and bold formatting, and empty-cell typing/undo. Conversion and formatting currently create separate undo transactions. Harness DOM assertions also cover renderer agreement and preservation. These checks do not replace full application export/reimport, public deployment checks or native PowerPoint raster evidence.\n\n`pnpm test:ecosystem` validates the dynamic composition fixture, edits and undoes a composition, renders SVG/PNG/PDF, exports editable PPTX, checks OOXML text-box coordinates against the shared geometry, and imports the result back into schema-valid OPF. Artifacts are written to a temporary directory and its location is printed. For full gallery render coverage, run `pnpm test:gallery -- --render` (or invoke the script with `--render`): it validates all generated documents and can render them with the local SVG engine.\n\n`pnpm test:pagination` verifies long-text and table pagination through SVG and editable PPTX, including exact source reconstruction, table row counts, and absence of extra exporter-created pages. It writes review artifacts under `artifacts/pagination/`.\n\n`pnpm test:fonts` verifies actual-font measurement across editor, SVG, pagination, and PPTX. It also runs the offline font-switch matrix (`scripts/test-font-switch-ecosystem.mjs`, FF-09): a seeded pairwise covering array of 58 decks over the 14 gallery dimensions, plus fixed content-type, block-replacement, per-slide override, CJK-in-Latin, theme and language switches, each switched A to B and back to A. A value class is a group of catalog values that take the same path through the engines, derived from the catalogs in the script: font schemes by language family, then by licensing and preview policy (Office metric, Office visual-only, monospace, open Google); one language per script family in the array and every other catalog script in a language chain; every layout family; the eight content blocks; every distinct chart export path of the non-deprecated chart types; header/footer, background (theme, solid, gradient, pattern, image) and image treatments by kind; and the first and last record of the metadata dimensions. Dimensions that a deck can carry several times (font scheme states, layouts, blocks, charts, backgrounds, images) take several values per deck. Every state is exported and checked with the FF-08 typeface inventory, the catalog's literal theme fonts, a package structure check, a preview re-render and a re-import. It pins the office font pack with visual substitution and asserts every substitution; known engine limitations, including chart types the preview approximates or the exporter writes as bar charts, are named expected failures in the script that fail with a \"limitation resolved\" message when they go away. It runs no browser and no Office. Its report is written to `artifacts/font-switch-matrix/report.json`. The pairwise decks run on four worker threads with a fixed partition (deck i on worker i mod 4), so every host verifies each deck after the same earlier decks; `OPF_MATRIX_WORKERS=1` runs them in one thread, `OPF_MATRIX_WORKERS=n` on n workers. See [font fidelity](font-fidelity.md) for loading and embedding local fonts and for current native PowerPoint limits.\n\n## Regenerating the example goldens (MR-31)\n\nThe raster golden of the examples corpus lives in one place, `packages/render/test/golden/` (a directory per baseline, one file per deck; `packages/render/test/golden/README.md` has the layout and `notes/` the review notes). The corpus is this repository's `examples/` and the renderer, core and the gallery are the checkout's own, so there is no lock selection, no core fixture and no sibling renderer to pin. A pull request that changes `examples/`, the core code that composes them, the gallery's records or the renderer's drawing moves slide hashes (or only the corpus digest, as FA-33 did: `notes/MR-31.md`); `pnpm test` and the `goldens` job of `ci.yml` fail until the baseline follows.\n\n```sh\ngh workflow run golden.yml --ref <branch>\npnpm golden:update --local # a review candidate under packages/render/artifacts/golden/, never the baseline\n```\n\n- **The workflow.** `.github/workflows/golden.yml` has two jobs. `regenerate` (read-only token) runs `pnpm golden:update` on the branch in the pinned Playwright image: it builds core, the gallery and the renderer, renders every slide, rewrites only the per-deck files whose hashes differ and uploads the patch, `diff.json` and the review sheets of the changed slides. `push` (write token, no branch code) applies the patch only when it touches `packages/render/test/golden/`, pushes one commit and dispatches `ci.yml` on it (a push made with `GITHUB_TOKEN` starts no workflow). It refuses the default branch and a fork.\n- **`pnpm golden:update`.** `scripts/golden-update.mjs`: without `--local` it refuses to rewrite the baseline anywhere but GitHub Actions on Linux in the Playwright image (the check the renderer's `golden-pinned-image.mjs` made); with `--local` it writes the review candidate only. The comparison is never changed (exact hashes, the baseline's own scale and font policy).\n- **Review.** The commit is evidence, not an approval. Open the artifact, look at the changed slides, write the reason in `notes/<ID>.md` and in the pull request, then approve. A change that moves one slide for a reason other than the PR's intent is a bug in the PR.\n- **Merge rhythm.** A merge conflict in deck files is resolved by merging `main`, taking either side, and regenerating. One pull request changes a layout and the golden of every package together (risk 23 of the monorepo plan).\n\n## Trying the packages in a site checkout\n\nThe three sites (openpresentation.org, pptx.gallery, pptx.dev) live in their own repositories and install the published packages. To browse pptx.gallery with this checkout, keep `pptx-gallery` in the same parent directory as this repository, install its dependencies, build here, run `node scripts/link-ecosystem.mjs` (it replaces the installed `@openpresentation/*` packages in the site's `node_modules` with links to this checkout without saving paths in manifests or lockfiles; reinstalling replaces the links, so rerun it) and start the site with `OPF_LOCAL_WORKSPACE=1 pnpm dev`. Layout detail pages have an interactive composition example; the flag expands Turbopack's local root to include this checkout. Build before starting the site, and stop and restart it around clean rebuilds: removing a linked `dist` directory during compilation can leave Turbopack with stale missing-module errors.\n\nAfter a release, the sites are bumped by `bump-sites.yml` (`release-process.md`); nothing here deploys or changes a site.\n\n## Editor host bundle and font provenance\n\nContributor details moved from the [browser integration guide](live-editor.md); published-package users can start there.\n\nFor library development, build the tarballs of the six packages from this checkout and install them into a clean consumer:\n\n```sh\npnpm build\npnpm pack:ecosystem\npnpm test:packed-ecosystem\n```\n\nThe packed consumer installs actual tarballs without workspace aliases, exercises editing/SVG/PPTX, checks TypeScript declarations, and bundles a browser entry without Node shims. A public release is the one-click workflow in [the release process](release-process.md); it packs and smoke-tests the same way before it publishes.\n\nThe gallery host example also offers local PPTX file import with preview/diagnostics and editable PowerPoint download. It commits active canvas text before export, shares preview text measurements and applies imports as a single undoable change. Save OPF to preserve the original source; native PowerPoint positions, fonts and unsupported features can change during conversion. The browser E2E checks run offline after loading and inspect the downloaded native merged table, then reimport and undo/redo. Native edit/save/reopen is a separate targeted check, not a pixel-equivalence claim.\n\n`pnpm vendor:gallery-editor --version X.Y.Z [--ref vX.Y.Z]` builds the host controls of the pptx.gallery site's vendored editor (`public/opf-editor`) while resolving libraries only from a fresh npm consumer; the manifest records both the example source hashes and the registry package integrities. It reads the editor examples from `packages/editor/examples` at `--ref` (default `HEAD`; the release tag `vX.Y.Z` for a release) and installs the published set `--version` names (`registryPlan({ tag })` in `scripts/registry-plan.mjs`: all six packages share one version; `--pin <package>=<X.Y.Z>` builds against a published set that is not shared) into a clean consumer under `artifacts/npm/gallery-editor-consumer`, with no sibling checkout but the site (`--site <dir>`, default `../pptx-gallery`) and no `release-plan.json`. After a stable release `bump-sites.yml` runs it in the pptx.gallery leg and commits the bundle into the bump pull request (`docs/programs/monorepo/site-workflows/README.md`).\n\nScript fonts: when the pinned editor example loads faces from `./script-fonts/` and the pinned renderer has the script pack (0.10.0 and later), the registry build also writes `script-fonts.json` and lists its hash in `manifest.json`. The manifest is the reviewable half: every `@expo-google-fonts/noto-*` package, exact version, SPDX license, license-file hash and each face's SHA-256, taken from the published renderer. The faces are binaries (63 files, 66.9 MiB), so they are never committed to the gallery repository. The gallery build copies them from its own pinned npm dependencies into the untracked `public/opf-editor/script-fonts/` directory, verifying every hash, and writes the license notices beside them; nothing is fetched from a font CDN. See `scripts/gallery-script-fonts.mjs` and the gallery's `scripts/prepare-editor-script-fonts.mjs`.\n\nBase fonts (FF-41): when the pinned editor example loads `base-fonts.json` (opf-editor 0.10.5: the example passes the faces as the renderer's `extraLazyFonts`, renderer 0.11.7 and later; 0.10.4's example used its own `examples/base-font-gate.js`), the registry build starts the editor with Roboto Regular alone in `fonts.json` (217 KB instead of 12.8 MB) and writes every other eager face (Roboto in six more styles, Roboto Mono, the Office substitutes) as a separate file named after its hash beside it, listed with its SHA-256 in `base-fonts.json` and in `manifest.json`; the editor fetches only the faces a document draws, verified, through its font gate (`scripts/gallery-base-fonts.mjs`). An older pinned example keeps every eager face in `fonts.json`. A default Roboto deck loads about 0.7 MB of fonts instead of 12.8 MB.\n\nLazy fonts: when the pinned editor example calls `ensureLazyFonts` and the pinned renderer vendors faces (Intos for the default Aptos scheme and the open families, renderer 0.11.0 and later), the registry build also writes `lazy-fonts.json` and lists its hash in `manifest.json`. It pins every vendored package (exact version, SPDX license, license-file and notice hashes) and each face SHA-256, taken from the published renderer. The faces are binaries, so they are not committed either: the gallery build copies them from its pinned `@openpresentation/opf-render` package (`fonts/<name>/`) into the untracked `public/opf-editor/fonts/` directory, verifying every hash, and the editor fetches only the families a document uses, same-origin. See `scripts/gallery-lazy-fonts.mjs` and the gallery's `scripts/prepare-editor-lazy-fonts.mjs`.\n\nThe browser bundle links `playground.js.LEGAL.txt`, included in the hashed resources. It contains bundled license notices and package license files, including the vendored PptxGenJS MIT license. For dependencies that publish only an explicit MIT declaration in their README, the build retains that declaration/attribution and the standard terms; omitted upstream notices use a version-specific source URL and verified supplement hash. License collection runs offline from the verified installation and committed supplement. Runtime JavaScript is not rewritten to normalize comment whitespace.\n"
|
|
100
100
|
},
|
|
101
101
|
{
|
|
102
102
|
"slug": "evidence-2026-09-08-windows",
|
|
@@ -126,7 +126,7 @@ var docsData = Object.freeze([
|
|
|
126
126
|
"slug": "font-fidelity",
|
|
127
127
|
"file": "docs/font-fidelity.md",
|
|
128
128
|
"title": "Measured fonts and reproducible previews",
|
|
129
|
-
"markdown": "# Measured fonts and reproducible previews\n\n## Start with the installed package\n\nUse the coordinated versions in the [quickstart](quickstart.md). Load fonts once per worker with\n`loadFonts({pack: 'office', scripts: 'auto', presentation})` from `@openpresentation/opf-render/fonts-node`,\nand pass the same handle as `{fonts}` to preview and export. When reusing a worker for another deck,\nawait `fonts.ensure(nextPresentation, { renderOptions: { catalogs, date } })` before rendering with the same catalogs/date, and bound concurrency. Supplying `presentation` selects only the actual family/weight/style and needed glyph fallback files; omitting it keeps deliberate whole-pack loading. A no-text deck holds no faces, while explicit supplied faces stay loaded. Selection uses the complete allowed metadata, so loading fewer files does not change weight selection or native typeface names. An exporter that maps source families passes `mapFamily` to `ensure`; hand it one stable function (define it once, outside the per-call code), because the handle keeps its per-slide font analysis keyed by the function's identity and a fresh closure on every call starts from a cold cache. Reused handles retain previously used faces; bound their lifetime as well as worker count. The renderer's\n[soak benchmark](https://github.com/OpenPresentation/opf-render#long-lived-workers-measured-memory-and-latency-opf-render171)\n(`npm run bench:soak`) measured no memory growth over 500 jobs per worker. That historical whole-pack worker held about 1 GiB, peaking near\n2 GiB on script-heavy decks, and its output was byte-identical on every repeat. Measure your own decks the same way.\nFor an authored Roboto deck, `pack: 'base'` avoids loading Office replacements. Neither loader reads system fonts by default.\n\nFor every catalog scheme's authored and rendered fonts, see the website's generated [font scheme and export matrix](https://www.openpresentation.org/docs/font-fidelity#font-scheme-and-export-matrix), including PowerPoint, Keynote, LibreOffice, HTML, SVG, PNG and PDF.\n\nIn browsers, serve the renderer's pinned font files from your own origin and await the font handle's `ensure(presentation)`\nbefore measuring or editing. The renderer README documents font copying and the player integration. Standalone SVG must\ncarry the used font bytes; script faces require `embedScriptFonts: true` in the Node loader. The CLI's default SVG mode\nrequests this automatically (`--text fonts`); `--text system` needs matching viewer fonts, and `--text paths` draws the glyphs as outlines so the SVG needs none. PPTX normally names the authored families\nand requires them on the recipient's machine; it does not automatically embed the preview fonts.\n\nThe policy below is current. Version-specific measurements and implementation history are evidence for their named\ncheckpoints, not transfer-size budgets for every release. The [font roadmap](plans/font-roadmap.md) records historical\nplanning; use installed package APIs and measured output when choosing a deployment strategy.\n\n## A different language on one slide\n\nSet `language` on a slide when its language differs from the deck. It accepts the same BCP-47 tag or inline Language object as the deck; omission inherits the deck value. Direction, script fonts, quotation marks and number formatting follow the slide, while an individual text run's `language` still wins. PPTX import keeps that explicit run language when measured text wraps across native fragments; native proofing-language edits remain authoritative.\n\nFor example, an English deck can contain `{ \"language\": \"ar-SA\", \"design\": { \"fontScheme\": \"noto-sans-arabic\" }, \"text\": \"\u0627\u062E\u062A\u0631 \u062E\u0637 \u0627\u0644\u0634\u0631\u064A\u062D\u0629\" }`. The Arabic slide reads right to left, measures Noto Naskh Arabic and writes that selected face in PowerPoint's complex-script slot. The deck's other slides retain their own language and font selection. Markdown writes a tag as `<!-- slide: language=ar-SA -->`; an inline Language object uses an `opf-slide` block.\n\n## Pass `fonts`, otherwise the estimate\n\nText measurement comes from one place: the `fonts` handle that opf-render's `loadFonts()` returns. Since RR-55 the same\nhandle carries it for every step that lays text out:\n\n- core's `validate`, `paginate` and the slide context (`resolveSlideContext`);\n- opf-render's `toSvg`, `toPng` and `toPdf`;\n- opf-pptx's `toPptx`.\n\n```js\nconst fonts = await loadFonts({ pack: 'office' });\nvalidate(deck, { fonts });\nconst { presentation } = paginate(deck, { fonts });\nconst svg = toSvg(presentation, { fonts });\nconst pptx = await toPptx(presentation, { fonts });\n```\n\nPass the same handle to preview, validation, pagination and export, so that all of them measure with the faces the\npreview draws. Then line breaks, overflow findings, page breaks and the exported text boxes agree, and the same handle\ngives identical geometry across engines (opf-pptx's `layout-parity` test checks that the exported PPTX paragraphs agree with the SVG preview and with\ncore's composed items, with and without `fonts`).\n\nA call without `fonts` is not an error: it uses core's built-in estimate, and says so (`checks.layout: \"estimated\"` in\n`validate`, `layout: \"estimated\"` in `paginate`). The estimate is deterministic and needs no font files: 0.54 em per\ncharacter, 0.62 em for capital letters and digits, 0.32 em for a space, 1 em for CJK characters, and zero width for\ncombining marks. It is close for Latin text in an ordinary text face and too narrow for some scripts (the tracking issue\nis opf#566), so treat an estimated result as a draft and measure before you rely on a page break or an overflow finding.\nCore's Node `convert` and the CLI's `convert` and `paginate` do this for you: they prepare an office-pack `fonts` handle once per process (`opf validate` loads none, so it is estimated). A library\ncall (`validate`, `paginate`, `toSvg`, `toPptx`) never loads fonts on its own, because that would change every\nfonts-less result and pull font files into a browser bundle; pass the handle you want.\n\n## Font policy (FF-31)\n\nOPF keeps one machine-readable font policy table, [`spec/reference/font-policy.json`](../spec/reference/font-policy.json). Core exports it as `FONT_POLICY`, `fontPolicyFor()` and `applyFontPolicyDecisions()` from `@openpresentation/opf` or `@openpresentation/opf/font-policy`. Each row gives a family's license class, where viewers get it, whether OPF may ever embed it, and its preview replacement with a measured width difference. It also lists alternates, ending where possible with a face that already ships with opf-render. The [licensing table](programs/font-fidelity-everywhere/font-licensing.md) explains the policy families; query `FONT_POLICY.families` for the installed set rather than relying on a copied count. [`font-policy.schema.json`](../spec/reference/font-policy.schema.json) is its JSON Schema. The measurement evidence explains how each replacement was chosen.\n\n**The policy in brief (owner decisions, 2026-09-29).** This is the canonical statement; the sibling repositories link here.\n\n1. **The user's font selection is the source of truth.** The user picks a font, for example Aptos or Calibri through a font scheme. That name is what the document, the theme and the PPTX carry.\n2. **License-restricted (proprietary) fonts are never bundled or embedded,** so previews cannot draw them. Openly licensed fonts such as Carlito and Roboto are bundled, and \"licensed\" below always means license-restricted. Live previews, SVG, the editor and gallery thumbnails use an open look-alike instead. The goal is a replacement that looks similar and is metric-compatible (same advance widths and line metrics), so text occupies the same size on screen and wraps as it does in PowerPoint. Calibri\u2192Carlito is the model.\n3. **Where no metric-compatible open replacement exists yet,** a visual-only look-alike is a documented fallback. It is reported as visual and is a known layout-fidelity gap to close, not the intended end state. The parity scoreboard counts it as near, not perfect. The Aptos family is no longer such a case: Intos previews it as metric.\n4. **PPTX export always writes the selected font name,** for example `typeface=\"Aptos\"` in the theme and in runs, never the replacement. PowerPoint then opens the file and shows the actual font, installed or as a Microsoft 365 cloud font.\n5. **Only open fonts may be embedded,** through the explicit embed path (FF-13).\n6. **Font files are bundled, never hotlinked.** Fonts, Google Fonts included, ship as pinned files (an exact npm version, or a vendored file with a recorded sha256) and are never loaded at runtime from a font CDN. That protects visitor privacy (a German court held the Google Fonts CDN a GDPR violation in 2022) and keeps previews offline-capable and audits reproducible. Build-time self-hosting such as `next/font/google` is not a hotlink but is not pinned, so use `next/font/local` with pinned files. Guards fail on CDN references in every repository.\n7. **Every bundled face records a verified permissive license.** Allowed: exactly OFL-1.1, Apache-2.0, MIT and UFL-1.0; not GPL, LGPL, AGPL, proprietary or unclear public-domain fonts. The record has the SPDX id, any Reserved Font Name the copyright block declares, the source URL, package@version and sha256, all checked against the LICENSE file the font ships with. A modified version (subset, instance, conversion) may not use a Reserved Font Name in its name: a family whose served name contains its reserved name (Carlito, Raleway) is bundled only as the unmodified upstream file, while one that reserves another name (Noto Sans JP reserves \"Source\") may be modified. Details and enforcement: [Font files: bundling and licenses](programs/font-fidelity-everywhere/font-licensing.md#font-files-bundling-and-licenses).\n\n**Release status.** Point 4 is published: opf-pptx 0.10.0 and later write the selected name into the PPTX, and the editor and pptx.gallery builds that depend on the published set export it. opf-pptx 0.9.1 and earlier wrote the substitute.\n\n1. **Licensed, non-free fonts are never bundled or embedded.** This covers Aptos, Calibri, Cambria, Segoe UI, Georgia, Tahoma, Grandview, Seaford, Tenorite, Consolas, Times New Roman, Arial, Courier New and the Windows script fonts. Rendering uses the family's designated open replacement instead:\n - **Metric-compatible** is the goal, used where a replacement exists and measures identical: Calibri\u2192Carlito, Arial\u2192Arimo, Times New Roman\u2192Tinos, Courier New\u2192Cousine and Georgia\u2192Gelasio. A metric row needs an upstream statement and a measurement in all four styles, with a mean width difference below 0.1% and no corpus string more than 0.3% off. Georgia\u2192Gelasio passes only with Gelasio shaped with its `liga` and `clig` features off (the row lists them as `disabledFeatures`): with default features Gelasio ligates fi, fl, ffi and ffl, which Georgia does not, and runs differ by up to 1.02%. With them off every one of the 300 corpus strings matches in all four styles (mean and maximum below 0.01%). opf-render turns those features off in measurement and in SVG, so a renderer that does not is visual against Georgia.\n - **Size adjustment** (RR-38, opf#361): a visual replacement whose advances and glyphs are far from the real font's can carry `sizeAdjust`, a preview-only font-size multiplier. A renderer scales the replacement's size by it when it measures and when it draws, so lines have the length PowerPoint's have. The exported font sizes and the PPTX font names are unchanged; an export that measures with the renderer's fonts breaks lines at the adjusted widths, as the preview does. It applies to runs of the family's script drawn in the row's replacement; Latin text in a scheme of that family is drawn by the replacement at the composed size. Six rows carry one: Arabic Typesetting 0.64 (RR-38, the corpus advance ratio), and, by the opf#361 rule (the smallest factor at which no line of the script corpus or of the scheme's Latin overhangs more than 3 percent natively), Angsana New 0.75, DilleniaUPC 0.68, Sakkal Majalla 0.89, Malgun Gothic 1.07 and Nirmala UI 1.07. Traditional Arabic, Ebrima and MS Gothic carry none: one factor cannot fit them (measurements). `lineAscent` and `lineAscentMixed` (em) say where PowerPoint puts the baseline below the top of a line box, for a line in the real font alone and for a line that also holds other fonts, measured in a native PowerPoint 365 probe: Angsana New 0.83 / 0.86, DilleniaUPC 0.82 / 0.85, Sakkal Majalla 0.76 / 0.81, Nirmala UI 0.97 / 0.94 and Arabic Typesetting 0.74 / 0.80 (corrected in opf#361 from RR-38's 0.70 / 0.78, which an earlier estimator read). A renderer that puts baselines one em below the line top moves such runs up by `1 - lineAscent` em; Malgun Gothic's baseline (1.06 em) sits below that, so it has none. Decomposed conjoining Hangul jamo (U+1100 to U+11FF, U+A960 to U+A97F, U+D7B0 to U+D7FF) are a known limitation: PowerPoint draws them unshaped and up to 1.9 times wider, which no factor fixes; precomposed Hangul, which real text uses, is what the Malgun Gothic factor is set on. The width that remains against PowerPoint is measured in [the Arabic line-width residual](#arabic-typesetting-and-traditional-arabic-line-width-residual-opf523).\n - **Alternates** are tried, in order, when the declared replacement's pack is not loaded. An alternate is always reported as visual, including on a metric row.\n - **Aptos family:** Aptos\u2192Intos, Aptos Display\u2192Intos Display, Aptos Narrow\u2192Intos Narrow and Aptos Serif\u2192Intos Serif are metric: 0.000% mean and maximum against Aptos 2.01 in all four styles, with equal vertical metrics.\n - **Otherwise the closest measured open face**, marked visual: a documented fallback and a known layout-fidelity gap until a metric-compatible replacement exists. For example, Segoe UI\u2192Red Hat Display measures a 1.72% mean width difference.\n2. **The PPTX always names the chosen family, and no font file is included.** The exporter writes `Aptos` when the document chose Aptos. PowerPoint resolves standard fonts on the viewer's machine: those shipped with Office, Windows or macOS, and Microsoft 365 cloud fonts. The replacement never reaches the package (opf-pptx `test/export-chosen-fonts.mjs`).\n3. **Openly licensed fonts render as themselves.** Examples are Roboto, Carlito and the Noto script families. They can reach a PPTX only through an explicit embed path (FF-13), never by default.\n4. **Families that are proprietary and non-standard, or missing from the table,** keep their name in the PPTX. `fontAvailabilityDiagnostics()` reports that viewers may lack them. It also flags Microsoft 365 cloud-only fonts (such as Aptos) and families that ship only in an optional Windows language feature.\n\n### Which faces are available\n\n`BUNDLED_FONT_MANIFEST` from `@openpresentation/opf-render/fonts-node` is authoritative for the installed renderer's families, faces, packs, licenses and hashes. Font packages can be optional peers: a declared face still needs its pinned files installed and served. Neither Node nor browser loading discovers system fonts by default.\n\n- **Base pack:** Roboto and Roboto Mono.\n- **Office pack:** the Office replacements, including Carlito, Caladea, Arimo, Tinos, Cousine and Gelasio, and the Aptos replacements Intos, Intos Display, Intos Narrow and Intos Serif.\n- **Open pack:** the open catalog families and replacement targets, including Red Hat Display for Segoe UI and Red Hat Text for Tahoma. Node `pack: 'office'` includes this pack and the base pack by default; `includeOpenFonts: false` and `includeBaseFonts: false` opt out. There is no separate proposed `catalog` pack to install.\n- **Script packs:** pinned Noto and special-purpose faces, loaded for the scripts a presentation needs with `scripts: 'auto'`, or explicitly by script codes or `'all'`.\n\nNode loaders verify the bundled manifest; browser hosts serve the package files and load the needed faces on demand, as described below. Optional script-font packages remain explicit host dependencies.\n\nThe registry tries an exact supplied family first, then an explicit alias, the permitted policy replacement and its alternates, and an explicit generic fallback if configured. Alternates are visual even when the preferred replacement is metric. Inspect `fonts.substitutions` for the actual route. `substitutionPolicy: 'visual'` permits approximate replacements; `'metric'` restricts them to metric replacements, with the policy's explicitly documented Cambria fallback; `'none'` disables policy substitutions but does not disable explicit aliases or an explicit fallback.\n\n| Environment | Font resolution | What the viewer needs |\n| --- | --- | --- |\n| Node, cloud or serverless | Supplied exact faces or loaded open replacements, controlled by the registry policy | Pinned font files available to the process |\n| Browser/editor | The same registry rules, with the host serving the required faces and awaiting `ensure(presentation)` | Self-hosted files, not a font CDN |\n| PowerPoint, exported PPTX | Authored font names; normal export does not embed fonts | Installed fonts or supported Office cloud fonts; otherwise PowerPoint substitutes |\n| Keynote, imported PPTX | Authored names when available to Keynote | Installed fonts; Keynote handles missing-font substitution |\n| LibreOffice Impress, PPTX | Authored names, subject to local replacement settings | Installed fonts or system/LibreOffice substitutions |\n\nNative substitutions depend on application version, operating system, installed fonts and user settings. OPF cannot promise one fixed replacement for a missing native font. See [PowerPoint cloud fonts](https://support.microsoft.com/en-us/office/fonts/cloud-fonts-in-office), [Keynote missing fonts](https://support.apple.com/guide/keynote/tane1c9a464f/mac), and [LibreOffice replacement settings](https://help.libreoffice.org/latest/en-US/text/shared/optionen/01010700.html). There is no native OPF `.key` exporter: import PPTX into Keynote, then save there if needed. For LibreOffice (experimental), [LibreOffice interoperability](libreoffice.md) describes the font profile OPF tests with: its preview fonts plus a fontconfig alias from each proprietary family to its replacement.\n\n### HTML and rendered exports\n\nThe renderer's `toHtml()` from `/element` emits inline SVG and supports `fontMode: 'standalone'` (faces in each slide), `'shared'` (rules once for the returned markup), and `'external'` (matching self-hosted page CSS). It uses the same rendered faces as `toSvg`; the file converter and CLI do not have an `.html` target. Node script faces need `embedScriptFonts: true` for self-contained SVG or shared HTML. When the element upgrades in a browser, supply the same pinned faces through its font root/handle.\n\nSVG with `text: 'fonts'` embeds the used faces. `text: 'system'` names the rendered families without their files and requires matching fonts in the page/viewer. `text: 'paths'` draws glyph outlines from those faces, so visible text needs no installed font; exceptional runs remain text with a diagnostic. PNG bakes the same rendered faces into pixels. PDF is vector with embedded/subset fonts and selectable text by default; raster PDF contains page images. Vector embedding depends on usable outlines and embedding permissions. These formats preserve the preview's replacement appearance; they do not switch back to the authored proprietary font.\n\nThe website's [font scheme and export matrix](https://www.openpresentation.org/docs/font-fidelity#font-scheme-and-export-matrix) is generated from the installed Gallery catalog and resolved `FONT_POLICY` on every build. Its rows, counts, code defaults, replacement tiers and size adjustments are not maintained by hand. The hosted guide, Copy as Markdown, raw agent guide and `llms-full.txt` use the same projection. The marker below is expanded by the website; this repository retains the source prose.\n\n<!-- generated-font-matrix -->\n\n**Aptos, the default scheme.** Aptos is a Microsoft 365 cloud font and is not redistributable. Under the owner policy of 2026-09-29 it previews with Intos, an OFL font whose advance widths, kerning and vertical metrics equal Aptos 2.01: 0.000% mean and maximum width difference over the 300-string corpus in regular, bold, italic and bold italic, for Aptos, Aptos Display, Aptos Narrow and Aptos Serif (Aptos Serif measured from Microsoft's standalone Aptos Fonts download, the others from the Microsoft 365 cloud fonts). Line breaks, line heights and text sizes therefore agree with Aptos. The letter shapes are Intos's own (Inter-derived, Gelasio-derived for the serif), not Aptos's. The exported PPTX still names Aptos, Aptos Display, Aptos Narrow or Aptos Serif, and no Aptos file is bundled or embedded. Deployments that hold an Aptos license can pass the real files through `faces` for exact previews.\n\nIntos ships in opf-render's default office pack (`loadFonts({pack: 'office'})`), so the default metric policy previews the Aptos family without asking for visual mode. Without those faces, previews can use the alternates Roboto and Carlito under visual policy. Like the open families, Intos is an `embed: \"used\"` face: the fonts handle supplies the faces a slide actually draws, and subsetting can reduce the embedded bytes further. Pack size is not SVG or HTML transfer size; measure the installed renderer's output and selected delivery mode rather than using historical eager-embedding totals. Intos files are pinned by commit and SHA-256, and the previous replacements stay as alternates. The pptx.gallery parity scoreboard's `fontResolution` check counts the Aptos family as perfect because the replacement is metric-compatible.\n\n**Browser hosts load the vendored faces on demand.** The eager list is what a host puts in one `fonts.json` (12.6 MB); the vendored faces (Intos and the open families, `registry.lazyFonts`, 51 faces) would add 19.4 MB, so they ship as separate hash-pinned files at their package-relative paths (`fonts/intos/...`, `fonts/<family>/...`) and load through `loadFonts({faces, lazyFontsBaseUrl})` from `/fonts-browser`. `await fonts.ensure(presentation)` (the registry's `ensureLazyFonts` and `ensureScripts` are the lower-level calls) fetches and verifies only the faces the document draws (renderer 0.11.5, face level: a plain Aptos deck needs Intos Display Bold and Intos Regular, 2 files, 1.5 MB; an italic or bold run adds one face; before 0.11.5 it was every face of the resolved families, 8 files, 5.9 MB), then adds them to the document and the registry together, so the editor never measures with a face it paints as a fallback. The gallery commits only a pinned manifest, `lazy-fonts.json` (`scripts/gallery-lazy-fonts.mjs`, copied by `prepare-gallery-editor`): exact renderer version, SPDX license, license-file hash and every face's SHA-256, no bytes. The gallery's own build copies the faces from the pinned renderer package's `fonts/` directory into an untracked path, verifying each hash, the way it does for script fonts. The local editor demo (`build-editor-demo`, through `scripts/emit-lazy-fonts.mjs`) copies the files beside the page instead. The editor playground calls `fonts.ensure(presentation)` when a document needs them.\n\nThe Windows reference-font advance study is exploratory source-checkpoint evidence, not an additional compatibility certification. It measures 1,024 cases across regular/bold Calibri, Arial, Times New Roman and Courier New, recording local reference-file versions/hashes and native font-slot names. Disabling optional ligatures and rounding base glyph advances to eighth-point steps predicts 949 observations within 0.02pt; 75 outliers remain, including combining marks, Arabic and Calibri kerning. Office theme tokens and per-glyph fallback are not resolved to exact native files by these name properties. No runtime provider or open-font mapping changes from this hypothesis, and no reference font is redistributed.\n\nThe composition API accepts a `textMeasurement` provider. A provider resolves font faces and returns actual text widths; callers pass the same provider to pagination (as `{ fonts: { textMeasurement } }`), editor geometry, SVG rendering, and PPTX export. Without one, the existing deterministic character-width estimate remains available. A provider with `forScripts(profile)` (the renderer's registry measurement) is a script planner: `validate` and `paginate` ask it for each slide's script-aware measurement, built from the slide's `resolveScriptFonts` profile and a run language's own profile, so they measure Arabic or Japanese runs in the script faces preview and export draw.\n\n`loadFonts(options)` from `/fonts-node` returns the fonts handle: the same registry measurement (`textMeasurement`), the faces to embed in SVG (`embeddedFonts`) and the explicit raster files (`fontFiles`), with system and bundled fallback disabled for raster calls (`useBundledFonts: false`, `loadSystemFonts: false`). Pass it as `{ fonts }` to every deck-level call: `paginate`, editor geometry, `toSvg`, `toPng`, `toPdf` and `toPptx`. `pack: 'base'` is the default for authored Roboto decks; `pack: 'office'` adds the Office replacements and open families, and retains metric policy unless visual substitution is explicitly requested. Core's file API and CLI explicitly use visual policy. `fonts.substitutions` records actual substitutions; the loader does not rewrite the authored document or add native embedding.\n\nRenderer 0.8.0 groups static files by their OpenType preferred family while retaining legacy family names and explicit custom namespaces. `Roboto` requests at 500/600/800 now select the actual Medium/SemiBold/ExtraBold files instead of nearby 400/700 faces. Optional `TextStyle.fontFace` carries the physical legacy family and native bold/italic flags independently of CSS numeric weight: SemiBold/ExtraBold are regular within their legacy families. The converter consumes this metadata; providers without it retain their prior behavior. Nine actual base faces pass metadata/measurement/outline checks and offline Chromium advances on Node 20/24. Seven payload slides cover serialized native selectors, deterministic output and source/reimport. These checks do not establish native Office paint, embedding or broader script coverage; see the Mac candidate evidence.\n\nRenderer 0.8.0 uses adjacent SVG spans when no measurement provider is supplied. This closes the visible gaps caused by estimated fragment widths while retaining estimated line breaks and all run text/style/source offsets. Supplied providers and accepted placements still use exact fragment origins. Measured SVG requests geometric precision; accepted outline placements also constrain horizontal advances with `textLength`/`spacingAndGlyphs` to avoid browser quantization drift. This can scale glyphs horizontally while retaining nominal font size and baseline. Width-only providers do not receive that constraint, and constrained widths do not certify raw font-metric equivalence. The compatible editor supports both forms. This is a spacing improvement, not evidence that unmeasured wrapping or glyph coverage is accurate; see candidate evidence.\n\nThe Node loader verifies the pinned package versions, font-file hashes, license notices and vendored provenance in the installed `BUNDLED_FONT_MANIFEST`; the browser loader verifies the served faces against the same pins. Missing or modified resources reject with actionable errors. Font files must remain available and unchanged between preparation and export. HarfBuzz shaping and subsetting are provided by the fonts handle when its pinned WASM resources are available; inspect diagnostics if a deployment omits them. Browser loading, glyph coverage, style selection and native compatibility remain separate requirements. The version-specific evidence below records historical checkpoints, not the current manifest's face counts or API boundaries.\n\nThe renderer's optional font registry uses [Fontkit](https://github.com/foliojs/fontkit) to shape text and measure glyph advances from local font bytes. It does not discover system fonts or fetch fonts. The Node loader loads the renderer's bundled Roboto and Roboto Mono faces:\n\n```js\nimport { loadFonts } from '@openpresentation/opf-render/fonts-node';\nimport { toSvg, toPng } from '@openpresentation/opf-render';\nimport { paginate } from '@openpresentation/opf/pagination';\nimport { toPptx } from '@openpresentation/opf-pptx';\n\nconst fonts = await loadFonts(); // pack: 'base', the bundled Roboto faces\n// Use design.fontScheme: 'roboto', or supply the document's actual font files.\nconst { presentation } = paginate(deck, { fonts });\nconst svg = toSvg(presentation, 1, { fonts }); // slide 1; embeds the faces it draws (text: 'paths' draws outlines instead)\nconst png = await toPng(svg, { fonts }); // draws with fonts.fontFiles only\nconst pptx = await toPptx(presentation, { fonts });\n```\n\n`loadFonts({ faces })` (from `/fonts-node` or `/fonts-browser`) accepts `{data: Uint8Array, weight, italic?, family?, postscriptName?, license?}` entries in Node or the browser, and `{path}` entries in Node. Weights are explicit, with 400 as the default. Supply each style that the document uses. Missing font families and unsupported glyphs fail with `OPFFontError`, including the source path where available. Collection fonts require a `postscriptName` selecting one face.\n\nAliases and fallback families are explicit choices:\n\n```js\nconst fonts = await loadFonts({\n pack: 'none', faces,\n aliases: { Aptos: 'Roboto', 'Aptos Display': 'Roboto' },\n fallbackFamily: 'Roboto',\n});\nconsole.log(fonts.substitutions);\nfonts.registry.clearSubstitutions(); // Start a fresh render's diagnostic collection.\n```\n\nAn available exact family takes precedence over aliases. The registry resolves a requested weight to the closest supplied weight, reports the substitution, and makes the resolved style available to rendering. Missing italic/upright styles fail instead of synthesizing an unmeasured style. `strictGlyphs: false` is an explicit escape hatch for hosts with their own glyph-fallback policy; it is unsuitable for fidelity verification.\n\nSVG embeds supplied fonts using data URIs and includes supplied license notices as metadata. The bundled loader carries the fonts' SIL Open Font License notices. For PNG/PDF, pass the same font files to the rasterizer; its native font loader does not depend on browser CSS font loading. In a browser, wait for `document.fonts.ready` before measuring or taking a screenshot. The editor playground loads and embeds bundled fonts and displays substitutions.\n\n`toPdf` (`svgToPdf` before 0.18) in renderers up to 0.11.9 was image-only: each slide was rasterized and embedded as a PNG on a PDF page. From opf-render 0.12.0 (opf-render#90, [roadmap](plans/pdf-export.md)) the default vector mode writes PDF text objects in embedded TrueType subsets of the fonts you supply or the bundled open pack (the same files the PNG preview uses; system fonts are rejected, a face whose OS/2 `fsType` forbids embedding is never embedded, the report names requested and resolved faces), with `ToUnicode` maps and `/ActualText` where the glyph map cannot give the text, vector shapes, gradients and images, and no second layout pass. `raster: true` (`mode: \"raster\"` before 0.18) keeps the image-per-slide output as an explicit compatibility mode. Extraction was checked in pdf.js, PDFium and poppler on Latin, CJK, right-to-left and Indic samples and all 805 example slides; PDFium misreads some Thai and Burmese marks, as it does in Chrome's own PDFs. No PDF/UA or PDF/A claim.\n\n## Office compatibility pack\n\n`loadFonts({ pack: 'office' })` from `@openpresentation/opf-render/fonts-node` supplies regular, bold, italic, and bold italic faces of Carlito, Caladea, Arimo, Tinos, Cousine, and Gelasio, plus the base Roboto pack. Package versions are pinned and each face carries its distribution's license notice. `includeBaseFonts: false` omits Roboto. Loading never installs fonts into the operating system or downloads fonts at render time.\n\n```js\nconst fonts = await loadFonts({\n pack: 'office',\n substitutionPolicy: 'metric', // Default for the office pack; no visual fallback.\n});\nfonts.registry.resolveFont({fontFamily: 'Calibri', fontWeight: 400});\n// requestedFamily: Calibri, resolvedFamily: Carlito, compatibility: metric\n```\n\n`loadFonts` defaults to `substitutionPolicy: 'none'` (the office pack to `'metric'`). Policies are `none`, `metric`, and `visual`; visual permits both curated tiers. An explicit `fallbackFamily` is a separate, reported `generic` fallback. Aliases are explicit visual substitutions and never establish metric compatibility. `resolveFont` reports exact resolutions as well; `substitutions` only collects changes. Resolution records include requested/resolved weights, italic, source path, and supporting upstream information where available.\n\n| Requested family | Bundled substitute | Current automatic tier |\n| --- | --- | --- |\n| Calibri | Carlito | Metric intent, standard 400/700 styles |\n| Cambria | Caladea | Visual: advances differ from Cambria 6.99 by a mean of 2.7% (FF-31 measurement). Metric-mode registries still use it, reported as visual (`metricModeFallback`) |\n| Arial | Arimo | Metric, standard 400/700 styles |\n| Times New Roman | Tinos | Metric, standard 400/700 styles |\n| Courier New | Cousine | Metric, standard 400/700 styles |\n| Georgia | Gelasio | Metric with `liga` and `clig` off (`disabledFeatures`, applied by opf-render): advances identical on all 300 corpus strings in four styles. With default features, ligature runs differ by up to 1.02% |\n| Calibri Light | Carlito | Visual: the bundle has no Carlito Light face |\n| Aptos, Aptos Display, Aptos Narrow, Aptos Serif | Intos, Intos Display, Intos Narrow, Intos Serif (office pack) | Metric: 0.000% mean and maximum against Aptos 2.01, all four styles; Roboto and Carlito are visual alternates |\n\nUpstream evidence: [Carlito](https://github.com/googlefonts/carlito), [Fontconfig mappings](https://chromium.googlesource.com/external/fontconfig/+/refs/heads/main/conf.d/30-metric-aliases.conf), [Arimo](https://github.com/google/fonts/blob/main/ofl/arimo/DESCRIPTION.en_us.html), [Tinos](https://github.com/google/fonts/blob/main/ofl/tinos/DESCRIPTION.en_us.html), [Cousine](https://github.com/google/fonts/blob/main/ofl/cousine/DESCRIPTION.en_us.html), and [Gelasio](https://github.com/SorkinType/Gelasio). Metric classification describes compatibility intent within the stated style scope, not universal identical output. Missing matching weights cannot silently qualify for the metric tier.\n\nRR-17: Liberation Sans, Serif and Mono are not bundled (Reserved Font Name, about 4.4 MB); a document that names them previews with Arimo, Tinos and Cousine, the Croscore faces Liberation 2 is built from (metric, 0.0000% in four styles). Each Latin replacement has a per-family qualification and a fixture in every host; see the [font tracker](programs/font-fidelity-everywhere/font-tracker.md).\n\nWeight-named Segoe UI Light and Semilight preview with Red Hat Display 300 for regular text and 400 for bold emphasis. Semilight targets 350, but the bundled font has no 350 face, so this remains a visual approximation. PPTX retains the authored family. Yu Gothic Regular also remains a documented visual gap: its Noto Sans JP Regular stand-in draws heavier strokes. See the [font tracker](programs/font-fidelity-everywhere/font-tracker.md) and comparison sheets.\n\nThe exported `FONT_COMPATIBILITY` list also contains optional visual candidates and CJK families. Listing a candidate does not bundle it or imply complete character coverage. Liberation Sans Narrow is a separate legacy distribution with a different license history; it is not part of this bundle. Wingdings, Webdings, and Symbol require character mapping before substitution; an ordinary fallback fails with `font-encoding-required`. Cambria Math previews with STIX Two Math and Segoe UI Emoji with Noto Color Emoji once opf-render's optional math and emoji packs are loaded (FF-45, [special families: emoji and math](programs/font-fidelity-everywhere/special-families-emoji-math.md)); without the pack a renderer reports `font-unavailable` naming it, like any other routed family (the former `math-font-required` failure is gone). OPF has no equation model: a Cambria Math run is text drawn per character in a math face, not MATH-table layout.\n\nDrawingML tokens such as `+mn-lt` resolve through the registry's explicit `themeFonts` option before substitution. Supply concrete `majorLatin`, `minorLatin`, and, where used, `majorEastAsia`, `minorEastAsia`, `majorComplexScript`, or `minorComplexScript` families. Missing theme mappings fail. This helper does not yet extract theme font records or embedded fonts from imported PPTX files.\n\n### Measured results and experimental fonts\n\n`node scripts/test-office-fonts.mjs --system` compares the bundle to reference fonts already installed in macOS's Supplemental directory. It does not redistribute reference fonts. The report records source-file hashes and individual shaped widths. Across four samples and four styles, Arimo/Arial, Tinos/Times New Roman, and Cousine/Courier New matched exactly on 48 runs. Gelasio/Georgia differed on ligature-containing runs, with a maximum difference of 2.0125%. Individual basic-Latin advances matched; disabling optional ligatures removed the tested difference. That earlier comparison predated the current disabled-feature qualification: the policy now marks Georgia\u2192Gelasio metric when `liga` and `clig` are off, as described above. Calibri and Cambria reference fonts were not available for this comparison.\n\nAkasia, assessed earlier (v0.0.2 open-file assessment), is dropped: its repository is no longer available, and Intos replaces it. `EXPERIMENTAL_FONT_CANDIDATES` now records Microsoft's Selawik, measured for Segoe UI on 2026-09-29 and rejected: 0.16% mean and 2.5% maximum in regular, no italic faces, 349 code points, lowercase 4.8% shorter. The acceptance rules for replacement fonts are in the [licensing table](programs/font-fidelity-everywhere/font-licensing.md#replacement-font-acceptance-rules).\n\nAn original OPF font project is technically feasible: independently designed or suitably open-licensed glyph outlines can be fitted to target advance widths, placement, vertical metrics, and shaping behavior. A successful font needs a reproducible source build, provenance, style/coverage tests, visual review, and cross-renderer conformance. Matching bounding boxes alone is insufficient: [OpenType horizontal metrics](https://learn.microsoft.com/en-us/typography/opentype/spec/hmtx) and [glyph positioning](https://learn.microsoft.com/en-us/typography/opentype/spec/gpos) jointly control text placement. Universal pixel identity across rasterizers is not the acceptance criterion; measured layout preservation over an explicit test matrix is.\n\n## Verification and remaining work\n\nScript fonts (CJK, Arabic, Hebrew, Indic, Thai, Khmer, Myanmar and the rest) have their own shaping corpora and per-family qualification (FF-44, RR-17): see [script-corpora.md](programs/font-fidelity-everywhere/script-corpora.md). It records, per script, glyph coverage, fontkit against HarfBuzz and Chromium, the installed originals measured in place, and dated shaping/raster limitations and their fixes. Read each result with its exact renderer and rasterizer versions; historical resvg-js failures do not describe every later PNG path or establish native acceptance.\n\n### Arabic Typesetting and Traditional Arabic: line-width residual (opf#523)\n\nNeither family is bundled; both preview and compose with Noto Naskh Arabic (OFL-1.1). Arabic Typesetting carries the RR-38 `sizeAdjust` of 0.64, and Traditional Arabic has none. Native PowerPoint draws lines in both families **narrower** than the shared composition measures them. This is a known, accepted residual.\n\n**Measured.** All widths are PowerPoint 365 `TextRange.Lines` bounds or ink, against the composed line.\n\n| Family | Native lines | Native / composed width | Largest gap |\n| --- | --- | --- | --- |\n| Arabic Typesetting (proxy at 0.64) | 16, in RR-59 and FF-46 set 2 | 14 lines at 0.86 to 0.97 (headings 0.86 to 0.92, body 0.90 to 0.97); one FF-46 body line at 1.04; one FF-46 heading at 0.55; pooled 0.94 without that heading | 56.6 pt narrower on an 856 pt body line (284 pt on the 0.55 heading); 31 pt wider on the 1.04 line |\n| Traditional Arabic (proxy at 1) | 10, in the same two runs | 0.68 to 0.90, pooled 0.79 | 223.6 pt narrower (an 842 pt body line) |\n\nThe RR-38 probe agrees for Arabic Typesetting. Its 45-character line is 216.9, 289.0 and 386.1 pt at 18, 24 and 32 pt in PowerPoint, and composes at 222.1, 298.6 and 396.9 pt.\n\n**Why it exists.** Three reasons:\n- **No published metrics.** Microsoft's font pages for [Arabic Typesetting](https://learn.microsoft.com/en-us/typography/font-list/arabic-typesetting) and [Traditional Arabic](https://learn.microsoft.com/en-us/typography/font-list/traditional-arabic) give only the file names, styles, vendor, scripts and code pages. They publish no advance widths, `xAvgCharWidth` or vertical metrics.\n- **No metric-compatible open face.** None exists for either family: no fontconfig metric alias, no Croscore-style clone. OPF does not take metrics from the installed proprietary files.\n- **One factor cannot fit.** Per glyph, Noto Naskh Arabic's advances differ from these fonts' by more than any scale can absorb. Ligatures and letter widths vary by text. Arabic Typesetting also has only a regular face, so PowerPoint emboldens bold text synthetically, while the preview draws Noto Naskh Arabic Bold.\n\n**One factor per family does not fix it.** For Traditional Arabic, the native / Noto Naskh ratio of the 10 lines spans 0.68 to 0.90, so any one factor leaves large gaps:\n\n| Factor | Largest gap, composed wider | Largest gap, native wider |\n| --- | --- | --- |\n| 0.79 (the pooled ratio; the opf#361 proposal) | 47 pt | 48 pt |\n| 0.90 | 139 pt | none |\n\nLatin text in a deck that uses the Traditional Arabic scheme also draws in Noto Naskh Arabic's Latin, where the policy measures Traditional Arabic at 0.86 of the replacement's width. At 0.79, those lines would run about 9 percent past their composed width in PowerPoint. Arabic Typesetting's 0.64 already sits near the upper edge of its native ratios. A lower factor would let more lines run past their boxes.\n\n**Practical impact.**\n- **Line counts agree.** The PPTX export writes each composed line as its own text box, and PowerPoint does not re-wrap it. Line counts, the order of lines and the right edges of right-to-left lines therefore agree: within 0.13 pt in RR-59.\n- **Left edges differ.** The left edge of a right-to-left line (the right edge of a left-to-right one) sits closer to the text in PowerPoint. The same text could fit in fewer lines natively than the preview shows.\n- **Overhang is rare.** Because the proxy errs wide, a Traditional Arabic line keeps slack in its box. For Arabic Typesetting, an occasional line runs a few percent past its composed width: 3.78 pt past its box in RR-59 `ar-run-in-en`, not clipped.\n- **Wrapping can differ near the edge.** Text that PowerPoint lays out itself wraps where the real font's widths put it, which can differ from the preview. That covers a line box retyped in PowerPoint, and text another application re-flows.\n\nFor layouts that must wrap exactly, choose a family with a metric replacement, or supply licensed font files through `loadFonts({faces})`.\n\n`pnpm test:fonts` checks that editor and SVG geometry match and that every native PPTX text box has the same coordinates and measured line breaks. With opf-pptx FF-31 (opf-pptx#63), export names the chosen family, not the preview substitute. It writes artifacts to `artifacts/fonts/`. A real-browser check of the same Roboto run measured 324.032 pixels versus the font engine's 324.170 pixels at 25 pixels, a difference of 0.138 pixels. These are measured tolerances, not a promise of pixel identity.\n\nPPTX records the chosen font family (FF-31); it never records a preview replacement and never embeds a proprietary font binary. PowerPoint still needs those fonts installed, through Office, the OS or Microsoft 365 cloud fonts, or it substitutes them. Line height remains the shared 1.22 multiplier, rather than a complete ascent/descent model. Rich-text font overrides, mixed-script fallback and bidi layout, specialized payload internals, and native font embedding remain active fidelity work. Passing a width provider does not remove those limits.\n"
|
|
129
|
+
"markdown": "# Measured fonts and reproducible previews\n\n## Start with the installed package\n\nUse the coordinated versions in the [quickstart](quickstart.md). Load fonts once per worker with\n`loadFonts({pack: 'office', scripts: 'auto', presentation})` from `@openpresentation/opf-render/fonts-node`,\nand pass the same handle as `{fonts}` to preview and export. When reusing a worker for another deck,\nawait `fonts.ensure(nextPresentation, { renderOptions: { catalogs, date } })` before rendering with the same catalogs/date, and bound concurrency. Supplying `presentation` selects only the actual family/weight/style and needed glyph fallback files; omitting it keeps deliberate whole-pack loading. A no-text deck holds no faces, while explicit supplied faces stay loaded. Selection uses the complete allowed metadata, so loading fewer files does not change weight selection or native typeface names. An exporter that maps source families passes `mapFamily` to `ensure`; hand it one stable function (define it once, outside the per-call code), because the handle keeps its per-slide font analysis keyed by the function's identity and a fresh closure on every call starts from a cold cache. Reused handles retain previously used faces; bound their lifetime as well as worker count. The renderer's\n[soak benchmark](https://github.com/OpenPresentation/opf-render#long-lived-workers-measured-memory-and-latency-opf-render171)\n(`npm run bench:soak`) measured no memory growth over 500 jobs per worker. That historical whole-pack worker held about 1 GiB, peaking near\n2 GiB on script-heavy decks, and its output was byte-identical on every repeat. Measure your own decks the same way.\nFor an authored Roboto deck, `pack: 'base'` avoids loading Office replacements. Neither loader reads system fonts by default.\n\nFor every catalog scheme's authored and rendered fonts, see the website's generated [font scheme and export matrix](https://www.openpresentation.org/docs/font-fidelity#font-scheme-and-export-matrix), including PowerPoint, Keynote, LibreOffice, HTML, SVG, PNG and PDF.\n\nIn browsers, serve the renderer's pinned font files from your own origin and await the font handle's `ensure(presentation)`\nbefore measuring or editing. The renderer README documents font copying and the player integration. Standalone SVG must\ncarry the used font bytes; script faces require `embedScriptFonts: true` in the Node loader. The CLI's default SVG mode\nrequests this automatically (`--text fonts`); `--text system` needs matching viewer fonts, and `--text paths` draws the glyphs as outlines so the SVG needs none. PPTX normally names the authored families\nand requires them on the recipient's machine; it does not automatically embed the preview fonts.\n\nThe policy below is current. Version-specific measurements and implementation history are evidence for their named\ncheckpoints, not transfer-size budgets for every release. The [font roadmap](plans/font-roadmap.md) records historical\nplanning; use installed package APIs and measured output when choosing a deployment strategy.\n\n## A different language on one slide\n\nSet `language` on a slide when its language differs from the deck. It accepts the same BCP-47 tag or inline Language object as the deck; omission inherits the deck value. Direction, script fonts, quotation marks and number formatting follow the slide, while an individual text run's `language` still wins. PPTX import keeps that explicit run language when measured text wraps across native fragments; native proofing-language edits remain authoritative.\n\nFor example, an English deck can contain `{ \"language\": \"ar-SA\", \"design\": { \"fontScheme\": \"noto-sans-arabic\" }, \"text\": \"\u0627\u062E\u062A\u0631 \u062E\u0637 \u0627\u0644\u0634\u0631\u064A\u062D\u0629\" }`. The Arabic slide reads right to left, measures Noto Naskh Arabic and writes that selected face in PowerPoint's complex-script slot. The deck's other slides retain their own language and font selection. Rendering that deck needs the Arabic script packages (`@expo-google-fonts/noto-naskh-arabic@0.4.5` and `@expo-google-fonts/noto-sans-arabic@0.4.3`), which the eight-font office pack of a starter project does not include: convert once, read the `fonts/script-font-not-installed` findings and install the packages they name (the [CLI guide](cli.md#fonts-for-a-deck-in-another-script) has the steps). Markdown writes a tag as `<!-- slide: language=ar-SA -->`; an inline Language object uses an `opf-slide` block.\n\n## Pass `fonts`, otherwise the estimate\n\nText measurement comes from one place: the `fonts` handle that opf-render's `loadFonts()` returns. Since RR-55 the same\nhandle carries it for every step that lays text out:\n\n- core's `validate`, `paginate` and the slide context (`resolveSlideContext`);\n- opf-render's `toSvg`, `toPng` and `toPdf`;\n- opf-pptx's `toPptx`.\n\n```js\nconst fonts = await loadFonts({ pack: 'office' });\nvalidate(deck, { fonts });\nconst { presentation } = paginate(deck, { fonts });\nconst svg = toSvg(presentation, { fonts });\nconst pptx = await toPptx(presentation, { fonts });\n```\n\nPass the same handle to preview, validation, pagination and export, so that all of them measure with the faces the\npreview draws. Then line breaks, overflow findings, page breaks and the exported text boxes agree, and the same handle\ngives identical geometry across engines (opf-pptx's `layout-parity` test checks that the exported PPTX paragraphs agree with the SVG preview and with\ncore's composed items, with and without `fonts`).\n\nA call without `fonts` is not an error: it uses core's built-in estimate, and says so (`checks.layout: \"estimated\"` in\n`validate`, `layout: \"estimated\"` in `paginate`). The estimate is deterministic and needs no font files: 0.54 em per\ncharacter, 0.62 em for capital letters and digits, 0.32 em for a space, 1 em for CJK characters, and zero width for\ncombining marks. It is close for Latin text in an ordinary text face and too narrow for some scripts (the tracking issue\nis opf#566), so treat an estimated result as a draft and measure before you rely on a page break or an overflow finding.\nCore's Node `convert` and the CLI's `convert` and `paginate` do this for you: they prepare an office-pack `fonts` handle once per process (`opf validate` loads none, so it is estimated). A library\ncall (`validate`, `paginate`, `toSvg`, `toPptx`) never loads fonts on its own, because that would change every\nfonts-less result and pull font files into a browser bundle; pass the handle you want.\n\n## Font policy (FF-31)\n\nOPF keeps one machine-readable font policy table, [`spec/reference/font-policy.json`](../spec/reference/font-policy.json). Core exports it as `FONT_POLICY`, `fontPolicyFor()` and `applyFontPolicyDecisions()` from `@openpresentation/opf` or `@openpresentation/opf/font-policy`. Each row gives a family's license class, where viewers get it, whether OPF may ever embed it, and its preview replacement with a measured width difference. It also lists alternates, ending where possible with a face that already ships with opf-render. The [licensing table](programs/font-fidelity-everywhere/font-licensing.md) explains the policy families; query `FONT_POLICY.families` for the installed set rather than relying on a copied count. [`font-policy.schema.json`](../spec/reference/font-policy.schema.json) is its JSON Schema. The measurement evidence explains how each replacement was chosen.\n\n**The policy in brief (owner decisions, 2026-09-29).** This is the canonical statement; the sibling repositories link here.\n\n1. **The user's font selection is the source of truth.** The user picks a font, for example Aptos or Calibri through a font scheme. That name is what the document, the theme and the PPTX carry.\n2. **License-restricted (proprietary) fonts are never bundled or embedded,** so previews cannot draw them. Openly licensed fonts such as Carlito and Roboto are bundled, and \"licensed\" below always means license-restricted. Live previews, SVG, the editor and gallery thumbnails use an open look-alike instead. The goal is a replacement that looks similar and is metric-compatible (same advance widths and line metrics), so text occupies the same size on screen and wraps as it does in PowerPoint. Calibri\u2192Carlito is the model.\n3. **Where no metric-compatible open replacement exists yet,** a visual-only look-alike is a documented fallback. It is reported as visual and is a known layout-fidelity gap to close, not the intended end state. The parity scoreboard counts it as near, not perfect. The Aptos family is no longer such a case: Intos previews it as metric.\n4. **PPTX export always writes the selected font name,** for example `typeface=\"Aptos\"` in the theme and in runs, never the replacement. PowerPoint then opens the file and shows the actual font, installed or as a Microsoft 365 cloud font.\n5. **Only open fonts may be embedded,** through the explicit embed path (FF-13).\n6. **Font files are bundled, never hotlinked.** Fonts, Google Fonts included, ship as pinned files (an exact npm version, or a vendored file with a recorded sha256) and are never loaded at runtime from a font CDN. That protects visitor privacy (a German court held the Google Fonts CDN a GDPR violation in 2022) and keeps previews offline-capable and audits reproducible. Build-time self-hosting such as `next/font/google` is not a hotlink but is not pinned, so use `next/font/local` with pinned files. Guards fail on CDN references in every repository.\n7. **Every bundled face records a verified permissive license.** Allowed: exactly OFL-1.1, Apache-2.0, MIT and UFL-1.0; not GPL, LGPL, AGPL, proprietary or unclear public-domain fonts. The record has the SPDX id, any Reserved Font Name the copyright block declares, the source URL, package@version and sha256, all checked against the LICENSE file the font ships with. A modified version (subset, instance, conversion) may not use a Reserved Font Name in its name: a family whose served name contains its reserved name (Carlito, Raleway) is bundled only as the unmodified upstream file, while one that reserves another name (Noto Sans JP reserves \"Source\") may be modified. Details and enforcement: [Font files: bundling and licenses](programs/font-fidelity-everywhere/font-licensing.md#font-files-bundling-and-licenses).\n\n**Release status.** Point 4 is published: opf-pptx 0.10.0 and later write the selected name into the PPTX, and the editor and pptx.gallery builds that depend on the published set export it. opf-pptx 0.9.1 and earlier wrote the substitute.\n\n1. **Licensed, non-free fonts are never bundled or embedded.** This covers Aptos, Calibri, Cambria, Segoe UI, Georgia, Tahoma, Grandview, Seaford, Tenorite, Consolas, Times New Roman, Arial, Courier New and the Windows script fonts. Rendering uses the family's designated open replacement instead:\n - **Metric-compatible** is the goal, used where a replacement exists and measures identical: Calibri\u2192Carlito, Arial\u2192Arimo, Times New Roman\u2192Tinos, Courier New\u2192Cousine and Georgia\u2192Gelasio. A metric row needs an upstream statement and a measurement in all four styles, with a mean width difference below 0.1% and no corpus string more than 0.3% off. Georgia\u2192Gelasio passes only with Gelasio shaped with its `liga` and `clig` features off (the row lists them as `disabledFeatures`): with default features Gelasio ligates fi, fl, ffi and ffl, which Georgia does not, and runs differ by up to 1.02%. With them off every one of the 300 corpus strings matches in all four styles (mean and maximum below 0.01%). opf-render turns those features off in measurement and in SVG, so a renderer that does not is visual against Georgia.\n - **Size adjustment** (RR-38, opf#361): a visual replacement whose advances and glyphs are far from the real font's can carry `sizeAdjust`, a preview-only font-size multiplier. A renderer scales the replacement's size by it when it measures and when it draws, so lines have the length PowerPoint's have. The exported font sizes and the PPTX font names are unchanged; an export that measures with the renderer's fonts breaks lines at the adjusted widths, as the preview does. It applies to runs of the family's script drawn in the row's replacement; Latin text in a scheme of that family is drawn by the replacement at the composed size. Six rows carry one: Arabic Typesetting 0.64 (RR-38, the corpus advance ratio), and, by the opf#361 rule (the smallest factor at which no line of the script corpus or of the scheme's Latin overhangs more than 3 percent natively), Angsana New 0.75, DilleniaUPC 0.68, Sakkal Majalla 0.89, Malgun Gothic 1.07 and Nirmala UI 1.07. Traditional Arabic, Ebrima and MS Gothic carry none: one factor cannot fit them (measurements). `lineAscent` and `lineAscentMixed` (em) say where PowerPoint puts the baseline below the top of a line box, for a line in the real font alone and for a line that also holds other fonts, measured in a native PowerPoint 365 probe: Angsana New 0.83 / 0.86, DilleniaUPC 0.82 / 0.85, Sakkal Majalla 0.76 / 0.81, Nirmala UI 0.97 / 0.94 and Arabic Typesetting 0.74 / 0.80 (corrected in opf#361 from RR-38's 0.70 / 0.78, which an earlier estimator read). A renderer that puts baselines one em below the line top moves such runs up by `1 - lineAscent` em; Malgun Gothic's baseline (1.06 em) sits below that, so it has none. Decomposed conjoining Hangul jamo (U+1100 to U+11FF, U+A960 to U+A97F, U+D7B0 to U+D7FF) are a known limitation: PowerPoint draws them unshaped and up to 1.9 times wider, which no factor fixes; precomposed Hangul, which real text uses, is what the Malgun Gothic factor is set on. The width that remains against PowerPoint is measured in [the Arabic line-width residual](#arabic-typesetting-and-traditional-arabic-line-width-residual-opf523).\n - **Alternates** are tried, in order, when the declared replacement's pack is not loaded. An alternate is always reported as visual, including on a metric row.\n - **Aptos family:** Aptos\u2192Intos, Aptos Display\u2192Intos Display, Aptos Narrow\u2192Intos Narrow and Aptos Serif\u2192Intos Serif are metric: 0.000% mean and maximum against Aptos 2.01 in all four styles, with equal vertical metrics.\n - **Otherwise the closest measured open face**, marked visual: a documented fallback and a known layout-fidelity gap until a metric-compatible replacement exists. For example, Segoe UI\u2192Red Hat Display measures a 1.72% mean width difference.\n2. **The PPTX always names the chosen family, and no font file is included.** The exporter writes `Aptos` when the document chose Aptos. PowerPoint resolves standard fonts on the viewer's machine: those shipped with Office, Windows or macOS, and Microsoft 365 cloud fonts. The replacement never reaches the package (opf-pptx `test/export-chosen-fonts.mjs`).\n3. **Openly licensed fonts render as themselves.** Examples are Roboto, Carlito and the Noto script families. They can reach a PPTX only through an explicit embed path (FF-13), never by default.\n4. **Families that are proprietary and non-standard, or missing from the table,** keep their name in the PPTX. `fontAvailabilityDiagnostics()` reports that viewers may lack them. It also flags Microsoft 365 cloud-only fonts (such as Aptos) and families that ship only in an optional Windows language feature.\n\n### Which faces are available\n\n`BUNDLED_FONT_MANIFEST` from `@openpresentation/opf-render/fonts-node` is authoritative for the installed renderer's families, faces, packs, licenses and hashes. Font packages can be optional peers: a declared face still needs its pinned files installed and served. Neither Node nor browser loading discovers system fonts by default.\n\n- **Base pack:** Roboto and Roboto Mono.\n- **Office pack:** the Office replacements, including Carlito, Caladea, Arimo, Tinos, Cousine and Gelasio, and the Aptos replacements Intos, Intos Display, Intos Narrow and Intos Serif.\n- **Open pack:** the open catalog families and replacement targets, including Red Hat Display for Segoe UI and Red Hat Text for Tahoma. Node `pack: 'office'` includes this pack and the base pack by default; `includeOpenFonts: false` and `includeBaseFonts: false` opt out. There is no separate proposed `catalog` pack to install.\n- **Script packs:** pinned Noto and special-purpose faces, loaded for the scripts a presentation needs with `scripts: 'auto'`, or explicitly by script codes or `'all'`.\n\nNode loaders verify the bundled manifest; browser hosts serve the package files and load the needed faces on demand, as described below. Optional script-font packages remain explicit host dependencies.\n\nThe registry tries an exact supplied family first, then an explicit alias, the permitted policy replacement and its alternates, and an explicit generic fallback if configured. Alternates are visual even when the preferred replacement is metric. Inspect `fonts.substitutions` for the actual route. `substitutionPolicy: 'visual'` permits approximate replacements; `'metric'` restricts them to metric replacements, with the policy's explicitly documented Cambria fallback; `'none'` disables policy substitutions but does not disable explicit aliases or an explicit fallback.\n\n| Environment | Font resolution | What the viewer needs |\n| --- | --- | --- |\n| Node, cloud or serverless | Supplied exact faces or loaded open replacements, controlled by the registry policy | Pinned font files available to the process |\n| Browser/editor | The same registry rules, with the host serving the required faces and awaiting `ensure(presentation)` | Self-hosted files, not a font CDN |\n| PowerPoint, exported PPTX | Authored font names; normal export does not embed fonts | Installed fonts or supported Office cloud fonts; otherwise PowerPoint substitutes |\n| Keynote, imported PPTX | Authored names when available to Keynote | Installed fonts; Keynote handles missing-font substitution |\n| LibreOffice Impress, PPTX | Authored names, subject to local replacement settings | Installed fonts or system/LibreOffice substitutions |\n\nNative substitutions depend on application version, operating system, installed fonts and user settings. OPF cannot promise one fixed replacement for a missing native font. See [PowerPoint cloud fonts](https://support.microsoft.com/en-us/office/fonts/cloud-fonts-in-office), [Keynote missing fonts](https://support.apple.com/guide/keynote/tane1c9a464f/mac), and [LibreOffice replacement settings](https://help.libreoffice.org/latest/en-US/text/shared/optionen/01010700.html). There is no native OPF `.key` exporter: import PPTX into Keynote, then save there if needed. For LibreOffice (experimental), [LibreOffice interoperability](libreoffice.md) describes the font profile OPF tests with: its preview fonts plus a fontconfig alias from each proprietary family to its replacement.\n\n### HTML and rendered exports\n\nThe renderer's `toHtml()` from `/element` emits inline SVG and supports `fontMode: 'standalone'` (faces in each slide), `'shared'` (rules once for the returned markup), and `'external'` (matching self-hosted page CSS). It uses the same rendered faces as `toSvg`; the file converter and CLI do not have an `.html` target. Node script faces need `embedScriptFonts: true` for self-contained SVG or shared HTML. When the element upgrades in a browser, supply the same pinned faces through its font root/handle.\n\nSVG with `text: 'fonts'` embeds the used faces. `text: 'system'` names the rendered families without their files and requires matching fonts in the page/viewer. `text: 'paths'` draws glyph outlines from those faces, so visible text needs no installed font; exceptional runs remain text with a diagnostic. PNG bakes the same rendered faces into pixels. PDF is vector with embedded/subset fonts and selectable text by default; raster PDF contains page images. Vector embedding depends on usable outlines and embedding permissions. These formats preserve the preview's replacement appearance; they do not switch back to the authored proprietary font.\n\nThe website's [font scheme and export matrix](https://www.openpresentation.org/docs/font-fidelity#font-scheme-and-export-matrix) is generated from the installed Gallery catalog and resolved `FONT_POLICY` on every build. Its rows, counts, code defaults, replacement tiers and size adjustments are not maintained by hand. The hosted guide, Copy as Markdown, raw agent guide and `llms-full.txt` use the same projection. The marker below is expanded by the website; this repository retains the source prose.\n\n<!-- generated-font-matrix -->\n\n**Aptos, the default scheme.** Aptos is a Microsoft 365 cloud font and is not redistributable. Under the owner policy of 2026-09-29 it previews with Intos, an OFL font whose advance widths, kerning and vertical metrics equal Aptos 2.01: 0.000% mean and maximum width difference over the 300-string corpus in regular, bold, italic and bold italic, for Aptos, Aptos Display, Aptos Narrow and Aptos Serif (Aptos Serif measured from Microsoft's standalone Aptos Fonts download, the others from the Microsoft 365 cloud fonts). Line breaks, line heights and text sizes therefore agree with Aptos. The letter shapes are Intos's own (Inter-derived, Gelasio-derived for the serif), not Aptos's. The exported PPTX still names Aptos, Aptos Display, Aptos Narrow or Aptos Serif, and no Aptos file is bundled or embedded. Deployments that hold an Aptos license can pass the real files through `faces` for exact previews.\n\nIntos ships in opf-render's default office pack (`loadFonts({pack: 'office'})`), so the default metric policy previews the Aptos family without asking for visual mode. Without those faces, previews can use the alternates Roboto and Carlito under visual policy. Like the open families, Intos is an `embed: \"used\"` face: the fonts handle supplies the faces a slide actually draws, and subsetting can reduce the embedded bytes further. Pack size is not SVG or HTML transfer size; measure the installed renderer's output and selected delivery mode rather than using historical eager-embedding totals. Intos files are pinned by commit and SHA-256, and the previous replacements stay as alternates. The pptx.gallery parity scoreboard's `fontResolution` check counts the Aptos family as perfect because the replacement is metric-compatible.\n\n**Browser hosts load the vendored faces on demand.** The eager list is what a host puts in one `fonts.json` (12.6 MB); the vendored faces (Intos and the open families, `registry.lazyFonts`, 51 faces) would add 19.4 MB, so they ship as separate hash-pinned files at their package-relative paths (`fonts/intos/...`, `fonts/<family>/...`) and load through `loadFonts({faces, lazyFontsBaseUrl})` from `/fonts-browser`. `await fonts.ensure(presentation)` (the registry's `ensureLazyFonts` and `ensureScripts` are the lower-level calls) fetches and verifies only the faces the document draws (renderer 0.11.5, face level: a plain Aptos deck needs Intos Display Bold and Intos Regular, 2 files, 1.5 MB; an italic or bold run adds one face; before 0.11.5 it was every face of the resolved families, 8 files, 5.9 MB), then adds them to the document and the registry together, so the editor never measures with a face it paints as a fallback. The gallery commits only a pinned manifest, `lazy-fonts.json` (`scripts/gallery-lazy-fonts.mjs`, copied by `prepare-gallery-editor`): exact renderer version, SPDX license, license-file hash and every face's SHA-256, no bytes. The gallery's own build copies the faces from the pinned renderer package's `fonts/` directory into an untracked path, verifying each hash, the way it does for script fonts. The local editor demo (`build-editor-demo`, through `scripts/emit-lazy-fonts.mjs`) copies the files beside the page instead. The editor playground calls `fonts.ensure(presentation)` when a document needs them.\n\nThe Windows reference-font advance study is exploratory source-checkpoint evidence, not an additional compatibility certification. It measures 1,024 cases across regular/bold Calibri, Arial, Times New Roman and Courier New, recording local reference-file versions/hashes and native font-slot names. Disabling optional ligatures and rounding base glyph advances to eighth-point steps predicts 949 observations within 0.02pt; 75 outliers remain, including combining marks, Arabic and Calibri kerning. Office theme tokens and per-glyph fallback are not resolved to exact native files by these name properties. No runtime provider or open-font mapping changes from this hypothesis, and no reference font is redistributed.\n\nThe composition API accepts a `textMeasurement` provider. A provider resolves font faces and returns actual text widths; callers pass the same provider to pagination (as `{ fonts: { textMeasurement } }`), editor geometry, SVG rendering, and PPTX export. Without one, the existing deterministic character-width estimate remains available. A provider with `forScripts(profile)` (the renderer's registry measurement) is a script planner: `validate` and `paginate` ask it for each slide's script-aware measurement, built from the slide's `resolveScriptFonts` profile and a run language's own profile, so they measure Arabic or Japanese runs in the script faces preview and export draw.\n\n`loadFonts(options)` from `/fonts-node` returns the fonts handle: the same registry measurement (`textMeasurement`), the faces to embed in SVG (`embeddedFonts`) and the explicit raster files (`fontFiles`), with system and bundled fallback disabled for raster calls (`useBundledFonts: false`, `loadSystemFonts: false`). Pass it as `{ fonts }` to every deck-level call: `paginate`, editor geometry, `toSvg`, `toPng`, `toPdf` and `toPptx`. `pack: 'base'` is the default for authored Roboto decks; `pack: 'office'` adds the Office replacements and open families, and retains metric policy unless visual substitution is explicitly requested. Core's file API and CLI explicitly use visual policy. `fonts.substitutions` records actual substitutions; the loader does not rewrite the authored document or add native embedding.\n\nRenderer 0.8.0 groups static files by their OpenType preferred family while retaining legacy family names and explicit custom namespaces. `Roboto` requests at 500/600/800 now select the actual Medium/SemiBold/ExtraBold files instead of nearby 400/700 faces. Optional `TextStyle.fontFace` carries the physical legacy family and native bold/italic flags independently of CSS numeric weight: SemiBold/ExtraBold are regular within their legacy families. The converter consumes this metadata; providers without it retain their prior behavior. Nine actual base faces pass metadata/measurement/outline checks and offline Chromium advances on Node 20/24. Seven payload slides cover serialized native selectors, deterministic output and source/reimport. These checks do not establish native Office paint, embedding or broader script coverage; see the Mac candidate evidence.\n\nRenderer 0.8.0 uses adjacent SVG spans when no measurement provider is supplied. This closes the visible gaps caused by estimated fragment widths while retaining estimated line breaks and all run text/style/source offsets. Supplied providers and accepted placements still use exact fragment origins. Measured SVG requests geometric precision; accepted outline placements also constrain horizontal advances with `textLength`/`spacingAndGlyphs` to avoid browser quantization drift. This can scale glyphs horizontally while retaining nominal font size and baseline. Width-only providers do not receive that constraint, and constrained widths do not certify raw font-metric equivalence. The compatible editor supports both forms. This is a spacing improvement, not evidence that unmeasured wrapping or glyph coverage is accurate; see candidate evidence.\n\nThe Node loader verifies the pinned package versions, font-file hashes, license notices and vendored provenance in the installed `BUNDLED_FONT_MANIFEST`; the browser loader verifies the served faces against the same pins. Missing or modified resources reject with actionable errors. Font files must remain available and unchanged between preparation and export. HarfBuzz shaping and subsetting are provided by the fonts handle when its pinned WASM resources are available; inspect diagnostics if a deployment omits them. Browser loading, glyph coverage, style selection and native compatibility remain separate requirements. The version-specific evidence below records historical checkpoints, not the current manifest's face counts or API boundaries.\n\nThe renderer's optional font registry uses [Fontkit](https://github.com/foliojs/fontkit) to shape text and measure glyph advances from local font bytes. It does not discover system fonts or fetch fonts. The Node loader loads the renderer's bundled Roboto and Roboto Mono faces:\n\n```js\nimport { loadFonts } from '@openpresentation/opf-render/fonts-node';\nimport { toSvg, toPng } from '@openpresentation/opf-render';\nimport { paginate } from '@openpresentation/opf/pagination';\nimport { toPptx } from '@openpresentation/opf-pptx';\n\nconst fonts = await loadFonts(); // pack: 'base', the bundled Roboto faces\n// Use design.fontScheme: 'roboto', or supply the document's actual font files.\nconst { presentation } = paginate(deck, { fonts });\nconst svg = toSvg(presentation, 1, { fonts }); // slide 1; embeds the faces it draws (text: 'paths' draws outlines instead)\nconst png = await toPng(svg, { fonts }); // draws with fonts.fontFiles only\nconst pptx = await toPptx(presentation, { fonts });\n```\n\n`loadFonts({ faces })` (from `/fonts-node` or `/fonts-browser`) accepts `{data: Uint8Array, weight, italic?, family?, postscriptName?, license?}` entries in Node or the browser, and `{path}` entries in Node. Weights are explicit, with 400 as the default. Supply each style that the document uses. Missing font families and unsupported glyphs fail with `OPFFontError`, including the source path where available. Collection fonts require a `postscriptName` selecting one face.\n\nAliases and fallback families are explicit choices:\n\n```js\nconst fonts = await loadFonts({\n pack: 'none', faces,\n aliases: { Aptos: 'Roboto', 'Aptos Display': 'Roboto' },\n fallbackFamily: 'Roboto',\n});\nconsole.log(fonts.substitutions);\nfonts.registry.clearSubstitutions(); // Start a fresh render's diagnostic collection.\n```\n\nAn available exact family takes precedence over aliases. The registry resolves a requested weight to the closest supplied weight, reports the substitution, and makes the resolved style available to rendering. Missing italic/upright styles fail instead of synthesizing an unmeasured style. `strictGlyphs: false` is an explicit escape hatch for hosts with their own glyph-fallback policy; it is unsuitable for fidelity verification.\n\nSVG embeds supplied fonts using data URIs and includes supplied license notices as metadata. The bundled loader carries the fonts' SIL Open Font License notices. For PNG/PDF, pass the same font files to the rasterizer; its native font loader does not depend on browser CSS font loading. In a browser, wait for `document.fonts.ready` before measuring or taking a screenshot. The editor playground loads and embeds bundled fonts and displays substitutions.\n\n`toPdf` (`svgToPdf` before 0.18) in renderers up to 0.11.9 was image-only: each slide was rasterized and embedded as a PNG on a PDF page. From opf-render 0.12.0 (opf-render#90, [roadmap](plans/pdf-export.md)) the default vector mode writes PDF text objects in embedded TrueType subsets of the fonts you supply or the bundled open pack (the same files the PNG preview uses; system fonts are rejected, a face whose OS/2 `fsType` forbids embedding is never embedded, the report names requested and resolved faces), with `ToUnicode` maps and `/ActualText` where the glyph map cannot give the text, vector shapes, gradients and images, and no second layout pass. `raster: true` (`mode: \"raster\"` before 0.18) keeps the image-per-slide output as an explicit compatibility mode. Extraction was checked in pdf.js, PDFium and poppler on Latin, CJK, right-to-left and Indic samples and all 805 example slides; PDFium misreads some Thai and Burmese marks, as it does in Chrome's own PDFs. No PDF/UA or PDF/A claim.\n\n## Office compatibility pack\n\n`loadFonts({ pack: 'office' })` from `@openpresentation/opf-render/fonts-node` supplies regular, bold, italic, and bold italic faces of Carlito, Caladea, Arimo, Tinos, Cousine, and Gelasio, plus the base Roboto pack. Package versions are pinned and each face carries its distribution's license notice. `includeBaseFonts: false` omits Roboto. Loading never installs fonts into the operating system or downloads fonts at render time.\n\n```js\nconst fonts = await loadFonts({\n pack: 'office',\n substitutionPolicy: 'metric', // Default for the office pack; no visual fallback.\n});\nfonts.registry.resolveFont({fontFamily: 'Calibri', fontWeight: 400});\n// requestedFamily: Calibri, resolvedFamily: Carlito, compatibility: metric\n```\n\n`loadFonts` defaults to `substitutionPolicy: 'none'` (the office pack to `'metric'`). Policies are `none`, `metric`, and `visual`; visual permits both curated tiers. An explicit `fallbackFamily` is a separate, reported `generic` fallback. Aliases are explicit visual substitutions and never establish metric compatibility. `resolveFont` reports exact resolutions as well; `substitutions` only collects changes. Resolution records include requested/resolved weights, italic, source path, and supporting upstream information where available.\n\n| Requested family | Bundled substitute | Current automatic tier |\n| --- | --- | --- |\n| Calibri | Carlito | Metric intent, standard 400/700 styles |\n| Cambria | Caladea | Visual: advances differ from Cambria 6.99 by a mean of 2.7% (FF-31 measurement). Metric-mode registries still use it, reported as visual (`metricModeFallback`) |\n| Arial | Arimo | Metric, standard 400/700 styles |\n| Times New Roman | Tinos | Metric, standard 400/700 styles |\n| Courier New | Cousine | Metric, standard 400/700 styles |\n| Georgia | Gelasio | Metric with `liga` and `clig` off (`disabledFeatures`, applied by opf-render): advances identical on all 300 corpus strings in four styles. With default features, ligature runs differ by up to 1.02% |\n| Calibri Light | Carlito | Visual: the bundle has no Carlito Light face |\n| Aptos, Aptos Display, Aptos Narrow, Aptos Serif | Intos, Intos Display, Intos Narrow, Intos Serif (office pack) | Metric: 0.000% mean and maximum against Aptos 2.01, all four styles; Roboto and Carlito are visual alternates |\n\nUpstream evidence: [Carlito](https://github.com/googlefonts/carlito), [Fontconfig mappings](https://chromium.googlesource.com/external/fontconfig/+/refs/heads/main/conf.d/30-metric-aliases.conf), [Arimo](https://github.com/google/fonts/blob/main/ofl/arimo/DESCRIPTION.en_us.html), [Tinos](https://github.com/google/fonts/blob/main/ofl/tinos/DESCRIPTION.en_us.html), [Cousine](https://github.com/google/fonts/blob/main/ofl/cousine/DESCRIPTION.en_us.html), and [Gelasio](https://github.com/SorkinType/Gelasio). Metric classification describes compatibility intent within the stated style scope, not universal identical output. Missing matching weights cannot silently qualify for the metric tier.\n\nRR-17: Liberation Sans, Serif and Mono are not bundled (Reserved Font Name, about 4.4 MB); a document that names them previews with Arimo, Tinos and Cousine, the Croscore faces Liberation 2 is built from (metric, 0.0000% in four styles). Each Latin replacement has a per-family qualification and a fixture in every host; see the [font tracker](programs/font-fidelity-everywhere/font-tracker.md).\n\nWeight-named Segoe UI Light and Semilight preview with Red Hat Display 300 for regular text and 400 for bold emphasis. Semilight targets 350, but the bundled font has no 350 face, so this remains a visual approximation. PPTX retains the authored family. Yu Gothic Regular also remains a documented visual gap: its Noto Sans JP Regular stand-in draws heavier strokes. See the [font tracker](programs/font-fidelity-everywhere/font-tracker.md) and comparison sheets.\n\nThe exported `FONT_COMPATIBILITY` list also contains optional visual candidates and CJK families. Listing a candidate does not bundle it or imply complete character coverage. Liberation Sans Narrow is a separate legacy distribution with a different license history; it is not part of this bundle. Wingdings, Webdings, and Symbol require character mapping before substitution; an ordinary fallback fails with `font-encoding-required`. Cambria Math previews with STIX Two Math and Segoe UI Emoji with Noto Color Emoji once opf-render's optional math and emoji packs are loaded (FF-45, [special families: emoji and math](programs/font-fidelity-everywhere/special-families-emoji-math.md)); without the pack a renderer reports `font-unavailable` naming it, like any other routed family (the former `math-font-required` failure is gone). OPF has no equation model: a Cambria Math run is text drawn per character in a math face, not MATH-table layout.\n\nDrawingML tokens such as `+mn-lt` resolve through the registry's explicit `themeFonts` option before substitution. Supply concrete `majorLatin`, `minorLatin`, and, where used, `majorEastAsia`, `minorEastAsia`, `majorComplexScript`, or `minorComplexScript` families. Missing theme mappings fail. This helper does not yet extract theme font records or embedded fonts from imported PPTX files.\n\n### Measured results and experimental fonts\n\n`node scripts/test-office-fonts.mjs --system` compares the bundle to reference fonts already installed in macOS's Supplemental directory. It does not redistribute reference fonts. The report records source-file hashes and individual shaped widths. Across four samples and four styles, Arimo/Arial, Tinos/Times New Roman, and Cousine/Courier New matched exactly on 48 runs. Gelasio/Georgia differed on ligature-containing runs, with a maximum difference of 2.0125%. Individual basic-Latin advances matched; disabling optional ligatures removed the tested difference. That earlier comparison predated the current disabled-feature qualification: the policy now marks Georgia\u2192Gelasio metric when `liga` and `clig` are off, as described above. Calibri and Cambria reference fonts were not available for this comparison.\n\nAkasia, assessed earlier (v0.0.2 open-file assessment), is dropped: its repository is no longer available, and Intos replaces it. `EXPERIMENTAL_FONT_CANDIDATES` now records Microsoft's Selawik, measured for Segoe UI on 2026-09-29 and rejected: 0.16% mean and 2.5% maximum in regular, no italic faces, 349 code points, lowercase 4.8% shorter. The acceptance rules for replacement fonts are in the [licensing table](programs/font-fidelity-everywhere/font-licensing.md#replacement-font-acceptance-rules).\n\nAn original OPF font project is technically feasible: independently designed or suitably open-licensed glyph outlines can be fitted to target advance widths, placement, vertical metrics, and shaping behavior. A successful font needs a reproducible source build, provenance, style/coverage tests, visual review, and cross-renderer conformance. Matching bounding boxes alone is insufficient: [OpenType horizontal metrics](https://learn.microsoft.com/en-us/typography/opentype/spec/hmtx) and [glyph positioning](https://learn.microsoft.com/en-us/typography/opentype/spec/gpos) jointly control text placement. Universal pixel identity across rasterizers is not the acceptance criterion; measured layout preservation over an explicit test matrix is.\n\n## Verification and remaining work\n\nScript fonts (CJK, Arabic, Hebrew, Indic, Thai, Khmer, Myanmar and the rest) have their own shaping corpora and per-family qualification (FF-44, RR-17): see [script-corpora.md](programs/font-fidelity-everywhere/script-corpora.md). It records, per script, glyph coverage, fontkit against HarfBuzz and Chromium, the installed originals measured in place, and dated shaping/raster limitations and their fixes. Read each result with its exact renderer and rasterizer versions; historical resvg-js failures do not describe every later PNG path or establish native acceptance.\n\n### Arabic Typesetting and Traditional Arabic: line-width residual (opf#523)\n\nNeither family is bundled; both preview and compose with Noto Naskh Arabic (OFL-1.1). Arabic Typesetting carries the RR-38 `sizeAdjust` of 0.64, and Traditional Arabic has none. Native PowerPoint draws lines in both families **narrower** than the shared composition measures them. This is a known, accepted residual.\n\n**Measured.** All widths are PowerPoint 365 `TextRange.Lines` bounds or ink, against the composed line.\n\n| Family | Native lines | Native / composed width | Largest gap |\n| --- | --- | --- | --- |\n| Arabic Typesetting (proxy at 0.64) | 16, in RR-59 and FF-46 set 2 | 14 lines at 0.86 to 0.97 (headings 0.86 to 0.92, body 0.90 to 0.97); one FF-46 body line at 1.04; one FF-46 heading at 0.55; pooled 0.94 without that heading | 56.6 pt narrower on an 856 pt body line (284 pt on the 0.55 heading); 31 pt wider on the 1.04 line |\n| Traditional Arabic (proxy at 1) | 10, in the same two runs | 0.68 to 0.90, pooled 0.79 | 223.6 pt narrower (an 842 pt body line) |\n\nThe RR-38 probe agrees for Arabic Typesetting. Its 45-character line is 216.9, 289.0 and 386.1 pt at 18, 24 and 32 pt in PowerPoint, and composes at 222.1, 298.6 and 396.9 pt.\n\n**Why it exists.** Three reasons:\n- **No published metrics.** Microsoft's font pages for [Arabic Typesetting](https://learn.microsoft.com/en-us/typography/font-list/arabic-typesetting) and [Traditional Arabic](https://learn.microsoft.com/en-us/typography/font-list/traditional-arabic) give only the file names, styles, vendor, scripts and code pages. They publish no advance widths, `xAvgCharWidth` or vertical metrics.\n- **No metric-compatible open face.** None exists for either family: no fontconfig metric alias, no Croscore-style clone. OPF does not take metrics from the installed proprietary files.\n- **One factor cannot fit.** Per glyph, Noto Naskh Arabic's advances differ from these fonts' by more than any scale can absorb. Ligatures and letter widths vary by text. Arabic Typesetting also has only a regular face, so PowerPoint emboldens bold text synthetically, while the preview draws Noto Naskh Arabic Bold.\n\n**One factor per family does not fix it.** For Traditional Arabic, the native / Noto Naskh ratio of the 10 lines spans 0.68 to 0.90, so any one factor leaves large gaps:\n\n| Factor | Largest gap, composed wider | Largest gap, native wider |\n| --- | --- | --- |\n| 0.79 (the pooled ratio; the opf#361 proposal) | 47 pt | 48 pt |\n| 0.90 | 139 pt | none |\n\nLatin text in a deck that uses the Traditional Arabic scheme also draws in Noto Naskh Arabic's Latin, where the policy measures Traditional Arabic at 0.86 of the replacement's width. At 0.79, those lines would run about 9 percent past their composed width in PowerPoint. Arabic Typesetting's 0.64 already sits near the upper edge of its native ratios. A lower factor would let more lines run past their boxes.\n\n**Practical impact.**\n- **Line counts agree.** The PPTX export writes each composed line as its own text box, and PowerPoint does not re-wrap it. Line counts, the order of lines and the right edges of right-to-left lines therefore agree: within 0.13 pt in RR-59.\n- **Left edges differ.** The left edge of a right-to-left line (the right edge of a left-to-right one) sits closer to the text in PowerPoint. The same text could fit in fewer lines natively than the preview shows.\n- **Overhang is rare.** Because the proxy errs wide, a Traditional Arabic line keeps slack in its box. For Arabic Typesetting, an occasional line runs a few percent past its composed width: 3.78 pt past its box in RR-59 `ar-run-in-en`, not clipped.\n- **Wrapping can differ near the edge.** Text that PowerPoint lays out itself wraps where the real font's widths put it, which can differ from the preview. That covers a line box retyped in PowerPoint, and text another application re-flows.\n\nFor layouts that must wrap exactly, choose a family with a metric replacement, or supply licensed font files through `loadFonts({faces})`.\n\n`pnpm test:fonts` checks that editor and SVG geometry match and that every native PPTX text box has the same coordinates and measured line breaks. With opf-pptx FF-31 (opf-pptx#63), export names the chosen family, not the preview substitute. It writes artifacts to `artifacts/fonts/`. A real-browser check of the same Roboto run measured 324.032 pixels versus the font engine's 324.170 pixels at 25 pixels, a difference of 0.138 pixels. These are measured tolerances, not a promise of pixel identity.\n\nPPTX records the chosen font family (FF-31); it never records a preview replacement and never embeds a proprietary font binary. PowerPoint still needs those fonts installed, through Office, the OS or Microsoft 365 cloud fonts, or it substitutes them. Line height remains the shared 1.22 multiplier, rather than a complete ascent/descent model. Rich-text font overrides, mixed-script fallback and bidi layout, specialized payload internals, and native font embedding remain active fidelity work. Passing a width provider does not remove those limits.\n"
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
"slug": "footnotes-citations-captions",
|
|
@@ -258,7 +258,7 @@ var docsData = Object.freeze([
|
|
|
258
258
|
"slug": "mcp",
|
|
259
259
|
"file": "docs/mcp.md",
|
|
260
260
|
"title": "OPF MCP server",
|
|
261
|
-
"markdown": "# OPF MCP server\n\n`@openpresentation/mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server for OPF, so an agent or editor that speaks MCP can learn the format, look things up and check a deck without shelling out and parsing text. It teaches OPF (documentation, schemas, the default catalog, example decks and the six agent skills, all as resources, with a `start_here` tool that gives a path for a goal), and it runs the checks the CLI runs (`validate_deck`, `convert`).\n\nIt also shows decks: `show_deck` opens the OPF viewer inside a client that supports MCP Apps (Claude on the web and desktop), with Preview, Source and Both, where the user can edit the deck and the edits come back to the model ([The OPF viewer](#the-opf-viewer-show_deck)).\n\nIt keeps no state, reads no file (everything it serves is bundled in the package, and tools work on the text you pass in; the one exception is the renderer's font files, which `opf-mcp` hands to the viewer), fetches nothing and has no network access. It runs two ways: locally over stdio (this page), and hosted on an edge runtime (the same server definition over Streamable HTTP). The hosted connection target is `https://www.openpresentation.org/mcp`; its deployed version, tools and viewer availability follow that site\u2019s deployment, separately from the npm package. Check the [hosted MCP guide](https://www.openpresentation.org/docs/mcp) for that deployment. The packaged `show_deck` viewer described here does not establish that a hosted deployment offers it. The local server measures layout with real fonts when `@openpresentation/opf-render` is installed.\n\n## Set it up\n\n**Hosted, nothing to install.** `https://openpresentation.org/mcp` is this server over Streamable HTTP: no account, no key, read-only, and it keeps nothing. In Claude (web or desktop): Settings, Connectors, Add custom connector, name it `OPF` and paste the URL; other clients take the same URL as a remote MCP server. Then ask for a deck (\"make a five-slide OPF deck about our Q3 results and show it to me\") and the OPF viewer opens in the conversation. A deck you pass to `validate_deck`, `convert` or `show_deck` is read in memory for that one call and not stored; the viewer itself edits, checks, draws and exports the deck on your machine. The hosted server allows 600 requests a minute per address and bodies up to 4 MB.\n\n**Local.** Any MCP client that starts a local server takes a command and arguments:\n\n```json\n{\n \"mcpServers\": {\n \"opf\": { \"command\": \"npx\", \"args\": [\"-y\", \"@openpresentation/mcp\"] }\n }\n}\n```\n\nPin a version (`@openpresentation/mcp@0.27.0`) to make the setup repeatable. Node 22 or later is required.\n\n| Client | How |\n| --- | --- |\n| Claude Code | `claude mcp add opf -- npx -y @openpresentation/mcp` (add `--scope project` to write `.mcp.json` for the team) |\n| Cursor | Add the JSON above to `.cursor/mcp.json` in the project, or to `~/.cursor/mcp.json` |\n| Claude Desktop | Install the extension (`opf-<version>.mcpb`, below), or add the JSON above to `claude_desktop_config.json` |\n| Any other client | Run `npx -y @openpresentation/mcp` as a stdio server (installed, the binary is `opf-mcp`) |\n\nCheck it with the official inspector: `npx @modelcontextprotocol/inspector npx -y @openpresentation/mcp`.\n\n### Claude Desktop extension (`.mcpb`)\n\nThe server also comes as an MCP Bundle, a one-file Claude Desktop extension: open `opf-<version>.mcpb` (double-click it, or drag it into Claude Desktop's Settings, Extensions) and Claude Desktop installs and starts it. It needs no Node install, no `npx` and no configuration, and it carries the renderer and its fonts, so the OPF viewer draws decks with the exact faces and validation measures layout with them.\n\nWhen the matching [GitHub release](https://github.com/OpenPresentation/opf/releases) lists `opf-<version>.mcpb` and its SHA-256 file, download both assets from that release. Release-bundle publication is planned from 0.34.0; 0.33.0 has no published bundle asset. The trusted publish workflow builds and checks the full bundle before attaching it after registry verification. Verify it with `sha256sum --check opf-<version>.mcpb.sha256` on Linux, or compare `Get-FileHash opf-<version>.mcpb -Algorithm SHA256` to the file on Windows.\n\nBuild it from a checkout: `pnpm --filter \"@openpresentation/mcp...\" run build`, then `pnpm --filter @openpresentation/mcp run build:mcpb`. It writes `packages/mcp/artifacts/opf-<version>.mcpb` (about 81 MB, every font the renderer draws with); `node scripts/build-mcpb.mjs --no-script-fonts` writes `opf-<version>-lite.mcpb` (about 33 MB) without the script faces (Japanese, Chinese, Korean, Arabic, Devanagari and the other scripts), whose text then draws with fallbacks. `--check` also unpacks the bundle and drives its server the way Claude Desktop starts it. The build packs this checkout's `@openpresentation/opf`, `gallery`, `opf-render` and `mcp`, and installs their third-party dependencies and the renderer's font packages from the npm registry, keeping only the font files the renderer's manifests name. The manifest is `packages/mcp/mcpb/manifest.json`; `test/mcpb-manifest.test.mjs` keeps its tool list in step with the server.\n\n`opf mcp` of the CLI is a convenience: it runs this server when `@openpresentation/mcp` is installed beside the CLI or in the working directory, and otherwise prints `npx -y @openpresentation/mcp` and exits with 2. The CLI itself carries no MCP code.\n\n## Tools\n\nEvery tool takes JSON arguments and returns structured JSON (`structuredContent`, with the same JSON as text for clients that read only text; `show_deck`, `read_font_file` and `read_icons` answer in their own text). A failure comes back with `isError: true` and a text report `{ ok: false, code, error, ... }` (no structured content), with a stable `code` (`unknown-id`, `invalid-document`, ...) and, where it helps, a suggestion (\"Did you mean two-column?\"). All tools are read-only.\n\n| Tool | Arguments | Returns |\n| --- | --- | --- |\n| `start_here` | `goal?` (what you are trying to do, in your own words) | `{ goal, summary, steps[], docs[], skills[], examples[], layouts[], themes[], validate }`: a short ordered path. Which documentation pages and skill to read, two or three example decks, layouts and themes from the catalog, and the validate step (`validate_deck` with `failOn: \"warning\"`). With no goal, the general learning path. Everything it names is a resource URI or a tool to call next. |\n| `validate_deck` | `document` (a JSON object, or deck text), `format?` (`json`, `yaml`, `markdown`; default JSON), `failOn?` (`error`, `warning`, `info`; default `error`) | `{ ok, valid, schemaValid, failOn, format, counts, findings[], checks, hint? }`. The findings are the ones `opf validate` reports (rule id, severity, category, JSON Pointer `path`, message, `help`, `fixes`, and a `location` with line and column for JSON, YAML and Markdown text). `ok` is false when a finding is at or above `failOn`. It does not look for local image files (it reads none). |\n| `get_schema` | `name?` (a schema such as `presentation` or `layout`, or a `$defs` name such as `Chart`), `pointer?` (a JSON Pointer into the schema, or a `$defs` name) | `{ name, pointer, id, schema, opfVersion }`, like `opf schema`. `$ref`s stay as written. A whole schema names the `@openpresentation/opf` release it came from in its `$comment`; a part is as it is. |\n| `search_catalog` | `kind` (`layouts`, `themes`, `color-schemes`, `font-schemes`, `narratives`, `audiences`, `purposes`, `tones`, `chart-types`, `languages`, `social-platforms`, `examples`), `query?`, `limit?` | `{ kind, total, returned, records[] }`: short records (id, name, summary, description, tags), best match first. |\n| `get_catalog_record` | `kind`, `id` | `{ kind, id, uri, record }`: the record in full, like `opf catalog <kind> <id>`. |\n| `convert` | `document`, `from?`, `to` (`json`, `yaml`, `markdown`) | `{ ok, from, to, text, findings, counts }`, like `opf convert`. The deck must be valid; otherwise nothing is converted and the findings are returned. This tool converts text formats only. The viewer separately offers PowerPoint, PDF and PNG Export in a host that can save files; the local `opf convert` also writes rendered formats. |\n| `search_docs` | `query`, `limit?` | `{ total, results[] }`: ranked pages and skills, each with `uri`, `title`, the `heading` the snippet sits under, a `snippet` and a `score`. |\n| `search_shapes` | `query?`, `category?` (`lines`, `rectangles`, `basic`, `blockArrows`, `equations`, `flowchart`, `starsBanners`, `callouts`, `actionButtons`), `limit?` | `{ query, total, returned, shapes[], categories[] }`: the 187 preset shapes of a shape block or an overlay shape, searched by DrawingML name (`rightArrow`) and common words (`speech bubble`, `cylinder`, `cog`; every word must match, a name ranks first; an empty query browses PowerPoint's gallery in order). Each shape has `shape` (the value to write), `category` and `categoryTitle`, `aspect` (the default frame, width over height), `adjust[]` (each adjust value's `name`, `default`, `min`, `max`, `unit` of `fraction` or `degrees`, and whether a `handle` moves it, at a square frame) and `svg`, a small drawing from the preset's own geometry. |\n| `list_examples` | `category?`, `query?` | `{ total, categories, examples[] }`: slug, name, category, slide count and `uri` for each bundled example deck. |\n| `show_deck` | `document` (a JSON object, or deck text), `format?`, `view?` (`preview`, `source`, `both`; default `preview`), `slide?` (from 1), `session?` | Opens the deck in the OPF viewer (`_meta.ui.resourceUri: ui://opf/deck`). `{ opened, checked, view, slide?, format, name, slides, outline[], valid, counts, findings[], viewer, iconSets }`, and as text the deck's name, slide titles, findings and the viewer session key, so a client without MCP Apps still gets an answer. With `processDecks: false` (a hosted server that does no deck work), `{ opened, checked: false, view, format?, viewer, iconSets }` only: the viewer does the checks. `iconSets` names the icon sets the viewer can read through `read_icons` (`[]` when the server has none). A later call for the same deck (the same name) replaces the open viewer of it; `session` chooses another session. `viewer` is `{ session, createdAt, tie }` ([Instances](#instances-and-the-viewer-session)). |\n| `open_editor` | `example?` (a bundled example's slug), `title?` (the deck's name: the starter deck's title, or a new name for the example), `session?`; all optional | Opens the OPF viewer's editor with a deck to edit: with `{}` a two-slide starter deck (\"Untitled deck\"), or the example named. `{ opened, editor: true, example, name, slides, document, examples[], viewer, iconSets }`; an unknown slug still opens the starter deck and the text names the nearest slug. Title \"OPF deck editor\". Its `_meta` carries `ui.resourceUri` and `\"openai/ui\": { \"entrypoints\": [{ \"type\": \"global\" }] }`, the marker Claude reads to offer the app as a direct entry point ([Entry point](#the-direct-entry-point-open_editor)). |\n| `read_font_file` | `file` (a path from the renderer's font manifest), `offset?` | For the viewer only (`_meta.ui.visibility: [\"app\"]`; a host hides it from the model). `{ file, offset, total, bytes }`: at most 512 KiB of the file, base64. Offered by `opf-mcp` when `@openpresentation/opf-render` is installed beside it. |\n| `read_icons` | `set` (`lucide`, `tabler`), `names` (at most 100 icon names), `index?` | For the viewer only (`_meta.ui.visibility: [\"app\"]`). `{ set, icons, errors?, index? }`: the path data of the icons the set has (a name it lacks is left out: the index names every icon), why a name could not be read, and with `index` the set's index (`names`, `viewBox`, `style`, stroke settings, `name`, `version`, `license`, `copyright`, `licenseText`). The viewer asks for the index once per set. Offered when the server has icon sets (`sources.iconSets`; `opf-mcp` and the `.mcpb` read the installed files) and the viewer. |\n\n## Resources\n\nResources have stable URIs. The server lists them (`resources/list`) and also offers URI templates (`resources/templates/list`) so a client can read a URI it builds itself.\n\n| URI | What it is |\n| --- | --- |\n| `opf://docs/index` | Every documentation page and skill, with its URI |\n| `opf://docs/whats-new` | The most recent release notes: the last five versions of the changelog of `@openpresentation/opf` (the format, the validators and the engine), newest first, as text |\n| `opf://docs/<slug>` | A documentation page as Markdown: `format-card` (the whole authoring surface on one page, sized for pasting into a model's context), `how-opf-works`, `schema-reference`, `validate`, `cli`, and the other pages meant for people who use OPF. Handoff, evidence, status and release notes are not served. |\n| `opf://schema/<name>` | A JSON Schema (`opf://schema/presentation`) |\n| `opf://schema/<name>#<pointer or $defs name>` | Part of a schema: `opf://schema/presentation#Chart`, `opf://schema/presentation#/properties/slides`. `opf://schema/Chart` also works. |\n| `opf://examples/<slug>` | A valid example deck as JSON |\n| `opf://catalog/<kind>/<id>` | A record of the default catalog (`@openpresentation/gallery`): `opf://catalog/layouts/two-column` |\n| `opf://skills/<name>` | A skill entrypoint (`opf-author`, `opf-layout`, `opf-presets`, `opf-edit`, `opf-export`, `opf-inspect`) |\n| `opf://skills/<name>/<path>` | A reference or asset of a skill: `opf://skills/opf-author/references/content.md` |\n| `ui://opf/deck` | The OPF viewer (`text/html;profile=mcp-app`): one HTML page (about 9.1 MB of UTF-8; `pnpm --filter @openpresentation/mcp build` prints the exact size and the JSON-RPC frame's headroom under the 10 MiB stdio limit) that `show_deck` and `open_editor` open. The `resources/read` content item carries `_meta.ui` `{ prefersBorder: false, preferredDisplayMode: \"fullscreen\" }`; the viewer declares no `csp`, `domain` or `permissions` (any of them would go on the same content item). |\n\nSkill scripts and agent manifests are not served; the server runs no code from them.\n\n## The OPF viewer (`show_deck`)\n\n`show_deck` is an [MCP App](https://github.com/modelcontextprotocol/ext-apps) (SEP-1865): in a client that supports MCP Apps, such as Claude on the web and desktop, the deck opens in the conversation with the openpresentation.org playground's three views.\n\n- **Preview** shows the slides, with the thumbnail strip under them. **Source** shows the deck's text (JSON, YAML or OPF Markdown) in the editor's source pane, checked as you type. **Both** puts them side by side; in a container narrower than 860px it stacks the slide over the source, and choosing it there asks the client for a larger view. The slide itself can be edited in place too. The model is told to open on Preview unless the user asked for the source.\n- **The bar** (48px, one row down to a 640px container, two rows and no Both below it, and every control still in two rows at 320px): Undo and Redo, the deck's name (a little room from 640px, a row of its own below 640px; renaming opens the editor's Save and Cancel over the whole bar, or over the name's own row where the bar wraps, and Enter or Save commits one undoable edit, Escape or Cancel puts the name back, and leaving the field closes an untouched rename and keeps a typed draft), the view switch, the editor's Design menu (theme, colors, fonts and the slide's layout, each one undoable edit), Find and replace (Ctrl/Cmd F), Export, Expand, and **Send to Claude**. Undo stops at the deck as it was opened. Present is left out (a sandboxed iframe cannot go full screen on its own), and the source pane's Copy works without the clipboard permission.\n- **Export** is the editor's own menu: PowerPoint (`@openpresentation/opf-pptx`, editable), PDF (vector, selectable text), SVG and PNG slides, and the OPF source as JSON, YAML or Markdown. Every file is made in the viewer, on the user's machine, with the fonts the slides draw with, and handed to the client to save (`ui/download-file`), since a sandboxed iframe cannot download. The menu, and the source pane's Download, show only in a client that declares that capability; the agent handoff is left out, the deck being in a conversation already.\n- **Your edits go back to the model.** A second after the last edit, the viewer sends the whole deck to the model as context (`ui/update-model-context`), so its next answer continues from your version; the footer says so (`Edits not shared yet`, then `Claude has your edits`). **Send to Claude** also asks for a turn (`ui/message`): it is the view's one primary button, filled while there are edits you have not sent, and it stays usable to send again. In a client that is not Claude the wording is \"the assistant\". Where the client offers the viewer's tools, the model changes the open deck in place ([The viewer's tools](#the-viewers-tools-editing-together)); otherwise it calls `show_deck` again and a new viewer opens, and with the session key the earlier one steps aside.\n- **The checks run in the viewer.** It runs core's validators on every change, with text measured by the fonts the slides draw with, and sends the findings to the model with the deck. The status footer (28px) shows the verdict at the left, the editor's review pill (`Valid OPF`, `2 issues`), which opens the Review panel in a drawer; then the slide navigator (previous, `01 / 16`, next), the editor's status line, and the version at the right.\n- **One palette, the client's.** The viewer is built to the openpresentation.org design system (the playground's bar and footer) and reads only the editor's `--opf-ui-*` tokens. In a client that sends the standard MCP Apps style variables, the neutral tokens (surfaces, text, borders) are derived from the client's background and text colors and its fonts, for the viewer's own chrome and the editor's parts alike, in the client's light or dark theme; the accent and the status colors stay OPF's, and the slides keep the deck's theme. Without those variables it uses the design system's own values.\n- **It is as tall as the deck needs.** Inline, the stage takes the shape of the deck's slides (up to 480px) with 16px around the slide on every side, so a 16:9 deck in a 660px column is about 545px tall; until the deck is drawn, a slide-shaped placeholder holds its place and says what the viewer is waiting for; Source and Both have a fixed height. Full screen, and a client that fixes the height, fill the frame.\n\n- **Saving is controlled by the host.** Source downloads preserve the current JSON, YAML or Markdown text, MIME type and suggested filename; the host controls confirmation and saving. Each outcome is worded as the host reports it ([capabilities](#what-the-viewer-does-with-each-host-capability)); \"Download started.\" is not proof that a file was saved. Without download support the file controls stay hidden; the viewer never substitutes a direct iframe Blob/anchor download. Source text can still be selected and copied manually.\n\n**Everything runs on the user's machine.** The page bundles `@openpresentation/opf-editor`, `@openpresentation/opf-render` and core's precompiled validators, so the editing, rendering and checking happen in the client, not on the server. The client runs it in a sandboxed iframe with no network, no `eval` and no WebAssembly (the restrictive default CSP of SEP-1865, since the viewer declares no domains), so the page loads nothing: its script, styles and the startup font (Roboto Regular) are inline. Any other face a deck draws comes from the server through the client: the viewer calls the app-only tool `read_font_file`, which serves the installed renderer's files in pieces of 512 KiB, and the renderer checks each file against its pinned SHA-256 before it registers it as bytes (`FontFace` from an `ArrayBuffer`, which needs no `font-src`). Without the renderer beside the server, or on a server that offers no `read_font_file`, the viewer draws those faces with Roboto and names the substitution. Images in a deck draw when they are data URIs; the sandbox blocks a remote image.\n\n**Set icons** (`\"icon\": \"lucide:rocket\"`) come from the server the same way: the viewer registers the gallery's sets as loaders that call the app-only tool `read_icons` for the icons a deck names (at most 100 a call, so a deck with more makes more calls) and for each set's index once (every name, so a check suggests the nearest names, and the license). The page carries no icon data. The viewer learns which sets the server reads from `iconSets` in the `show_deck` or `open_editor` result; a set the server does not offer, a server without `read_icons`, or a call that fails settles the load: the slide draws without the icon, and `opf/icon-unknown` says it could not be loaded and why. The viewer's checks, and the checks in `read_deck` and `edit_deck` results, wait for the deck's icons, so a known icon is never reported and an unknown name gets the same finding and suggestions as `validate_deck`. The viewer has no icon picker (that is the editor's Content panel), so it never reads the sets' search keywords.\n\n**In a client without MCP Apps** (Claude Code, the API), `show_deck` returns the deck's name, slide titles and findings as text, like a short `validate_deck`, and `open_editor` returns its deck and the example slugs.\n\n### What the viewer does with each host capability\n\nEvery capability below is the host's to offer, and Claude can limit each one by connector type (several need a remote connector: a custom connector added by URL or a directory listing, not a local server), by organization and by client. Nothing here is available to every user, and none of it was verified in Claude from this repository; the stand-in host in `test/deck-app-tools-browser.mjs` and `test/deck-app-browser.mjs` behaves as Claude's MCP Apps documentation describes. The viewer keeps working without each one.\n\n| Capability | Where the host offers it | Where it does not |\n| --- | --- | --- |\n| **The viewer's own tools** (`read_deck`, `select_slide`, `edit_deck`) | The model reads the open deck and changes it in place, one undoable edit per call, and the user sees it at once. Claude gets a view's tools from the user's next message after the view opened, and only for a remote connector. | The tools are never called; the model sees the user's edits as context and opens a new viewer with `show_deck` to change the deck. |\n| **Model context** (`ui/update-model-context`) | A second after the last edit the whole deck goes to the model, with its revision and the viewer session key. A viewer that `open_editor` opened sends the deck it opened (the starter deck or the example, named) in its first context too. | The footer says nothing about sharing; Send still asks for a turn where messages work. |\n| **Messages** (`ui/message`) | **Send to Claude** asks for a turn on the user's click. In Claude: `Sent to Claude for your approval` when Claude took it (not proof that the user approved or the model read it); in another host: `Sent to the assistant`. `Claude didn't take the message` when it was refused, `The message couldn't be confirmed` when the request failed or timed out. Send stays usable to try again. The message is one short sentence; the deck goes as context, never in the message. | No Send button. |\n| **Downloads** (`ui/download-file`) | Export and the source pane's Download hand the file to the host: `Download started.`, `The download didn't finish.`, or `The download couldn't be confirmed.` (a rejection or the ten-minute timeout; the host's dialog may still save it). A host that answers \"method not found\" gets `This host does not offer downloads here. Select the source text to copy it.`, and Download and Export are no longer offered. One request at a time: a click while one waits sends nothing and says so. The file name is the URI's last segment as written (never percent-encoded); the viewer turns / \\\\ % : \" * < > \\| ~ # ? into `_` itself, so the name the user sees is the one it chose. The viewer makes only PowerPoint, PDF, PNG, SVG, ZIP and OPF source files, none of a type a host refuses outright. | No Export menu or Download button; the source text can be selected and copied. |\n| **A larger view** (`ui/request-display-mode`, `availableDisplayModes: [\"inline\", \"fullscreen\"]`) | **Expand** asks from the click itself (Claude honors it only right after a press in the view and opens its side panel or full screen; both report `fullscreen`); the label becomes **Back to the conversation**. A refusal leaves the label as it was and says the host kept the viewer where it was. The content item's `preferredDisplayMode: \"fullscreen\"` asks Claude to open the side panel when the tool returns; Claude decides. | No Expand button; the viewer stays inline. |\n| **Server tools from the view** (`tools/call`) | Fonts (`read_font_file`), set icons (`read_icons`) and the editor's example picker (`get_catalog_record`). | The deck draws with Roboto in place of faces it cannot get and without its set icons (each with an `opf/icon-unknown` finding that says it could not be loaded), and the editor offers only its starter deck and Paste. |\n\n**Layout** follows the container the host reports (`containerDimensions`: its width, and a fixed or a maximum height): the side panel and full screen are both `fullscreen` and the side panel can be resized down to about 320px. A fixed height fills the frame, and so does `fullscreen` when the host sends no dimensions with it (borderless); a maximum height keeps the inline view as tall as its slide. The host's `safeAreaInsets` pad the view, and `hostcontextchanged` lays it out again. In the narrowest container (under 400px) every control in the bar, the start row and the footer is at least 44 by 44 CSS pixels, Send has a row of its own, and the footer wraps a long message instead of cutting it short. A status message clears itself after eight seconds.\n\n### The viewer's tools (editing together)\n\nThe viewer registers three tools before it connects, and their names, titles, descriptions and schemas never change while it runs (Claude may ask the user to approve a tool again when one does); changing values go in results. Each answers in text, which is what the model reads, and acts on its own view only: with two viewers open, a call reaches one. Inputs a model is likely to get wrong (an unknown `op`, too many operations, a negative or fractional `offset` or `index`, both or neither of `index` and `id`) come back as normal results that say how to fix them, not as validation errors.\n\n| Tool | Arguments | What it does |\n| --- | --- | --- |\n| `read_deck` | `source?` (`json`, `yaml`, `markdown`), `offset?` | The open deck's `revision` (core's `documentHash`, `sha256:...`), viewer `session`, `name`, `slideCount`, `selected` `{ index, id }`, `outline[]` `{ index, id, title, layout }` (indexes from 0, as in `/slides/0`), `sourceDraft` and `checks` (counts and up to 20 findings). It is bounded whatever the deck: names, ids, titles and finding paths at most 200 characters, finding messages 300, the outline at most 30,000 characters of JSON (then `outlineTruncated: { listed, of }`). With `source`, also the deck's text, in pages that keep the result under 100,000 characters with at least 40,000 characters of text each; pages after the first leave the outline out, a page never starts or ends inside a surrogate pair, and every page carries a `textHash` of the whole text (when it changes between pages, start again at 0). The form open in the source pane comes back as the pane shows it, a draft the deck has not taken included (`draft: true`), and nothing the user is typing is applied by the read. |\n| `select_slide` | `index?` (a whole number from 0) or `id?`, exactly one | Shows that slide; the deck does not change. Refused (`busy`) while the user has text open on the slide, since changing slides would commit it. |\n| `edit_deck` | `expectedRevision`, `operations` (1 to 100 JSON Patch operations, as `opf edit` takes them; paths may name slides and blocks by id, `/slides/@intro/title`) | Applies the operations through the editor session's `applyPatch` with `expectHash`: all or none, as one undo step, with the source pane, the slide and the model's context following. Refused, changing nothing: a revision that is not the current one (`stale-revision`, read again); an edit while the user is typing, with text open on the slide or typing the source pane has not applied yet (`busy`: the user's edit is never committed for them; try again after their next message); a source draft that is not a valid deck (`source-draft`); an operation on the whole deck, `path` or `from` `\"\"` (`whole-deck`); any operation but `test` whose `path` or `from` is `/slides` itself, that is adding, replacing, removing, moving or copying the whole slides array (`whole-slides`: edit slides one at a time); more than 200,000 characters of operations (`too-large`); and an edit that would make the deck invalid (`invalid-result`, with the findings). The deck in the viewer is always valid in format and references: a JSON deck that is not does not open (the tools answer `not-open`), and YAML or Markdown text that is not stays a draft in Source (`source-draft`). In the source pane, JSON keeps its formatting (only the changed values are rewritten); YAML and Markdown text is written again from the deck, so YAML comments are dropped and the pane says so. This holds for every change made outside the source pane (the Design menu, an edit on the slide, Undo), not only for `edit_deck`. Returns the new `revision`, `previousRevision`, `changed[]` (as the operations addressed them) and the checks. |\n\nEvery tool answers with `ok: false` and a `code` (`loading`, `not-open`, `superseded`, `closed`, `busy`, `source-draft`, `stale-revision`, `whole-deck`, `whole-slides`, `too-large`, `invalid-input`, `invalid-result`, ...) and a sentence that says what to do instead, rather than an error, while the deck is loading, when no deck opened (also after the tool call was cancelled), after a newer viewer of the same session replaced the view (which also makes it read-only), and after the host tore the view down.\n\n### Instances and the viewer session\n\nEach tool call mounts its own view, and earlier views stay live. `show_deck` and `open_editor` mint `viewer: { session, createdAt, tie }` in their result; the server keeps nothing and counts nothing. Decision (vetoable, RR111-SESSION-BY-DECK): **one editing session is one deck**: the session key is the caller's `session` when it passes one (letters, digits and `- _ . :`, up to 64), and otherwise it is derived from the deck's own identity, statelessly: OPF has no document id, so it is `deck-` and 32 hex digits of the SHA-256 of the deck's `name`, trimmed, lowercased and with runs of spaces collapsed (a deck without a name gets a random key of its own). So a model that shows a newer version of the same deck replaces the older viewer without passing anything back, a deck with another name stays independent, and `open_editor` derives the key from the starter or example deck it opens. Both tools' descriptions say so. Views of one session meet on a `BroadcastChannel` named by that key and compare the server's keys only: `createdAt` (the server's clock), then `tie` (random, minted per call), then the instance id; never a key a view made up. The older view greys out, becomes read-only, clears its sharing state and any selection, says that a newer viewer is open, and stops sending context, messages and tool edits. A view whose result carries no key, a view where the browser has no `BroadcastChannel`, and every view of another session stay independent. The channel is per conversation because the viewer declares no `ui.domain` (its origin is then the conversation's); a host that gave it a fixed domain would let two conversations with a deck of the same name meet, so that would need the session key to include something the host scopes.\n\n### The direct entry point (`open_editor`)\n\nWhere Claude offers it (a remote custom connector or a directory listing, the newer conversation experience, an organization that allows it; not a local server), a user can open the OPF viewer's editor without asking the model: Claude lists it as \"OPF deck editor\" beside the connector's name and calls `open_editor` with `{}`. The starter deck can be edited at once; the start row under the bar (\"A starter deck to edit.\", an example picker capped at 280px, and **Paste a deck**, all on one row from 600px) opens a bundled example (through `get_catalog_record`) or pastes a deck. **Paste a deck** switches to Source, selects the whole text and focuses it, so what the user pastes replaces it; where the host lets the view read the clipboard, the deck on it goes in at once. The label goes once the user opens an example, pastes or edits. The model can call it too, with a `title` (with an `example`, the title renames the example deck, and the result says so) or an `example`.\n\n**Not built:** embedding the pptx.dev workspace as a website inside the app. It would need explicit `frameDomains`, framing headers on pptx.dev and a listing that allows embedded sites, and it is a separate review.\n\nTry it locally: run the server in Claude Desktop (the setup above) and ask Claude for a deck. To see the viewer outside a client, `node packages/mcp/test/deck-app-browser.mjs` (after `pnpm --filter @openpresentation/mcp build`) runs it in Chromium behind a stand-in host that frames it the way a client does; with `OPF_DECK_APP_SCREENSHOTS=<directory>` it saves a screenshot of each view. ext-apps' `basic-host` example is a reference host for a server over HTTP.\n\n## Prompts\n\n| Prompt | Arguments | Use |\n| --- | --- | --- |\n| `learn_opf` | none | Orient an agent that has not used OPF; includes the format card |\n| `author_deck` | `brief`, `audience?`, `slides?` | Write a deck from a brief, then validate and fix it; includes the format card and the `opf-author` skill |\n| `fix_validation_findings` | `document`, `format?` | Repair a deck that does not validate with the smallest change; includes the `opf-inspect` skill |\n| `choose_layout` | `content`, `intent?` | Pick a layout from the content a slide carries; includes the `opf-layout` skill |\n\n## A typical session\n\n1. The agent calls `start_here { goal: \"a board update with a revenue chart\" }` (or reads `opf://docs/format-card`, or runs the `learn_opf` prompt).\n2. It reads what the path names, finds layouts with `search_catalog { kind: \"layouts\", query: \"two columns\" }` and reads one with `get_catalog_record`.\n3. It writes the deck and calls `validate_deck` with `failOn: \"warning\"`; each finding names a rule, a JSON Pointer and a hint. It fixes the findings and repeats until `ok` is true. A field it is unsure of comes from `get_schema { name: \"Chart\" }`.\n4. It shows the deck with `show_deck`: in a client with MCP Apps the user sees the slides, can edit them, and the edits come back to the agent. Or it uses `convert` to hand the deck over as YAML or Markdown. In a host that advertises file saving, the viewer's Export menu hands PowerPoint, PDF and PNG files to the host. The local `opf convert deck.opf.json deck.pdf` (or `.pptx`) is another way to write an export.\n\nValidation checks the file. It does not render the deck, so it is not proof of how the deck looks.\n\n## Host it\n\nThe package is a library as well as a command. Its entries:\n\n| Entry | What it is |\n| --- | --- |\n| `@openpresentation/mcp` | `createOpfServer(options)`: the server with the bundled docs, examples, skills and release notes. Edge-safe. |\n| `@openpresentation/mcp/server` | `createOpfMcpServer(options)`: the same server with no bundled data; you pass `sources`. Edge-safe, and small. |\n| `@openpresentation/mcp/stdio` | `runStdio()`: the Node stdio wrapper that `opf-mcp` and `opf mcp` run. Uses Node. |\n| `opf-mcp` (bin) | The stdio server; `npx -y @openpresentation/mcp` runs it. |\n\nThe two library entries import no Node builtin and read no file; documentation, examples, skills and release notes are bundled data; validation uses the precompiled validators (`@openpresentation/opf/precompiled`), so they run where code generation from strings is refused, such as Cloudflare Workers (the tests bundle them the way Wrangler does and run them in workerd):\n\n```ts\nimport { createOpfServer } from \"@openpresentation/mcp\";\nimport { WebStandardStreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\n\nexport default {\n async fetch(request: Request): Promise<Response> {\n const server = createOpfServer({ version: \"0.27.0\" });\n const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });\n await server.connect(transport);\n return transport.handleRequest(request);\n },\n};\n```\n\n`createOpfServer({ version, opfVersion?, sources?, checkText?, deckApp?, processDecks? })` returns an SDK `McpServer`. `sources` replaces any of the bundled `docs`, `examples`, `skills` and `whatsNew`. `checkText` replaces the check behind `validate_deck`; `opf-mcp` passes the one that measures layout with the fonts `opf convert` draws with. Without it, layout is estimated and the report's `hint` says so.\n\nThe default entry bundles the viewer, example decks and public documentation. A host that must stay small imports `createOpfMcpServer` from `@openpresentation/mcp/server`, which bundles none of that data, and takes `sources: { docs, examples, skills, whatsNew? }` from wherever it keeps them (KV, R2, static assets): `docs` is `[{ slug, title, markdown }]`, `examples` is `[{ slug, category, file, deck }]`, `skills` maps a skill name to `{ \"SKILL.md\": text, ... }`. `defaultSources()` and `DOC_SLUGS` (the pages served) are exported from `@openpresentation/mcp`.\n\n**A hosted server that does no deck work.** A tool call always runs on the server the client calls, so a hosted server runs every call on your compute. Pass `processDecks: false` and it does no OPF processing of decks: `show_deck` only opens the viewer, which reads, checks and renders the deck on the user's machine and sends its findings to the model as context; `validate_deck`, `convert` and the `fix_validation_findings` prompt are left out, and `start_here` and the other prompts point to `show_deck`. What stays on the server is the lookups (docs, schemas, catalog, examples), which are small and the same for every caller, and handing over the viewer's HTML. A client without MCP Apps gets no check from such a server. `deckApp: { readFontFile }` gives the viewer font files (the local server reads the installed renderer's); `deckApp: false` leaves the viewer out. The lean `createOpfMcpServer` takes `deckApp: { html }` with `DECK_APP_HTML` from `@openpresentation/mcp`, or a function that returns the same page from storage; the function runs only when a client opens the viewer, so other requests never load the viewer page.\n\n**Fonts for a hosted viewer.** A site that already serves the OPF preview fonts (the layout the OpenPresentation site's `prepare-opf-fonts.mjs` writes: `/opf-fonts/manifest.json`, `base/`, `lazy/fonts/` and `scripts/`) passes `readFontFile: siteFontFiles({ fetch })`, exported by both library entries. `fetch` reads a file by its path on the site; in a Worker it is the static-assets binding, so the fonts cost no storage of their own and no request leaves the Worker:\n\n```ts\nimport { createOpfMcpServer, siteFontFiles } from \"@openpresentation/mcp/server\";\n\nconst server = createOpfMcpServer({\n version, sources,\n deckApp: { html: () => loadDeckAppHtml(), readFontFile: siteFontFiles({ fetch: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))) }) },\n});\n```\n\nIt reads only font files under the font folders and the faces the site's manifest names, and the renderer in the viewer checks each file against its pinned SHA-256. `OPF_SITE_FONTS_ORIGIN=https://www.openpresentation.org node --test packages/mcp/test/site-fonts.test.mjs` checks a deployed site serves every face the viewer can ask for (Node needs `NODE_USE_ENV_PROXY=1` behind a proxy).\n\n**Icons for a hosted viewer.** A Worker has no installed icon files, so its `defaultSources()` registers no icon set, and without one the server offers no `read_icons` and a deck's set icons are `opf/icon-unknown` in the viewer. Serve the gallery's six set-level icon files as static assets under `/opf-icons/` and pass them as `sources.iconSets`; nothing is bundled into the Worker:\n\n```ts\nimport { fetchIcons, galleryIconSets } from \"@openpresentation/gallery/icon-sets\";\n\nconst iconSets = galleryIconSets(fetchIcons(new URL(\"/opf-icons/\", request.url), env.ASSETS));\nconst server = createOpfMcpServer({ version, sources: { ...sources, iconSets }, deckApp: { html, readFontFile } });\n```\n\n```sh\n# The six set-level files (lucide.json, lucide.icons.json, lucide.tags.json and Tabler's three; 2.5 MB, 538 KB gzip) into the static assets.\nnode -e \"const fs = require('fs'); fs.mkdirSync('public/opf-icons', { recursive: true }); for (const f of fs.readdirSync('node_modules/@openpresentation/gallery/dist/icons')) if (f.endsWith('.json')) fs.copyFileSync('node_modules/@openpresentation/gallery/dist/icons/' + f, 'public/opf-icons/' + f)\"\n```\n\nThen `search_icons` and `validate_deck` read the same sets, and `test/mcp-workerd.test.mjs` runs such a Worker in workerd.\n\n## Limits\n\n- The viewer is about 9.1 MB of UTF-8 HTML (9,064,031 bytes in 0.34; the build prints the exact size), loaded once per conversation or cached by the client. Its `resources/read` frame is 9,390,901 bytes, about 1.1 MB under the default 10 MiB stdio limit, and `test/app-resource-frame.test.mjs` fails when that headroom drops below 1,000,000 bytes. The bundle carries only zod's English messages (`scripts/build-app.mjs`) and core's precompiled validators, whose errors are built by shared helper functions (`packages/javascript/scripts/validators-codegen.mjs`). A client may cap the size of an MCP App or ask the user before it shows one.\n- Export needs a client that saves files for the viewer (`ui/download-file`); in one that does not, there is no Export menu. A PowerPoint or PNG export draws an SVG picture through the browser's image decoder from a `data:` URL (`svgSource: \"data\"` of the renderer's `export-browser`), because the sandbox allows no `blob:` image. The model sees the deck as JSON, not as pictures of the slides.\n- The `convert` tool handles JSON, YAML and Markdown. Viewer Export runs in the client and requires its file-saving capability; the local `opf` command can also render and write files.\n- `validate_deck` reads no files, so a local image path in a deck is not looked up (the CLI warns with `cli/asset-missing`). Pass images as data URIs or assets.\n- Layout is measured with real fonts only under `opf-mcp` with `@openpresentation/opf-render` installed; `checks.layout` says `measured` or `estimated`.\n"
|
|
261
|
+
"markdown": "# OPF MCP server\n\n`@openpresentation/mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server for OPF, so an agent or editor that speaks MCP can learn the format, look things up and check a deck without shelling out and parsing text. It teaches OPF (documentation, schemas, the default catalog, example decks and the six agent skills, all as resources, with a `start_here` tool that gives a path for a goal), and it runs the checks the CLI runs (`validate_deck`, `convert`).\n\nIt also shows decks: `show_deck` opens the OPF viewer inside a client that supports MCP Apps (Claude on the web and desktop), with Preview, Source and Both, where the user can edit the deck and the edits come back to the model ([The OPF viewer](#the-opf-viewer-show_deck)).\n\nIt keeps no state, reads no file (everything it serves is bundled in the package, and tools work on the text you pass in; the one exception is the renderer's font files, which `opf-mcp` hands to the viewer), fetches nothing and has no network access. It runs two ways: locally over stdio (this page), and hosted on an edge runtime (the same server definition over Streamable HTTP). The hosted connection target is `https://www.openpresentation.org/mcp`; its deployed version, tools and viewer availability follow that site\u2019s deployment, separately from the npm package. Check the [hosted MCP guide](https://www.openpresentation.org/docs/mcp) for that deployment. The packaged `show_deck` viewer described here does not establish that a hosted deployment offers it. The local server measures layout with real fonts when `@openpresentation/opf-render` is installed.\n\n## Set it up\n\n**Hosted, nothing to install.** `https://www.openpresentation.org/mcp` is this server over Streamable HTTP: no account, no key, read-only, and it keeps nothing. In Claude (web or desktop), open the Connectors page and add a custom connector: name it `OPF` and paste the URL `https://www.openpresentation.org/mcp`. Claude moves these menus; on 2026-11-14 the page was Customize (in the left sidebar), then its Connectors tab, then Add and Add custom connector, and the older Settings, Connectors page only pointed there. If a label has moved, look for \"Connectors\" and \"custom connector\". Other clients take the same URL as a remote MCP server.\n\n**Your first request.** Claude has its own slide feature, and a plain \"make a pitch deck\" may be answered by it without calling OPF. Name OPF and the viewer in the first message, for example: *Use the OPF tools to make a ten-slide deck about our Q3 results, validate it, and show it in the OPF viewer.* Naming OPF only tells the host which tools you mean; whether and how Claude uses them is the host's decision, so if a reply comes from another feature, say so and repeat the request naming OPF. Once the viewer opens, ordinary follow-ups (\"add a slide on risks\") continue in it.\n\n**What the hosted server keeps.** A deck you pass to `validate_deck`, `convert` or `show_deck` is read in memory for that one call and not stored; the viewer itself edits, checks, draws and exports the deck on your machine. The hosted server allows 600 requests a minute per address and bodies up to 4 MB.\n\n**Local.** Any MCP client that starts a local server takes a command and arguments:\n\n```json\n{\n \"mcpServers\": {\n \"opf\": { \"command\": \"npx\", \"args\": [\"-y\", \"@openpresentation/mcp\"] }\n }\n}\n```\n\nPin a version (`@openpresentation/mcp@0.27.0`) to make the setup repeatable. Node 22 or later is required.\n\n| Client | How |\n| --- | --- |\n| Claude Code | `claude mcp add opf -- npx -y @openpresentation/mcp` (add `--scope project` to write `.mcp.json` for the team) |\n| Cursor | Add the JSON above to `.cursor/mcp.json` in the project, or to `~/.cursor/mcp.json` |\n| Claude Desktop | Install the extension (`opf-<version>.mcpb`, below), or add the JSON above to `claude_desktop_config.json` |\n| Any other client | Run `npx -y @openpresentation/mcp` as a stdio server (installed, the binary is `opf-mcp`) |\n\nCheck it with the official inspector: `npx @modelcontextprotocol/inspector npx -y @openpresentation/mcp`.\n\n### Claude Desktop extension (`.mcpb`)\n\nThe server also comes as an MCP Bundle, a one-file Claude Desktop extension: open `opf-<version>.mcpb` (double-click it, or drag it into Claude Desktop's Settings, Extensions) and Claude Desktop installs and starts it. It needs no Node install, no `npx` and no configuration, and it carries the renderer and its fonts, so the OPF viewer draws decks with the exact faces and validation measures layout with them.\n\nWhen the matching [GitHub release](https://github.com/OpenPresentation/opf/releases) lists `opf-<version>.mcpb` and its SHA-256 file, download both assets from that release. Release-bundle publication is planned from 0.34.0; 0.33.0 has no published bundle asset. The trusted publish workflow builds and checks the full bundle before attaching it after registry verification. Verify it with `sha256sum --check opf-<version>.mcpb.sha256` on Linux, or compare `Get-FileHash opf-<version>.mcpb -Algorithm SHA256` to the file on Windows.\n\nBuild it from a checkout: `pnpm --filter \"@openpresentation/mcp...\" run build`, then `pnpm --filter @openpresentation/mcp run build:mcpb`. It writes `packages/mcp/artifacts/opf-<version>.mcpb` (about 81 MB, every font the renderer draws with); `node scripts/build-mcpb.mjs --no-script-fonts` writes `opf-<version>-lite.mcpb` (about 33 MB) without the script faces (Japanese, Chinese, Korean, Arabic, Devanagari and the other scripts), whose text then draws with fallbacks. `--check` also unpacks the bundle and drives its server the way Claude Desktop starts it. The build packs this checkout's `@openpresentation/opf`, `gallery`, `opf-render` and `mcp`, and installs their third-party dependencies and the renderer's font packages from the npm registry, keeping only the font files the renderer's manifests name. The manifest is `packages/mcp/mcpb/manifest.json`; `test/mcpb-manifest.test.mjs` keeps its tool list in step with the server.\n\n`opf mcp` of the CLI is a convenience: it runs this server when `@openpresentation/mcp` is installed beside the CLI or in the working directory, and otherwise prints `npx -y @openpresentation/mcp` and exits with 2. The CLI itself carries no MCP code.\n\n## Tools\n\nEvery tool takes JSON arguments and returns structured JSON (`structuredContent`, with the same JSON as text for clients that read only text; `show_deck`, `read_font_file` and `read_icons` answer in their own text). A failure comes back with `isError: true` and a text report `{ ok: false, code, error, ... }` (no structured content), with a stable `code` (`unknown-id`, `invalid-document`, ...) and, where it helps, a suggestion (\"Did you mean two-column?\"). All tools are read-only.\n\n| Tool | Arguments | Returns |\n| --- | --- | --- |\n| `start_here` | `goal?` (what you are trying to do, in your own words) | `{ goal, summary, steps[], docs[], skills[], examples[], layouts[], themes[], validate }`: a short ordered path. Which documentation pages and skill to read, two or three example decks, layouts and themes from the catalog, and the validate step (`validate_deck` with `failOn: \"warning\"`). With no goal, the general learning path. Everything it names is a resource URI or a tool to call next. |\n| `validate_deck` | `document` (a JSON object, or deck text), `format?` (`json`, `yaml`, `markdown`; default JSON), `failOn?` (`error`, `warning`, `info`; default `error`) | `{ ok, valid, schemaValid, failOn, format, counts, findings[], checks, hint? }`. The findings are the ones `opf validate` reports (rule id, severity, category, JSON Pointer `path`, message, `help`, `fixes`, and a `location` with line and column for JSON, YAML and Markdown text). `ok` is false when a finding is at or above `failOn`. It does not look for local image files (it reads none). |\n| `get_schema` | `name?` (a schema such as `presentation` or `layout`, or a `$defs` name such as `Chart`), `pointer?` (a JSON Pointer into the schema, or a `$defs` name) | `{ name, pointer, id, schema, opfVersion }`, like `opf schema`. `$ref`s stay as written. A whole schema names the `@openpresentation/opf` release it came from in its `$comment`; a part is as it is. |\n| `search_catalog` | `kind` (`layouts`, `themes`, `color-schemes`, `font-schemes`, `narratives`, `audiences`, `purposes`, `tones`, `chart-types`, `languages`, `social-platforms`, `examples`), `query?`, `limit?` | `{ kind, total, returned, records[] }`: short records (id, name, summary, description, tags), best match first. |\n| `get_catalog_record` | `kind`, `id` | `{ kind, id, uri, record }`: the record in full, like `opf catalog <kind> <id>`. |\n| `convert` | `document`, `from?`, `to` (`json`, `yaml`, `markdown`) | `{ ok, from, to, text, findings, counts }`, like `opf convert`. The deck must be valid; otherwise nothing is converted and the findings are returned. This tool converts text formats only. The viewer separately offers PowerPoint, PDF and PNG Export in a host that can save files; the local `opf convert` also writes rendered formats. |\n| `search_docs` | `query`, `limit?` | `{ total, results[] }`: ranked pages and skills, each with `uri`, `title`, the `heading` the snippet sits under, a `snippet` and a `score`. |\n| `search_shapes` | `query?`, `category?` (`lines`, `rectangles`, `basic`, `blockArrows`, `equations`, `flowchart`, `starsBanners`, `callouts`, `actionButtons`), `limit?` | `{ query, total, returned, shapes[], categories[] }`: the 187 preset shapes of a shape block or an overlay shape, searched by DrawingML name (`rightArrow`) and common words (`speech bubble`, `cylinder`, `cog`; every word must match, a name ranks first; an empty query browses PowerPoint's gallery in order). Each shape has `shape` (the value to write), `category` and `categoryTitle`, `aspect` (the default frame, width over height), `adjust[]` (each adjust value's `name`, `default`, `min`, `max`, `unit` of `fraction` or `degrees`, and whether a `handle` moves it, at a square frame) and `svg`, a small drawing from the preset's own geometry. |\n| `list_examples` | `category?`, `query?` | `{ total, categories, examples[] }`: slug, name, category, slide count and `uri` for each bundled example deck. |\n| `show_deck` | `document` (a JSON object, or deck text), `format?`, `view?` (`preview`, `source`, `both`; default `preview`), `slide?` (from 1), `session?` | Opens the deck in the OPF viewer (`_meta.ui.resourceUri: ui://opf/deck`). `{ opened, checked, view, slide?, format, name, slides, outline[], valid, counts, findings[], viewer, iconSets }`, and as text the deck's name, slide titles, findings and the viewer session key, so a client without MCP Apps still gets an answer. With `processDecks: false` (a hosted server that does no deck work), `{ opened, checked: false, view, format?, viewer, iconSets }` only: the viewer does the checks. `iconSets` names the icon sets the viewer can read through `read_icons` (`[]` when the server has none). A later call for the same deck (the same name) replaces the open viewer of it; `session` chooses another session. `viewer` is `{ session, createdAt, tie }` ([Instances](#instances-and-the-viewer-session)). |\n| `open_editor` | `example?` (a bundled example's slug), `title?` (the deck's name: the starter deck's title, or a new name for the example), `session?`; all optional | Opens the OPF viewer's editor with a deck to edit: with `{}` a two-slide starter deck (\"Untitled deck\"), or the example named. `{ opened, editor: true, example, name, slides, document, examples[], viewer, iconSets }`; an unknown slug still opens the starter deck and the text names the nearest slug. Title \"OPF deck editor\". Its `_meta` carries `ui.resourceUri` and `\"openai/ui\": { \"entrypoints\": [{ \"type\": \"global\" }] }`, the marker Claude reads to offer the app as a direct entry point ([Entry point](#the-direct-entry-point-open_editor)). |\n| `read_font_file` | `file` (a path from the renderer's font manifest), `offset?` | For the viewer only (`_meta.ui.visibility: [\"app\"]`; a host hides it from the model). `{ file, offset, total, bytes }`: at most 512 KiB of the file, base64. Offered by `opf-mcp` when `@openpresentation/opf-render` is installed beside it. |\n| `read_icons` | `set` (`lucide`, `tabler`), `names` (at most 100 icon names), `index?` | For the viewer only (`_meta.ui.visibility: [\"app\"]`). `{ set, icons, errors?, index? }`: the path data of the icons the set has (a name it lacks is left out: the index names every icon), why a name could not be read, and with `index` the set's index (`names`, `viewBox`, `style`, stroke settings, `name`, `version`, `license`, `copyright`, `licenseText`). The viewer asks for the index once per set. Offered when the server has icon sets (`sources.iconSets`; `opf-mcp` and the `.mcpb` read the installed files) and the viewer. |\n\n## Resources\n\nResources have stable URIs. The server lists them (`resources/list`) and also offers URI templates (`resources/templates/list`) so a client can read a URI it builds itself.\n\n| URI | What it is |\n| --- | --- |\n| `opf://docs/index` | Every documentation page and skill, with its URI |\n| `opf://docs/whats-new` | The most recent release notes: the newest release, and older ones while there are at most five and the page is under 120,000 characters, from the changelog of `@openpresentation/opf` (the format, the validators and the engine), newest first, as text |\n| `opf://docs/<slug>` | A documentation page as Markdown: `format-card` (the whole authoring surface on one page, sized for pasting into a model's context), `how-opf-works`, `schema-reference`, `validate`, `cli`, and the other pages meant for people who use OPF. Handoff, evidence, status and release notes are not served. |\n| `opf://schema/<name>` | A JSON Schema (`opf://schema/presentation`) |\n| `opf://schema/<name>#<pointer or $defs name>` | Part of a schema: `opf://schema/presentation#Chart`, `opf://schema/presentation#/properties/slides`. `opf://schema/Chart` also works. |\n| `opf://examples/<slug>` | A valid example deck as JSON |\n| `opf://catalog/<kind>/<id>` | A record of the default catalog (`@openpresentation/gallery`): `opf://catalog/layouts/two-column` |\n| `opf://skills/<name>` | A skill entrypoint (`opf-author`, `opf-layout`, `opf-presets`, `opf-edit`, `opf-export`, `opf-inspect`) |\n| `opf://skills/<name>/<path>` | A reference or asset of a skill: `opf://skills/opf-author/references/content.md` |\n| `ui://opf/deck` | The OPF viewer (`text/html;profile=mcp-app`): one HTML page (about 9.1 MB of UTF-8; `pnpm --filter @openpresentation/mcp build` prints the exact size and the JSON-RPC frame's headroom under the 10 MiB stdio limit) that `show_deck` and `open_editor` open. The `resources/read` content item carries `_meta.ui` `{ prefersBorder: false, preferredDisplayMode: \"fullscreen\" }`; the viewer declares no `csp`, `domain` or `permissions` (any of them would go on the same content item). |\n\nSkill scripts and agent manifests are not served; the server runs no code from them.\n\n## The OPF viewer (`show_deck`)\n\n`show_deck` is an [MCP App](https://github.com/modelcontextprotocol/ext-apps) (SEP-1865): in a client that supports MCP Apps, such as Claude on the web and desktop, the deck opens in the conversation with the openpresentation.org playground's three views.\n\n- **Preview** shows the slides, with the thumbnail strip under them. **Source** shows the deck's text (JSON, YAML or OPF Markdown) in the editor's source pane, checked as you type. **Both** puts them side by side; in a container narrower than 860px it stacks the slide over the source, and choosing it there asks the client for a larger view. The slide itself can be edited in place too. The model is told to open on Preview unless the user asked for the source.\n- **The bar** (48px, one row down to a 640px container, two rows and no Both below it, and every control still in two rows at 320px): Undo and Redo, the deck's name (a little room from 640px, a row of its own below 640px; renaming opens the editor's Save and Cancel over the whole bar, or over the name's own row where the bar wraps, and Enter or Save commits one undoable edit, Escape or Cancel puts the name back, and leaving the field closes an untouched rename and keeps a typed draft), the view switch, the editor's Design menu (theme, colors, fonts and the slide's layout, each one undoable edit), Find and replace (Ctrl/Cmd F), Export, Expand, and **Send to Claude**. Undo stops at the deck as it was opened. Present is left out (a sandboxed iframe cannot go full screen on its own), and the source pane's Copy works without the clipboard permission.\n- **Export** is the editor's own menu: PowerPoint (`@openpresentation/opf-pptx`, editable), PDF (vector, selectable text), SVG and PNG slides, and the OPF source as JSON, YAML or Markdown. Every file is made in the viewer, on the user's machine, with the fonts the slides draw with, and handed to the client to save (`ui/download-file`), since a sandboxed iframe cannot download. The menu, and the source pane's Download, show only in a client that declares that capability; the agent handoff is left out, the deck being in a conversation already.\n- **Your edits go back to the model.** A second after the last edit, the viewer sends the whole deck to the model as context (`ui/update-model-context`), so its next answer continues from your version; the footer says so (`Edits not shared yet`, then `Claude has your edits`). **Send to Claude** also asks for a turn (`ui/message`): it is the view's one primary button, filled while there are edits you have not sent, and it stays usable to send again. In a client that is not Claude the wording is \"the assistant\". Where the client offers the viewer's tools, the model changes the open deck in place ([The viewer's tools](#the-viewers-tools-editing-together)); otherwise it calls `show_deck` again and a new viewer opens, and with the session key the earlier one steps aside.\n- **The checks run in the viewer.** It runs core's validators on every change, with text measured by the fonts the slides draw with, and sends the findings to the model with the deck. The status footer (28px) shows the verdict at the left, the editor's review pill (`Valid OPF`, `2 issues`), which opens the Review panel in a drawer. While the text in Source is not a valid deck, the slides keep the last valid version, but the verdict is the text's: the pill counts its errors (`1 issue`, never `Valid OPF`), the Review panel lists them first and says the findings under them describe the last valid version, and the model's context and `read_deck` carry them as `sourceChecks`; all of it clears once the text is valid again. Then come the slide navigator (previous, `01 / 16`, next), the editor's status line, and the version at the right.\n- **One palette, the client's.** The viewer is built to the openpresentation.org design system (the playground's bar and footer) and reads only the editor's `--opf-ui-*` tokens. In a client that sends the standard MCP Apps style variables, the neutral tokens (surfaces, text, borders) are derived from the client's background and text colors and its fonts, for the viewer's own chrome and the editor's parts alike, in the client's light or dark theme; the accent and the status colors stay OPF's, and the slides keep the deck's theme. Without those variables it uses the design system's own values.\n- **It is as tall as the deck needs.** Inline, the stage takes the shape of the deck's slides (up to 480px) with 16px around the slide on every side, so a 16:9 deck in a 660px column is about 545px tall; until the deck is drawn, a slide-shaped placeholder holds its place and says what the viewer is waiting for; Source and Both have a fixed height. Full screen, and a client that fixes the height, fill the frame.\n\n- **Saving is controlled by the host.** Source downloads preserve the current JSON, YAML or Markdown text, MIME type and suggested filename; the host controls confirmation and saving. Each outcome is worded as the host reports it ([capabilities](#what-the-viewer-does-with-each-host-capability)); \"Download started.\" is not proof that a file was saved. Without download support the file controls stay hidden; the viewer never substitutes a direct iframe Blob/anchor download. Source text can still be selected and copied manually.\n\n**Everything runs on the user's machine.** The page bundles `@openpresentation/opf-editor`, `@openpresentation/opf-render` and core's precompiled validators, so the editing, rendering and checking happen in the client, not on the server. The client runs it in a sandboxed iframe with no network, no `eval` and no WebAssembly (the restrictive default CSP of SEP-1865, since the viewer declares no domains), so the page loads nothing: its script, styles and the startup font (Roboto Regular) are inline. Any other face a deck draws comes from the server through the client: the viewer calls the app-only tool `read_font_file`, which serves the installed renderer's files in pieces of 512 KiB, and the renderer checks each file against its pinned SHA-256 before it registers it as bytes (`FontFace` from an `ArrayBuffer`, which needs no `font-src`). Without the renderer beside the server, or on a server that offers no `read_font_file`, the viewer draws those faces with Roboto and names the substitution. Images in a deck draw when they are data URIs; the sandbox blocks a remote image.\n\n**Set icons** (`\"icon\": \"lucide:rocket\"`) come from the server the same way: the viewer registers the gallery's sets as loaders that call the app-only tool `read_icons` for the icons a deck names (at most 100 a call, so a deck with more makes more calls) and for each set's index once (every name, so a check suggests the nearest names, and the license). The page carries no icon data. The viewer learns which sets the server reads from `iconSets` in the `show_deck` or `open_editor` result; a set the server does not offer, a server without `read_icons`, or a call that fails settles the load: the slide draws without the icon, and `opf/icon-unknown` says it could not be loaded and why. The viewer's checks, and the checks in `read_deck` and `edit_deck` results, wait for the deck's icons, so a known icon is never reported and an unknown name gets the same finding and suggestions as `validate_deck`. The viewer has no icon picker (that is the editor's Content panel), so it never reads the sets' search keywords.\n\n**In a client without MCP Apps** (Claude Code, the API), `show_deck` returns the deck's name, slide titles and findings as text, like a short `validate_deck`, and `open_editor` returns its deck and the example slugs.\n\n### What the viewer does with each host capability\n\nEvery capability below is the host's to offer, and Claude can limit each one by connector type (several need a remote connector: a custom connector added by URL or a directory listing, not a local server), by organization and by client. Nothing here is available to every user, and none of it was verified in Claude from this repository; the stand-in host in `test/deck-app-tools-browser.mjs` and `test/deck-app-browser.mjs` behaves as Claude's MCP Apps documentation describes. The viewer keeps working without each one.\n\n| Capability | Where the host offers it | Where it does not |\n| --- | --- | --- |\n| **The viewer's own tools** (`read_deck`, `select_slide`, `edit_deck`) | The model reads the open deck and changes it in place, one undoable edit per call, and the user sees it at once. Claude gets a view's tools from the user's next message after the view opened, and only for a remote connector. | The tools are never called; the model sees the user's edits as context and opens a new viewer with `show_deck` to change the deck. |\n| **Model context** (`ui/update-model-context`) | A second after the last edit the whole deck goes to the model, with its revision and the viewer session key. A viewer that `open_editor` opened sends the deck it opened (the starter deck or the example, named) in its first context too. | The footer says nothing about sharing; Send still asks for a turn where messages work. |\n| **Messages** (`ui/message`) | **Send to Claude** asks for a turn on the user's click. In Claude: `Sent to Claude for your approval` when Claude took it (not proof that the user approved or the model read it); in another host: `Sent to the assistant`. `Claude didn't take the message` when it was refused, `The message couldn't be confirmed` when the request failed or timed out. Send stays usable to try again. The message is one short sentence; the deck goes as context, never in the message. | No Send button. |\n| **Downloads** (`ui/download-file`) | Export and the source pane's Download hand the file to the host: `Download started.`, `The download didn't finish.`, or `The download couldn't be confirmed.` (a rejection or the ten-minute timeout; the host's dialog may still save it). A host that answers \"method not found\" gets `This host does not offer downloads here. Select the source text to copy it.`, and Download and Export are no longer offered. One request at a time: a click while one waits sends nothing and says so. The file name is the URI's last segment as written (never percent-encoded); the viewer turns / \\\\ % : \" * < > \\| ~ # ? into `_` itself, so the name the user sees is the one it chose. The viewer makes only PowerPoint, PDF, PNG, SVG, ZIP and OPF source files, none of a type a host refuses outright. | No Export menu or Download button; the source text can be selected and copied. |\n| **A larger view** (`ui/request-display-mode`, `availableDisplayModes: [\"inline\", \"fullscreen\"]`) | **Expand** asks from the click itself (Claude honors it only right after a press in the view and opens its side panel or full screen; both report `fullscreen`); the label becomes **Back to the conversation**. A refusal leaves the label as it was and says the host kept the viewer where it was. The content item's `preferredDisplayMode: \"fullscreen\"` asks Claude to open the side panel when the tool returns; Claude decides. | No Expand button; the viewer stays inline. |\n| **Server tools from the view** (`tools/call`) | Fonts (`read_font_file`), set icons (`read_icons`) and the editor's example picker (`get_catalog_record`). | The deck draws with Roboto in place of faces it cannot get and without its set icons (each with an `opf/icon-unknown` finding that says it could not be loaded), and the editor offers only its starter deck and Paste. |\n\n**Layout** follows the container the host reports (`containerDimensions`: its width, and a fixed or a maximum height): the side panel and full screen are both `fullscreen` and the side panel can be resized down to about 320px. A fixed height fills the frame, and so does `fullscreen` when the host sends no dimensions with it (borderless); a maximum height keeps the inline view as tall as its slide. The host's `safeAreaInsets` pad the view, and `hostcontextchanged` lays it out again. In the narrowest container (under 400px) every control in the bar, the start row and the footer is at least 44 by 44 CSS pixels, Send has a row of its own, and the footer wraps a long message instead of cutting it short. A status message clears itself after eight seconds.\n\n### The viewer's tools (editing together)\n\nThe viewer registers three tools before it connects, and their names, titles, descriptions and schemas never change while it runs (Claude may ask the user to approve a tool again when one does); changing values go in results. Each answers in text, which is what the model reads, and acts on its own view only: with two viewers open, a call reaches one. Inputs a model is likely to get wrong (an unknown `op`, too many operations, a negative or fractional `offset` or `index`, both or neither of `index` and `id`) come back as normal results that say how to fix them, not as validation errors.\n\n| Tool | Arguments | What it does |\n| --- | --- | --- |\n| `read_deck` | `source?` (`json`, `yaml`, `markdown`), `offset?` | The open deck's `revision` (core's `documentHash`, `sha256:...`), viewer `session`, `name`, `slideCount`, `selected` `{ index, id }`, `outline[]` `{ index, id, title, layout }` (indexes from 0, as in `/slides/0`), `sourceDraft` and `checks` (counts and up to 20 findings). While the source pane's text is not a valid deck, `checks` describe the deck at `revision` (the last valid version, which the slides show) and `sourceChecks` (the same shape) the text's own findings; a syntax error is one error with rule id `syntax`. It is bounded whatever the deck: names, ids, titles and finding paths at most 200 characters, finding messages 300, the outline at most 30,000 characters of JSON (then `outlineTruncated: { listed, of }`). With `source`, also the deck's text, in pages that keep the result under 100,000 characters with at least 40,000 characters of text each; pages after the first leave the outline out, a page never starts or ends inside a surrogate pair, and every page carries a `textHash` of the whole text (when it changes between pages, start again at 0). The form open in the source pane comes back as the pane shows it, a draft the deck has not taken included (`draft: true`), and nothing the user is typing is applied by the read. |\n| `select_slide` | `index?` (a whole number from 0) or `id?`, exactly one | Shows that slide; the deck does not change. Refused (`busy`) while the user has text open on the slide, since changing slides would commit it. |\n| `edit_deck` | `expectedRevision`, `operations` (1 to 100 JSON Patch operations, as `opf edit` takes them; paths may name slides and blocks by id, `/slides/@intro/title`) | Applies the operations through the editor session's `applyPatch` with `expectHash`: all or none, as one undo step, with the source pane, the slide and the model's context following. Refused, changing nothing: a revision that is not the current one (`stale-revision`, read again); an edit while the user is typing, with text open on the slide or typing the source pane has not applied yet (`busy`: the user's edit is never committed for them; try again after their next message); a source draft that is not a valid deck (`source-draft`); an operation on the whole deck, `path` or `from` `\"\"` (`whole-deck`); any operation but `test` whose `path` or `from` is `/slides` itself, that is adding, replacing, removing, moving or copying the whole slides array (`whole-slides`: edit slides one at a time); more than 200,000 characters of operations (`too-large`); and an edit that would make the deck invalid (`invalid-result`, with the findings). The deck in the viewer is always valid in format and references: a JSON deck that is not does not open (the tools answer `not-open`), and YAML or Markdown text that is not stays a draft in Source (`source-draft`). In the source pane, JSON keeps its formatting (only the changed values are rewritten); YAML and Markdown text is written again from the deck, so YAML comments are dropped and the pane says so. This holds for every change made outside the source pane (the Design menu, an edit on the slide, Undo), not only for `edit_deck`. Returns the new `revision`, `previousRevision`, `changed[]` (as the operations addressed them) and the checks. |\n\nEvery tool answers with `ok: false` and a `code` (`loading`, `not-open`, `superseded`, `closed`, `busy`, `source-draft`, `stale-revision`, `whole-deck`, `whole-slides`, `too-large`, `invalid-input`, `invalid-result`, ...) and a sentence that says what to do instead, rather than an error, while the deck is loading, when no deck opened (also after the tool call was cancelled), after a newer viewer of the same session replaced the view (which also makes it read-only), and after the host tore the view down.\n\n### Instances and the viewer session\n\nEach tool call mounts its own view, and earlier views stay live. `show_deck` and `open_editor` mint `viewer: { session, createdAt, tie }` in their result; the server keeps nothing and counts nothing. Decision (vetoable, RR111-SESSION-BY-DECK): **one editing session is one deck**: the session key is the caller's `session` when it passes one (letters, digits and `- _ . :`, up to 64), and otherwise it is derived from the deck's own identity, statelessly: OPF has no document id, so it is `deck-` and 32 hex digits of the SHA-256 of the deck's `name`, trimmed, lowercased and with runs of spaces collapsed (a deck without a name gets a random key of its own). So a model that shows a newer version of the same deck replaces the older viewer without passing anything back, a deck with another name stays independent, and `open_editor` derives the key from the starter or example deck it opens. Both tools' descriptions say so. Views of one session meet on a `BroadcastChannel` named by that key and compare the server's keys only: `createdAt` (the server's clock), then `tie` (random, minted per call), then the instance id; never a key a view made up. The older view greys out, becomes read-only, clears its sharing state and any selection, says that a newer viewer is open, and stops sending context, messages and tool edits. A view whose result carries no key, a view where the browser has no `BroadcastChannel`, and every view of another session stay independent. The channel is per conversation because the viewer declares no `ui.domain` (its origin is then the conversation's); a host that gave it a fixed domain would let two conversations with a deck of the same name meet, so that would need the session key to include something the host scopes.\n\n### The direct entry point (`open_editor`)\n\nWhere Claude offers it (a remote custom connector or a directory listing, the newer conversation experience, an organization that allows it; not a local server), a user can open the OPF viewer's editor without asking the model: Claude lists it as \"OPF deck editor\" beside the connector's name and calls `open_editor` with `{}`. The starter deck can be edited at once; the start row under the bar (\"A starter deck to edit.\", an example picker capped at 280px, and **Paste a deck**, all on one row from 600px) opens a bundled example (through `get_catalog_record`) or pastes a deck. **Paste a deck** switches to Source, selects the whole text and focuses it, so what the user pastes replaces it; where the host lets the view read the clipboard, the deck on it goes in at once. The label goes once the user opens an example, pastes or edits. The model can call it too, with a `title` (with an `example`, the title renames the example deck, and the result says so) or an `example`.\n\n**Not built:** embedding the pptx.dev workspace as a website inside the app. It would need explicit `frameDomains`, framing headers on pptx.dev and a listing that allows embedded sites, and it is a separate review.\n\nTry it locally: run the server in Claude Desktop (the setup above) and ask Claude for a deck. To see the viewer outside a client, `node packages/mcp/test/deck-app-browser.mjs` (after `pnpm --filter @openpresentation/mcp build`) runs it in Chromium behind a stand-in host that frames it the way a client does; with `OPF_DECK_APP_SCREENSHOTS=<directory>` it saves a screenshot of each view. ext-apps' `basic-host` example is a reference host for a server over HTTP.\n\n## Prompts\n\n| Prompt | Arguments | Use |\n| --- | --- | --- |\n| `learn_opf` | none | Orient an agent that has not used OPF; includes the format card |\n| `author_deck` | `brief`, `audience?`, `slides?` | Write a deck from a brief, then validate and fix it; includes the format card and the `opf-author` skill |\n| `fix_validation_findings` | `document`, `format?` | Repair a deck that does not validate with the smallest change; includes the `opf-inspect` skill |\n| `choose_layout` | `content`, `intent?` | Pick a layout from the content a slide carries; includes the `opf-layout` skill |\n\n## A typical session\n\n1. The agent calls `start_here { goal: \"a board update with a revenue chart\" }` (or reads `opf://docs/format-card`, or runs the `learn_opf` prompt).\n2. It reads what the path names, finds layouts with `search_catalog { kind: \"layouts\", query: \"two columns\" }` and reads one with `get_catalog_record`.\n3. It writes the deck and calls `validate_deck` with `failOn: \"warning\"`; each finding names a rule, a JSON Pointer and a hint. It fixes the findings and repeats until `ok` is true. A field it is unsure of comes from `get_schema { name: \"Chart\" }`.\n4. It shows the deck with `show_deck`: in a client with MCP Apps the user sees the slides, can edit them, and the edits come back to the agent. Or it uses `convert` to hand the deck over as YAML or Markdown. In a host that advertises file saving, the viewer's Export menu hands PowerPoint, PDF and PNG files to the host. The local `opf convert deck.opf.json deck.pdf` (or `.pptx`) is another way to write an export.\n\nValidation checks the file. It does not render the deck, so it is not proof of how the deck looks.\n\n## Host it\n\nThe package is a library as well as a command. Its entries:\n\n| Entry | What it is |\n| --- | --- |\n| `@openpresentation/mcp` | `createOpfServer(options)`: the server with the bundled docs, examples, skills and release notes. Edge-safe. |\n| `@openpresentation/mcp/server` | `createOpfMcpServer(options)`: the same server with no bundled data; you pass `sources`. Edge-safe, and small. |\n| `@openpresentation/mcp/stdio` | `runStdio()`: the Node stdio wrapper that `opf-mcp` and `opf mcp` run. Uses Node. |\n| `opf-mcp` (bin) | The stdio server; `npx -y @openpresentation/mcp` runs it. |\n\nThe two library entries import no Node builtin and read no file; documentation, examples, skills and release notes are bundled data; validation uses the precompiled validators (`@openpresentation/opf/precompiled`), so they run where code generation from strings is refused, such as Cloudflare Workers (the tests bundle them the way Wrangler does and run them in workerd):\n\n```ts\nimport { createOpfServer } from \"@openpresentation/mcp\";\nimport { WebStandardStreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js\";\n\nexport default {\n async fetch(request: Request): Promise<Response> {\n const server = createOpfServer({ version: \"0.27.0\" });\n const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });\n await server.connect(transport);\n return transport.handleRequest(request);\n },\n};\n```\n\n`createOpfServer({ version, opfVersion?, sources?, checkText?, deckApp?, processDecks? })` returns an SDK `McpServer`. `sources` replaces any of the bundled `docs`, `examples`, `skills` and `whatsNew`. `checkText` replaces the check behind `validate_deck`; `opf-mcp` passes the one that measures layout with the fonts `opf convert` draws with. Without it, layout is estimated and the report's `hint` says so.\n\nThe default entry bundles the viewer, example decks and public documentation. A host that must stay small imports `createOpfMcpServer` from `@openpresentation/mcp/server`, which bundles none of that data, and takes `sources: { docs, examples, skills, whatsNew? }` from wherever it keeps them (KV, R2, static assets): `docs` is `[{ slug, title, markdown }]`, `examples` is `[{ slug, category, file, deck }]`, `skills` maps a skill name to `{ \"SKILL.md\": text, ... }`. `defaultSources()` and `DOC_SLUGS` (the pages served) are exported from `@openpresentation/mcp`.\n\n**A hosted server that does no deck work.** A tool call always runs on the server the client calls, so a hosted server runs every call on your compute. Pass `processDecks: false` and it does no OPF processing of decks: `show_deck` only opens the viewer, which reads, checks and renders the deck on the user's machine and sends its findings to the model as context; `validate_deck`, `convert` and the `fix_validation_findings` prompt are left out, and `start_here` and the other prompts point to `show_deck`. What stays on the server is the lookups (docs, schemas, catalog, examples), which are small and the same for every caller, and handing over the viewer's HTML. A client without MCP Apps gets no check from such a server. `deckApp: { readFontFile }` gives the viewer font files (the local server reads the installed renderer's); `deckApp: false` leaves the viewer out. The lean `createOpfMcpServer` takes `deckApp: { html }` with `DECK_APP_HTML` from `@openpresentation/mcp`, or a function that returns the same page from storage; the function runs only when a client opens the viewer, so other requests never load the viewer page.\n\n**Fonts for a hosted viewer.** A site that already serves the OPF preview fonts (the layout the OpenPresentation site's `prepare-opf-fonts.mjs` writes: `/opf-fonts/manifest.json`, `base/`, `lazy/fonts/` and `scripts/`) passes `readFontFile: siteFontFiles({ fetch })`, exported by both library entries. `fetch` reads a file by its path on the site; in a Worker it is the static-assets binding, so the fonts cost no storage of their own and no request leaves the Worker:\n\n```ts\nimport { createOpfMcpServer, siteFontFiles } from \"@openpresentation/mcp/server\";\n\nconst server = createOpfMcpServer({\n version, sources,\n deckApp: { html: () => loadDeckAppHtml(), readFontFile: siteFontFiles({ fetch: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))) }) },\n});\n```\n\nIt reads only font files under the font folders and the faces the site's manifest names, and the renderer in the viewer checks each file against its pinned SHA-256. `OPF_SITE_FONTS_ORIGIN=https://www.openpresentation.org node --test packages/mcp/test/site-fonts.test.mjs` checks a deployed site serves every face the viewer can ask for (Node needs `NODE_USE_ENV_PROXY=1` behind a proxy).\n\n**Icons for a hosted viewer.** A Worker has no installed icon files, so its `defaultSources()` registers no icon set, and without one the server offers no `read_icons` and a deck's set icons are `opf/icon-unknown` in the viewer. Serve the gallery's six set-level icon files as static assets under `/opf-icons/` and pass them as `sources.iconSets`; nothing is bundled into the Worker:\n\n```ts\nimport { fetchIcons, galleryIconSets } from \"@openpresentation/gallery/icon-sets\";\n\nconst iconSets = galleryIconSets(fetchIcons(new URL(\"/opf-icons/\", request.url), env.ASSETS));\nconst server = createOpfMcpServer({ version, sources: { ...sources, iconSets }, deckApp: { html, readFontFile } });\n```\n\n```sh\n# The six set-level files (lucide.json, lucide.icons.json, lucide.tags.json and Tabler's three; 2.5 MB, 538 KB gzip) into the static assets.\nnode -e \"const fs = require('fs'); fs.mkdirSync('public/opf-icons', { recursive: true }); for (const f of fs.readdirSync('node_modules/@openpresentation/gallery/dist/icons')) if (f.endsWith('.json')) fs.copyFileSync('node_modules/@openpresentation/gallery/dist/icons/' + f, 'public/opf-icons/' + f)\"\n```\n\nThen `search_icons` and `validate_deck` read the same sets, and `test/mcp-workerd.test.mjs` runs such a Worker in workerd.\n\n## Limits\n\n- The viewer is about 9.1 MB of UTF-8 HTML (9,064,031 bytes in 0.34; the build prints the exact size), loaded once per conversation or cached by the client. Its `resources/read` frame is 9,390,901 bytes, about 1.1 MB under the default 10 MiB stdio limit, and `test/app-resource-frame.test.mjs` fails when that headroom drops below 1,000,000 bytes. The bundle carries only zod's English messages (`scripts/build-app.mjs`) and core's precompiled validators, whose errors are built by shared helper functions (`packages/javascript/scripts/validators-codegen.mjs`). A client may cap the size of an MCP App or ask the user before it shows one.\n- Export needs a client that saves files for the viewer (`ui/download-file`); in one that does not, there is no Export menu. A PowerPoint or PNG export draws an SVG picture through the browser's image decoder from a `data:` URL (`svgSource: \"data\"` of the renderer's `export-browser`), because the sandbox allows no `blob:` image. The model sees the deck as JSON, not as pictures of the slides.\n- The `convert` tool handles JSON, YAML and Markdown. Viewer Export runs in the client and requires its file-saving capability; the local `opf` command can also render and write files.\n- `validate_deck` reads no files, so a local image path in a deck is not looked up (the CLI warns with `cli/asset-missing`). Pass images as data URIs or assets.\n- Layout is measured with real fonts only under `opf-mcp` with `@openpresentation/opf-render` installed; `checks.layout` says `measured` or `estimated`.\n"
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
264
|
"slug": "native-content-release-2026-09-09",
|