Skip to content

Latest commit

 

History

History

render

README.md

OPF Render

OPF 0.18 (RR-73, RR-74; requires core 0.18). One shape for every engine: toX(deck, slides?, options?). The second argument is a slide number (one result), a selection ("1-3", "1,3-5", "2-", [1, 3]; a list of results) or the options, told apart by type, and slides count from 1. Renamed and removed outright (no aliases); an old option fails with invalid-render-options or invalid-conversion-option and names its replacement:

0.17 0.18
renderSvg(deck, options) toSvg(deck, options)
renderSlideSvg(deck, index, options) (from 0) toSvg(deck, index + 1, options) (from 1; slide-out-of-range)
svgToPng(svg, options), svgToPdf(svgs, options) toPng and toPdf: they take a deck (and draw it with toSvg) or SVG
renderDeckHtml(deck, { slides }) toHtml(deck, slides?, options?) ("1-" for every slide)
embedFonts: false, textAsPaths: true text: "system", text: "paths" (default "fonts")
mode: "raster" raster: true (vector is the default)
fontDirs fonts: the handle, or font folders (a path or a list) for SVG input

OPF 0.15 (FA-23; requires core 0.15). Catalogs are registered by the host, and every picture is an image background or an image block. The breaking changes are recorded in CHANGELOG.md; the 0.15 design explains them.

  • The renderer bundles, looks up and fetches no catalog. Every entry point (toSvg, resolvePresentation, the font loaders' renderOptions, /player, <opf-deck>) takes core's catalogs: Catalog[] and passes it unchanged to core resolution. Register the gallery snapshot yourself: import { gallery } from '@openpresentation/gallery' and toSvg(deck, { catalogs: [gallery] }). strictReferences: true fails with unresolved-reference instead of falling back.
  • What resolves nowhere draws with core's engine defaults (engineDefaults is { theme, colorScheme, fontScheme, chartType }: core's ENGINE_DEFAULT_THEME, ENGINE_DEFAULT_COLOR_SCHEME, ENGINE_DEFAULT_FONT_SCHEME) and is reported once per reference as unresolved-reference.
  • An image background (design.background: { type: "image", src, alt, fit, focus, opacity, recolor, overlay }, or an image source string) draws from core's geometry.backgroundImage: the canvas color, the picture (cover, contain, stretch or tile; recolor and opacity on the pixels only), then the overlay (the whole slide or an edge band). alt is the picture's accessible name; without it the picture is decorative.
  • Every content picture is an image block drawn from item.image: frame, fit (cover, contain, stretch; default design.imageFit, else cover), focus, shape mask, border, opacity, recolor and overlay, and a placed block (placement) at its edge band.

Lighter install (RR-63, 0.16.0). pdf-lib, @resvg/resvg-js, sharp and every @expo-google-fonts/* font package are optional peer dependencies, loaded on first use: an SVG-only install holds none of them. Add what you export (see Install); a missing converter rejects with converter-missing. New /png and /pdf entries beside /svg. Rendered output is unchanged.

0.14.0 (RR-55, with core 0.14.0, opf-pptx 0.14.0 and opf-editor 0.14.0). One fonts handle, whole-deck and one-slide render functions, and core's slide context. This release renames and deletes outright (no aliases; the CHANGELOG has the old-to-new table):

  • renderSvg(deck, options) returns string[], one SVG per slide; renderSlideSvg(deck, index, options) returns the SVG of one slide.
  • loadFonts(options) from /fonts-node or /fonts-browser (the environment is the subpath) returns the one fonts handle: { textMeasurement, embeddedFonts, fontFiles, useBundledFonts, loadSystemFonts, registry, manifest, substitutions, ensure, pending } (a browser handle also has dispose). createFontRegistry is an internal building block, not an export.
  • Every deck-level function takes { fonts } (the handle, or any object with a textMeasurement) instead of separate textMeasurement, embeddedFonts, fontFiles, useBundledFonts and loadSystemFonts options: renderSvg, renderSlideSvg, svgToPng, svgToPdf, /export-browser, /player, <opf-deck> and renderDeckHtml.
  • OPFRenderError invalid-opf carries findings: the error findings of core validate(deck, { only: ['format'] }).
  • The layout engine is read from @openpresentation/opf/composition; /fonts re-exports core's FONT_POLICY (the table: .families, .provisionalDecisions), fontPolicyFor, isSymbolEncodedFamily, symbolCodeOf, mapSymbolText and scriptFontRole rather than keeping copies.
import { loadFonts } from '@openpresentation/opf-render/fonts-node';
import { toSvg, toPng, toPdf } from '@openpresentation/opf-render';
import { paginate } from '@openpresentation/opf/pagination';
import { toPptx } from '@openpresentation/opf-pptx';

const fonts = await loadFonts({ pack: 'office', substitutionPolicy: 'visual' });
const { presentation } = paginate(opf, { fonts });
const slides = toSvg(presentation, { fonts });          // every slide
const first = toSvg(presentation, 1, { fonts });   // one slide
const png = await toPng(slides[0], { fonts });
const pdf = await toPdf(slides, { fonts });
const pptx = await toPptx(presentation, { fonts });

A slide's canvas, layout, theme, color scheme and font scheme come from core's resolveSlideContext (slide design, then deck design, then theme, then the engine default), from the records the document embeds and the catalogs the host registers (catalogs), so preview, pagination, validation and export resolve them one way. A slide with no layout composes automatically. A reference that resolves nowhere never throws: the slide composes automatically or draws with core's engine defaults, and the render reports unresolved-reference (naming the reference and the catalog's source) through onDiagnostic; with strictReferences: true it throws OPFRenderError unresolved-reference instead.

An option a function does not know is not read: a top-level textMeasurement or embeddedFonts is ignored, so pass { fonts }.

Aptos previews with Intos. The Office pack includes Intos, Intos Display, Intos Narrow and Intos Serif (16 faces, about 12 MB, vendored under fonts/intos/, SIL OFL 1.1, pinned to upstream commit fef9315c14da9e4b23b4c3cac8e718998d4e4736 and per-file SHA-256, unmodified from the upstream files). They are the metric-compatible previews for Aptos, Aptos Display, Aptos Narrow and Aptos Serif, the default aptos font scheme: 0.000% mean and maximum width difference against Aptos 2.01 in all four styles, with equal vertical metrics. The letter shapes are Intos's own, not Aptos's. The exported PPTX still names Aptos; no Aptos file is bundled or embedded. A registry built without these faces (the base pack) has no Aptos substitute: visual policy falls back to Roboto or Carlito. Like the open families, Intos is embed: "used": it is not in registry.embeddedFonts (the 33 eager npm faces), the loadFonts() handle's embeddedFonts supplies it, and an SVG embeds only the Intos faces its text draws. registry.lazyFonts lists the 51 vendored faces (35 open, 16 Intos) with package-relative file and sha256, and loadFonts({ faces, lazyFontsBaseUrl }) from /fonts-browser loads them on demand: await fonts.ensure(presentation) (the registry's ensureLazyFonts and ensureScripts are the lower-level calls) fetches and verifies only the faces the document draws, by family, weight and style (a plain Aptos deck: Intos Display Bold and Intos Regular, 2 files, 1.5 MB; an italic run adds Intos Italic, a bold run Intos Bold; the code face only when a slide has code), then adds them to the document and the registry together so measurement and painting never disagree. Faces a host serves itself load the same way: loadFonts({ faces: startup, extraLazyFonts: [{ family, weight, italic, url, sha256 }] }) adds them to the lazy list (registry.lazyFonts, package: "host"), so the registry can start with Roboto Regular only (splitStartupFaces(faces) splits a manifest into the startup face and the rest) and a document draws, fetches and verifies just the faces it needs, vendored and host faces in one ensureLazyFonts call. sha256 is mandatory, loads are all or nothing, dispose() removes the faces, and, like the vendored ones, host faces are embed: "used": they are not in registry.embeddedFonts (only the startup faces are), and a standalone SVG embeds one only when passed explicitly through registry.selectEmbeddedFonts and the slide's text uses its family. fonts.pending(presentation) (and the registry's pendingLazyFonts) is the synchronous check hosts gate rendering on, and after an edit it reports just the newly needed faces. The faces are those the renderer itself measures and draws (presentationFaces(presentation, options, registry), one layout-and-paint run with a recording measurement), resolved by the registry's own face selection over the faces it holds plus the vendored ones, so the browser loads exactly what Node draws with every vendored face loaded. A document resolves with the toSvg options the host renders with: pass them as loadFonts({ faces, renderOptions: { catalogs } }), or per call (pendingLazyFonts(presentation, { catalogs }), ensureLazyFonts(presentation, { signal, catalogs })), so a layout or font scheme id that only the host's catalogs know resolves here too; a document that does not resolve throws (rejects) what toSvg throws for it instead of reporting nothing. For the unreleased 0.34 Node path, loadFonts({ presentation, ... }) prepares only the actual styles and glyphs that presentation draws; an explicit script list makes its faces eligible without eagerly loading unrelated ones. A selected manifest color face also requires its effective declared monochrome raster companion, so the same handle serves SVG and PNG/raster PDF. Omitting presentation preserves whole-pack loading for an explicit host font collection (use an explicit script list or scripts: 'all'; scripts: 'auto' still needs its presentation). Caller-provided faces remain explicit and host-managed, including any caller-owned raster companion. Published 0.33 behavior does not change until the maintained 0.34 release. Both Node paths accept renderOptions: { catalogs }. Hosts copy the vendored directories next to the page.

Version 0.12.0 requires @openpresentation/opf ^0.12.0 (composed font sizes on PowerPoint's 0.01 pt grid, hanging wrap whitespace, promoted regions in reading order, right-to-left decks composed mirrored) and draws what that core composes, plus the preview changes listed in the changelog; use it with opf-pptx 0.12.0 and opf-editor 0.11.0 so preview and export resolve one core. Version 0.11.9 requires @openpresentation/opf ^0.11.4 and draws the design fields (deck and organization logos on covers and section slides, header and footer logo parts, design.listBullet: image picture bullets at the size PowerPoint draws them, the accent font, contentDirection and chartPrimary through core composition), and the slide tag falls back to the text color when the scheme primary is under 4.5:1 against the background; furniture images sit on their zone edge. Use it with opf-pptx 0.11.7 and opf-editor 0.10.6 so preview and export resolve one core (no API change; the preview of covers, list slides with picture bullets, chart slides with a primary chart and slides with furniture images changes). Version 0.11.8 draws the slide tag in the scheme primary color, as opf-pptx 0.11.5 writes it (no API change; the preview of slides with a tag changes). Version 0.11.7 lets a browser registry load the host's own faces on demand (extraLazyFonts, splitStartupFaces: a registry can start with Roboto Regular only; additive, registry.lazyFonts still lists the 94 vendored faces plus the host's). Version 0.11.6 makes the category-axis labels of chart previews rotate and skip instead of wrapping mid-word (no API change; the preview of dense-axis chart slides changes) and requires @openpresentation/opf ^0.11.3 (the 70 legacy gallery layout ids and their geometry); use it with PPTX 0.11.4 and editor 0.10.4 so preview and export resolve the same core. Version 0.11.5 loads vendored preview fonts by face, not by family, and lets the font loaders resolve documents with the host's render options (presentationFaces, lazyFacesNeeded; pendingLazyFonts, ensureLazyFonts, pendingScripts and ensureScripts take catalogs and throw or reject with the toSvg error for a document that does not resolve; registry.lazyFonts still lists 94 faces). Version 0.11.4 previews the seven chartex chart types natively (the world map as a non-geographic tile grid), keeps the Latin Noto Sans replacement for script schemes under scripts: 'auto' in Node, shapes Noto Sans Mongolian again and bundles Raleway and Playfair Display (registry.lazyFonts lists 94 faces; no API change). Version 0.11.3 previews the classic chart types natively, draws deprecated chart ids as their replacement and scales value axes like Office (no API change; the preview of chart slides changes). Version 0.11.2 makes scripts: 'auto' load the script faces a font scheme names and adds details.loadedFaceHasGlyph to missing-glyph (no export change). Version 0.11.1 adds the open replacement font families the policy routes to and complete Red Hat styles (no API change). Version 0.11.0 requires @openpresentation/opf ^0.11.2 (cover centering, Intos Aptos previews, lazy font loading, automatic script fonts and glyph fallback); use it with PPTX 0.11.0 and editor 0.10.0 so preview and export resolve the same core. Version 0.10.0 required @openpresentation/opf ^0.11.1 (font policy table, script fonts and right-to-left paragraphs, socials, image treatments, formatted slide-number and date furniture with the host date option, per-item alignment). See the changelog for the intentional preview-output changes.

Version 0.9.0 required @openpresentation/opf ^0.11.0 and resolved content ColorRef / variables through core resolveColorRef(). Authored #RRGGBB paint stays authored. It retains the existing rendering APIs.

Version 0.8.1 required core 0.10.1, including metric, quote and timeline layout placeholders and the corrected text-bullet contract.

Unfinished prepared shaping work is preserved in the September 15 roadmap; it is not part of the published runtime.

This checkout supports Node 22 or later (engines.node >=22; CI tests Node 22, 24 and 26). Versions 0.8.0 to 0.12.0 declared 24.x, so npm on Node 22 or 26 silently installed an older release instead (RR-20); upgrade past 0.12.0. Use .nvmrc (Node 24) for local development. Earlier published versions retain their original engine declarations. Browser entrypoints remain browser-safe; native application compatibility is verified separately.

Version 0.8.0 adds optional font-registry vector outlines and shared heading/scalar/rich line placement. Pass the same fonts handle and textRasterPadding option to preview, pagination and export; padding defaults to one scaled reference pixel. SVG consumes accepted origins without remeasuring. See the source contract and limits. Native raster certification remains separate.

Version 0.8.0 requires core 0.10.0 and renders accepted quote and code geometry without fitting it again. Code filename/language/body parts preserve source whitespace, literal tabs and metadata case and expose trace targets for editing. The 43 reviewed code raster changes retain the other 762 corpus hashes. Coordinated releases PPTX 0.8.0 and editor 0.7.0 add native source recovery and editing. Glyph containment and separation do not establish native pixel equivalence.

Deterministic local renderer for Open Presentation Format documents. The shared SVG core implements validation, reference resolution (through core, against the catalogs the host registers), placeholder binding and text layout. Node APIs additionally convert SVG to PNG and to PDF (vector with selectable text by default, or raster-backed).

In version 0.8.0, design.contentBox uses core's shared padded geometry. The card renders at item.frameBox; its payload uses item.box and accepted internals. Card padding participates in composition scoring, strict overflow and pagination. This requires core 0.10.0.

Version 0.8.0 paints plain and rich text, titles, subtitles and tags using composition's accepted fits and resolved styles. A TextRun[] title, subtitle, tag or quote text (FA-10) is painted the same way, through the rich-line painter used for body text. Painting does not measure those payloads again. Supply a font registry during composition: reusing an estimated fit cannot correct spacing when the actual drawing font has different advances.

Citations, footnotes and captions (core RR-34 fields cite, footnote, references and caption) draw from the same composed geometry: a marker is a superscript segment after its run (traced as data-opf-segment="marker" without source offsets), the slide's footnote area is a rule and <n> <text> lines in the muted color above the footer band, and a caption is a band inside its block's region. Decks without those fields render as before.

loadFonts in /fonts-node prepares the fonts. It verifies all selected font files and license notices against the versioned BUNDLED_FONT_MANIFEST, including exact npm versions and SHA-256 hashes. Carlito is not an npm dependency: the package ships the unmodified google/fonts Carlito files and their OFL notice in fonts/carlito, pinned to a google/fonts commit and verified by the same hashes. The returned handle configures layout, SVG, editing, PPTX, and Node raster output with the same font inputs (textMeasurement, embeddedFonts, fontFiles, useBundledFonts: false, loadSystemFonts: false, plus registry, manifest, substitutions, ensure(presentation) and pending(presentation)):

import { loadFonts } from '@openpresentation/opf-render/fonts-node';
import { toSvg, toPng } from '@openpresentation/opf-render';
import { paginate } from '@openpresentation/opf/pagination';
import { toPptx } from '@openpresentation/opf-pptx';

const fonts = await loadFonts({
  pack: 'office', substitutionPolicy: 'visual',
});
const { presentation } = paginate(opf, { fonts });
const slides = toSvg(presentation, { fonts });
const png = await toPng(slides[0], { fonts });
const pptx = await toPptx(presentation, { fonts });
console.log(fonts.substitutions);

pack is base (default), office or none (only the faces you supply). The base pack contains nine Roboto/Roboto Mono faces and suits a document using design.fontScheme: 'roboto'. The Office pack includes 24 Office-substitute faces plus 70 vendored faces of the open families that font schemes select and the open replacements the font policy routes to (below) and the 16 vendored Intos faces that preview the Aptos family (below), and defaults to metric substitution policy. Its four Carlito faces are the byte-identical upstream release (OFL reserves the name "Carlito", so a subset or conversion could not keep it); visual substitution remains explicit. Neither helper changes the document's authored font scheme or installs system fonts. The authored (selected) font is the source of truth. Licensed fonts are never bundled, so these packs supply open look-alikes for previews and SVG: metric-compatible where one exists (Carlito for Calibri, Intos for Aptos), visual-only where none does yet (a documented fallback and known layout-fidelity gap). The PPTX exporter still writes the selected name; see the OPF font policy. Missing resources, changed bytes/notices, and unexpected package versions fail with actionable font errors. Requested/resolved substitution records remain on registry.substitutions; source paths appear where the caller supplies them. Font coverage, variant naming, shaping, and native fidelity retain their documented limits.

Default PNG/PDF raster loading now uses the same complete nine-face base pack, fixing omitted semibold and italic faces. A handle says useBundledFonts: false because it already holds its files; a plain fonts: { useBundledFonts: false } draws with no bundled face. Font files must stay available and unchanged for subsequent raster calls. node scripts/update-font-manifest.mjs is an explicit maintenance operation requiring review of font bytes, style metadata, licenses and raster changes; builds and installs never regenerate the expected hashes.

Version 0.8.0 resolves OpenType preferred-family groups, so a Roboto request at 500, 600 or 800 selects the installed Medium, SemiBold or ExtraBold face. Explicit caller family renames keep their own namespace; ambiguous grouped faces reject. Resolved styles also carry optional fontFace metadata with the physical legacy family and its bold/italic style-link flags. Coordinated PPTX export consumes those flags independently of numeric weight. This prevents requesting a second bold style from an already named ExtraBold/SemiBold family. Browser CSS and native selectors retain their respective family names; no font is synthesized or installed by this lookup. See exact-weight evidence and limits.

Code strings that XML 1.0 cannot represent reject rendering with invalid-code-text, the OPF field path and UTF-16 offset. Input JSON stays unchanged. Tabs, line endings and valid supplementary Unicode remain accepted; schema validity and XML serialization do not certify font coverage or native fidelity.

Pass fonts, otherwise the estimate

Text measurement comes from one place: the fonts handle that loadFonts() (from /fonts-node or /fonts-browser) returns. Pass the same handle to preview, validation, pagination and export, so that every step measures with the faces the preview draws:

import { loadFonts } from '@openpresentation/opf-render/fonts-node';
import { toSvg, toPng, toPdf } from '@openpresentation/opf-render';
import { validate } from '@openpresentation/opf';
import { gallery } from '@openpresentation/gallery';
import { paginate } from '@openpresentation/opf/pagination';
import { toPptx } from '@openpresentation/opf-pptx';

const catalogs = [gallery];
const renderOptions = { catalogs, date: '2026-11-09' };
const fonts = await loadFonts({ pack: 'office', scripts: 'auto', presentation: deck, renderOptions });
const report = validate(deck, { fonts });                 // overflow findings use the real widths
const { presentation } = paginate(deck, { fonts });        // page breaks use the real widths
const svgs = toSvg(presentation, { fonts });              // line breaks use the real widths
const png = await toPng(presentation, 1, { fonts });
const pdf = await toPdf(presentation, { fonts });
const pptx = await toPptx(presentation, { fonts });        // the same lines in editable PowerPoint text

Node loading with presentation reads only the selected family, weight and italic faces, plus the glyph fallback faces actually needed. Selection still considers the complete allowed pack metadata. A valid deck without drawn text needs zero faces; explicit caller faces are retained. Omit presentation to deliberately load the complete requested pack, as font-copying and catalog build tools do. No font or license bytes, selected native typefaces, or font policy change.

Node document preparation verifies selected font bytes and style/glyph coverage without shaping text merely to discard its width. It does not qualify shaping: loadFonts/ensure may finish before a shaping error that previously occurred during preparation; real measurement, outlines and rendering still shape and retain their original failures. Caller-replaced measurement methods/accessors and caller-installed shapers keep full measurement during coverage. No width, outline or shaping cache is reused by this preparation probe.

Before drawing a changed deck, await fonts.ensure(nextDeck, { renderOptions }) with the same catalogs and date as rendering; fonts.pending(nextDeck, renderOptions) includes missing ordinary styles as well as scripts. Calls on one handle are serialized and failed preparation can be retried. The synchronous renderer never loads files itself: measuring an unprepared style refuses rather than quietly choosing a different held weight. Core's Node conversion/pagination prepares each document under its existing shared lease, and the async PPTX exporter prepares demand handles for selected or explicitly safe typefaces. Native preparation also preserves the chosen role's requested weight while selecting its actual glyph fallback: a bold Latin fragment inside an Emoji role can require a separate bold Latin fallback face. Safe mapping applies outside the raw script planner, so script-generated fallback names keep their ordinary selection. The exporter supplies this mode automatically; ordinary preview preparation and glyph strictness are unchanged. A reused handle retains its previous faces; use a new handle or bounded worker lifetime to release them.

One handle carries the measurement for core's validate, paginate and slide context, for toSvg, toPng and toPdf, and for opf-pptx's toPptx. The same handle gives identical text geometry across those engines: every engine reads core's one composition, so the measurement decides the lines. opf-pptx's layout-parity test checks that the exported PowerPoint paragraphs agree with this renderer's SVG and with core's composed items, with and without fonts.

Node handles, and browser handles loaded with shapeWasm, measure advances and glyph ink with the same HarfBuzz shaper used by vector PDF and text outlines. Handles without shaping WASM retain fontkit measurement. This can change line wrapping for Myanmar and some Syriac text; the reviewed corpus report records the differences and the unchanged example output.

A call without fonts is not an error. It uses core's deterministic estimate instead of measured font advances. Core applies script-specific widths, including the six script estimates improved in OPF 0.19; nonspacing and enclosing marks have no independent advance, while spacing combining marks retain width. The estimate needs no font files, but line breaks, overflow findings and page breaks can differ from what the selected faces actually draw. Treat an estimated preview as a draft. Core's Node convert and the opf CLI prepare an office-pack handle for you; a library call to toSvg, toPng or toPdf never loads fonts on its own, so pass the handle you want. Compare opf#364.

Install: what to add for what (RR-63)

npm install @openpresentation/opf-render brings the SVG renderer, layout and text measurement (@openpresentation/opf, fontkit, bidi-js, pako) and the vendored font files under fonts/. The heavy pieces are optional peer dependencies, so you install only what your output needs. npm 7+ and pnpm do not install optional peers; add them yourself:

You want Import Also install
SVG in a browser (the host serves its own font files) @openpresentation/opf-render/svg (+ /fonts-browser) nothing
SVG in Node, no fonts handle (estimated widths) @openpresentation/opf-render/svg nothing
SVG in Node with exact text measurement /svg and loadFonts from /fonts-node the font packages of the pack (below)
PNG in Node /png (or the root) npm install @resvg/resvg-js (sharp too for WebP and rotated JPEG pictures) and the fonts of the pack
PDF in Node (vector, the default) /pdf (or the root) the fonts of the pack; sharp for pictures; @resvg/resvg-js for the rare element drawn as an image (a filter, a mask)
PDF in Node, raster: true /pdf (or the root) pdf-lib, @resvg/resvg-js, sharp and the fonts of the pack
PNG and PDF in a browser /export-browser nothing (raster: true needs pdf-lib, see below)
Slideshow, <opf-deck>, server markup /player, /element, /element/define nothing

The font packages are pinned exactly (@expo-google-fonts/*, each a pinned optional peer; what each pack holds is described under pack above and in Script fonts). loadFonts() (pack base) needs @expo-google-fonts/roboto@0.4.3 and roboto-mono@0.4.2; loadFonts({ pack: 'office' }) also needs arimo, caladea, cousine, gelasio, tinos and noto-sans. A script face (scripts: ['Jpan'], scripts: 'auto') needs its own @expo-google-fonts/noto-* package. The fonts/ directory (the vendored Carlito, Intos and open families, about 28 MB) ships inside the package.

Converter ranges: @resvg/resvg-js@^2.6.2, sharp@^0.35.5, pdf-lib@^1.17.1.

The format entries

Entry What it is Runs in
@openpresentation/opf-render/svg toSvg, resolvePresentation, OPFRenderError and the types. No converter, no Node module. browser and Node
@openpresentation/opf-render/png toPng Node
@openpresentation/opf-render/pdf toPdf Node
@openpresentation/opf-render/export-browser toPng and toPdf for a page (canvas) browser
@openpresentation/opf-render/element, /element/define, /player toHtml, <opf-deck>, present (the HTML output) browser (toHtml also on a server)
@openpresentation/opf-render all of /svg, plus toPng and toPdf Node (a browser bundler picks /svg)

There is no /html entry: it would only repeat /element (toHtml, defineOpfDeck) and /player (present) under a second name. A bundler that bundles Node code (a server framework) sees the converters' dynamic import() in the root and in /png and /pdf; an app that only draws SVG should import /svg, which has none, and an app that exports should list the converters as installed (or external) in its bundler.

A server bundle needs no bundler config for /fonts-node and /preview-fonts-node either: a Next.js app (Turbopack or webpack) that imports them builds and renders what plain Node renders (npm run test:next-bundle checks this against Next.js 16). They read harfbuzzjs's .wasm files, the installed @expo-google-fonts/* packages and this package's fonts/ directory from disk at run time, through Node's own resolution, so a bundler does not trace them. A deployment that ships only traced files (Next.js output: "standalone", serverless functions) must include those packages, for example with outputFileTracingIncludes. Without harfbuzzjs, loadFonts still loads the fonts and reports harfbuzz-unavailable through onDiagnostic: an SVG then embeds whole faces, and outlines are shaped with fontkit.

A missing converter or font package

An export that needs a converter that is not installed rejects with OPFRenderError code converter-missing. details holds package, range, install (the command), purpose and installed (false when the package is absent; true when it is installed but cannot load, for example a native binary missing for the platform):

try { await toPng(svg); }
catch (error) {
  // error.code === 'converter-missing'
  // error.message: '@resvg/resvg-js is not installed. It is an optional peer dependency of @openpresentation/opf-render, used for PNG output, ...: run `npm install @resvg/resvg-js@^2.6.2`.'
}

toPng needs @resvg/resvg-js; a WebP or rotated JPEG picture in it also needs sharp. toPdf (vector) needs no converter for text and shapes, sharp for pictures and @resvg/resvg-js for an element it has to draw as an image (reported as pdf-raster-fallback); raster: true needs pdf-lib and @resvg/resvg-js. A picture is never silently dropped from a PDF because sharp is absent: the export rejects instead.

A font pack whose @expo-google-fonts/* packages are not all installed rejects loadFonts with OPFFontError code font-resource-unavailable; details.packages and the message name every missing package with the npm install command. scripts: 'auto' still reports a missing script package as the script-font-not-installed diagnostic instead of failing. In a browser, export-browser imports no converter: a raster PDF takes the module as an option (toPdf(svgs, { raster: true, pdfLib }) with import * as pdfLib from 'pdf-lib'), so a bundle of the entry holds no PDF library; without it a raster PDF rejects with converter-missing.

Installed size, measured on Windows with npm install --ignore-scripts, unpacked. sharp brings its 19 MiB libvips build on each platform; of the SVG-only install, 28 MiB is the vendored font files under fonts/, 13 MiB core and 6 MiB fontkit:

Install 0.15.0 with RR-63
SVG only, in a browser (/svg + /fonts-browser) 135 MiB 56 MiB
Node SVG and PNG (base pack) 135 MiB 89 MiB