@openpresentation/opf-render 0.33.0 → 0.34.0
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/README.md +28 -15
- package/dist/chart-options.js +4 -2
- package/dist/charts.js +99 -91
- package/dist/export-browser.d.ts +7 -0
- package/dist/export-browser.js +18 -6
- package/dist/font-demand.js +673 -0
- package/dist/font-files.js +43 -0
- package/dist/font-registry.js +57 -20
- package/dist/font-selection-metadata.js +21 -0
- package/dist/font-selection.js +6 -0
- package/dist/fonts-browser.d.ts +4 -3
- package/dist/fonts-browser.js +19 -8
- package/dist/fonts-node.d.ts +6 -5
- package/dist/fonts-node.js +27 -7
- package/dist/fonts.d.ts +13 -3
- package/dist/hb-shape.js +4 -4
- package/dist/index.d.ts +6 -0
- package/dist/lazy-fonts.js +209 -44
- package/dist/pdf-fonts.js +1 -1
- package/dist/pdf-text.js +10 -2
- package/dist/pdf-vector.js +2 -31
- package/dist/preview-fonts-cli.js +14 -4
- package/dist/preview-fonts-node.d.ts +18 -0
- package/dist/preview-fonts-node.js +37 -0
- package/dist/raster-markers.js +46 -0
- package/dist/raster.js +7 -4
- package/dist/script-font-pack.js +65 -4
- package/dist/script-fonts.js +6 -90
- package/dist/svg.d.ts +6 -0
- package/dist/svg.js +179 -74
- package/dist/text-paths.js +48 -16
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ A slide's canvas, layout, theme, colour scheme and font scheme come from core's
|
|
|
48
48
|
|
|
49
49
|
An option a function does not know is not read: a top-level `textMeasurement` or `embeddedFonts` is ignored, so pass `{ fonts }`.
|
|
50
50
|
|
|
51
|
-
**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. Node
|
|
51
|
+
**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.
|
|
52
52
|
|
|
53
53
|
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 colour 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 colour, 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.
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ This checkout supports Node 22 or later (`engines.node` `>=22`; CI tests Node 22
|
|
|
62
62
|
|
|
63
63
|
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](https://github.com/OpenPresentation/opf/blob/f94125a1ff95bf0974a055fe1c081d348dad54f2/docs/plans/text-placement.md). Native raster certification remains separate.
|
|
64
64
|
|
|
65
|
-
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
|
|
65
|
+
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.
|
|
66
66
|
|
|
67
67
|
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).
|
|
68
68
|
|
|
@@ -94,7 +94,7 @@ console.log(fonts.substitutions);
|
|
|
94
94
|
|
|
95
95
|
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.
|
|
96
96
|
|
|
97
|
-
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
|
|
97
|
+
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.
|
|
98
98
|
|
|
99
99
|
Code strings that [XML 1.0 cannot represent](https://www.w3.org/TR/xml/#charsets) 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.
|
|
100
100
|
|
|
@@ -106,10 +106,13 @@ Text measurement comes from one place: the `fonts` handle that `loadFonts()` (fr
|
|
|
106
106
|
import { loadFonts } from '@openpresentation/opf-render/fonts-node';
|
|
107
107
|
import { toSvg, toPng, toPdf } from '@openpresentation/opf-render';
|
|
108
108
|
import { validate } from '@openpresentation/opf';
|
|
109
|
+
import { gallery } from '@openpresentation/gallery';
|
|
109
110
|
import { paginate } from '@openpresentation/opf/pagination';
|
|
110
111
|
import { toPptx } from '@openpresentation/opf-pptx';
|
|
111
112
|
|
|
112
|
-
const
|
|
113
|
+
const catalogs = [gallery];
|
|
114
|
+
const renderOptions = { catalogs, date: '2026-11-09' };
|
|
115
|
+
const fonts = await loadFonts({ pack: 'office', scripts: 'auto', presentation: deck, renderOptions });
|
|
113
116
|
const report = validate(deck, { fonts }); // overflow findings use the real widths
|
|
114
117
|
const { presentation } = paginate(deck, { fonts }); // page breaks use the real widths
|
|
115
118
|
const svgs = toSvg(presentation, { fonts }); // line breaks use the real widths
|
|
@@ -118,9 +121,15 @@ const pdf = await toPdf(presentation, { fonts });
|
|
|
118
121
|
const pptx = await toPptx(presentation, { fonts }); // the same lines in editable PowerPoint text
|
|
119
122
|
```
|
|
120
123
|
|
|
124
|
+
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.
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
121
130
|
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](https://github.com/OpenPresentation/opf-pptx/blob/main/test/layout-parity.mjs) checks that the exported PowerPoint paragraphs agree with this renderer's SVG and with core's composed items, with and without `fonts`.
|
|
122
131
|
|
|
123
|
-
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;
|
|
132
|
+
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.
|
|
124
133
|
|
|
125
134
|
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](https://github.com/OpenPresentation/opf/issues/364).
|
|
126
135
|
|
|
@@ -212,7 +221,7 @@ console.log(fonts.substitutions);
|
|
|
212
221
|
|
|
213
222
|
Set `trace: true` to stamp rendered SVG elements with `data-opf-path` values such as `slides.0.title`; omit it for smaller production SVG.
|
|
214
223
|
|
|
215
|
-
Layout templates (OPF 0.19, core `opf-layout/v2`: a `direction` and one ordered `regions` list, nested for two dimensions) draw from core's composed geometry, as every slide does: the renderer adds no arrangement of its own. Core places each block in its region (`geometry.regions`, `item.region`); a card is the `item.frameBox` core composed in the block's cell (`design.contentBox`), and a region with `bleed` arrives with its outer edges on the slide edge and no card. A list core laid out in columns (`item.listColumns`: a lone list in a region with `listColumns: "auto"`, or a list payload with `columns`) draws each column's own fit in its own box, at one shared size, with numbering continuing across the columns; `item.text` (the whole list) is not drawn then. With `trace: true` everything an item of a region draws (card, payload, caption) is grouped in `<g data-opf-region="<name>">`, and each list column is a group with `data-opf-list-column` (its index), `data-opf-list-start` and `data-opf-list-end` (the half-open range of the payload's items it holds) and its `data-opf-box-*`. OPF 0.19 removes `opf-layout/v1` records with no alias or migration shim. Slides without a layout use core's automatic composition; only items bound to template regions carry these region attributes. `test/layout-template-goldens.mjs` pins the SVG and PNG of the
|
|
224
|
+
Layout templates (OPF 0.19, core `opf-layout/v2`: a `direction` and one ordered `regions` list, nested for two dimensions) draw from core's composed geometry, as every slide does: the renderer adds no arrangement of its own. Core places each block in its region (`geometry.regions`, `item.region`); a card is the `item.frameBox` core composed in the block's cell (`design.contentBox`), and a region with `bleed` arrives with its outer edges on the slide edge and no card. A list core laid out in columns (`item.listColumns`: a lone list in a region with `listColumns: "auto"`, or a list payload with `columns`) draws each column's own fit in its own box, at one shared size, with numbering continuing across the columns; `item.text` (the whole list) is not drawn then. With `trace: true` everything an item of a region draws (card, payload, caption) is grouped in `<g data-opf-region="<name>">`, and each list column is a group with `data-opf-list-column` (its index), `data-opf-list-start` and `data-opf-list-end` (the half-open range of the payload's items it holds) and its `data-opf-box-*`. OPF 0.19 removes `opf-layout/v1` records with no alias or migration shim. Slides without a layout use core's automatic composition; only items bound to template regions carry these region attributes. `test/layout-template-goldens.mjs` pins the SVG and PNG of the matching Gallery templates (40 in this source) with 1 to 6 short and long blocks, and of the pages core's `paginate` makes of the ones that overflow.
|
|
216
225
|
|
|
217
226
|
The installed open font pack works offline. The Aptos family previews with the metric-compatible Intos even under the default metric policy; this example additionally permits visual-only look-alikes for families with no metric replacement yet (a documented fallback), and the substitution report identifies requested and resolved faces. A visual substitute is not a claim of metric or pixel equivalence, and it is a known layout-fidelity gap rather than the end state. Replacements apply to rendering only; the document keeps the selected font name. Omit `substitutionPolicy` to restrict the Office pack to its metric mappings, or supply your own licensed faces (`faces`). Missing fonts/glyphs fail explicitly. Without `fonts`, synchronous SVG APIs use estimated widths; named fonts alone do not make rich-run spacing reliable. Browser hosts should load the same bytes using the loader below.
|
|
218
227
|
|
|
@@ -283,7 +292,7 @@ The default changed from raster to vector in the release that added this section
|
|
|
283
292
|
|
|
284
293
|
## PNG and PDF in a browser
|
|
285
294
|
|
|
286
|
-
`@openpresentation/opf-render/export-browser` exports `toPdf` and `toPng` for a page, with the arguments of the Node functions. They take a deck (drawn with the browser fonts handle) or the SVG the preview draws, and need no Node module, no network and no system font (a bundle of this entry contains no sharp, resvg, fs or crypto, and the vector converter's SHA-256 is plain JavaScript).
|
|
295
|
+
`@openpresentation/opf-render/export-browser` exports `toPdf` and `toPng` for a page, with the arguments of the Node functions. They take a deck (drawn with the browser fonts handle) or the SVG the preview draws, and need no Node module, no network and no system font (a bundle of this entry contains no sharp, resvg, fs or crypto, and the vector converter's SHA-256 is plain JavaScript). On a page whose Content-Security-Policy allows `data:` images but not `blob:` ones (the sandbox of an MCP App), pass `svgSource: "data"`: a slide drawn through the image decoder (a PNG, a raster PDF, a part the vector PDF cannot draw) then goes in as a `data:` URL; a `blob:` URL that does not load is retried that way.
|
|
287
296
|
|
|
288
297
|
- **Vector PDF** (default) is the same converter the Node export uses (selectable real text in embedded font subsets, paths, gradients, patterns, clips, opacity, links, tagged structure, byte-identical output for the same SVG). Fonts come from the SVG's own `@font-face` data (pass a `fonts` handle with `embeddedFonts` to `toSvg`; each face is embedded only on the slides that draw it, so the PDF gets every face its pages draw), from the faces of the `fonts` handle you pass to `toPdf` (script faces an SVG does not carry reach the PDF too) or from `fontData: [{ data, family? }]`; `fontFiles` and font folders do not exist here and system fonts cannot be loaded. A face the handle never loaded is never embedded.
|
|
289
298
|
- **Pictures** are decoded by the browser (PNG, JPEG, WebP, GIF through `createImageBitmap`, EXIF orientation applied); an upright JPEG is passed through compressed, as in Node. An effect with no PDF form (filter, mask, a nested SVG picture) rasterizes only that element on a canvas and reports `pdf-raster-fallback`.
|
|
@@ -350,7 +359,7 @@ useEffect(() => { defineOpfDeck(); }, []);
|
|
|
350
359
|
// ...and render <opf-deck src="/deck.opf.json" fonts="/opf-fonts/" />.
|
|
351
360
|
```
|
|
352
361
|
|
|
353
|
-
Entry points (package `exports`): `/element` (`defineOpfDeck`, `getOpfDeckElement`, `toHtml`, `loadPreviewFonts`), `/element/define` (importing it registers the tag; the only file with a side effect), `/player` (`present`), `/preview-fonts` (the font root layout and `loadPreviewFonts`) and `/preview-fonts-node` (`copyPreviewFonts`, also the `opf-preview-fonts` command). The element loads the player on first use, so a page that only embeds decks does not carry slideshow code.
|
|
362
|
+
Entry points (package `exports`): `/element` (`defineOpfDeck`, `getOpfDeckElement`, `toHtml`, `loadPreviewFonts`), `/element/define` (importing it registers the tag; the only file with a side effect), `/player` (`present`), `/preview-fonts` (the font root layout and `loadPreviewFonts`) and `/preview-fonts-node` (`copyPreviewFonts`, `fontconfigAliases` and `fontconfigConf`, also the `opf-preview-fonts` command). The element loads the player on first use, so a page that only embeds decks does not carry slideshow code.
|
|
354
363
|
|
|
355
364
|
### Fonts: one self-hosted directory
|
|
356
365
|
|
|
@@ -361,6 +370,8 @@ npx opf-preview-fonts public/opf-fonts # base and vendored face
|
|
|
361
370
|
npx opf-preview-fonts public/opf-fonts --scripts Jpan,Arab # plus Noto script faces (large; `all` for every script)
|
|
362
371
|
```
|
|
363
372
|
|
|
373
|
+
`--fontconfig <file>` also writes a fontconfig file that names the directory and adds one alias per font-policy replacement (Aptos to Intos, Calibri to Carlito, Arial to Arimo, ...). On Linux, `npx opf-preview-fonts ~/.local/share/fonts/opf --scripts all --fontconfig ~/.config/fontconfig/conf.d/60-opf-fonts.conf` makes OPF's preview replacements available to apps that resolve fonts through fontconfig, including LibreOffice. Matching font resolution alone does not guarantee identical line breaks or layout; [LibreOffice interoperability remains experimental](https://github.com/OpenPresentation/opf/blob/main/docs/libreoffice.md#fonts). The same file comes from `fontconfigConf()` and `fontconfigAliases()` of `/preview-fonts-node`. An alias replaces a family even where it is installed, so use it on machines that lack the originals.
|
|
374
|
+
|
|
364
375
|
```
|
|
365
376
|
<root>/base/<package>/<file> the eager Office and base faces (Roboto Regular loads at startup, the rest on demand)
|
|
366
377
|
<root>/lazy/fonts/<family>/<file> the vendored faces (Intos for the default Aptos scheme, the open families)
|
|
@@ -434,7 +445,7 @@ The reproducible production fixture (`npm run build` then `node scripts/measure-
|
|
|
434
445
|
| Shared SSR, before deferred upgrade | 229,322 B | 199 B | None |
|
|
435
446
|
| Shared SSR, after deferred upgrade | 229,322 B | 500,355 B total | Two faces, 191,628 B gzip |
|
|
436
447
|
|
|
437
|
-
The base and Office pack standalone SVGs both contain two Roboto rules (430,764 B / 228,481 B gzip). All three SSR modes render identical pixels with JavaScript disabled, an extracted standalone SVG paints the same offline, and strict interactive upgrades preserve those pixels. These numbers describe this local candidate and fixture, vary with the deck and bundler, and are recorded in
|
|
448
|
+
The base and Office pack standalone SVGs both contain two Roboto rules (430,764 B / 228,481 B gzip). All three SSR modes render identical pixels with JavaScript disabled, an extracted standalone SVG paints the same offline, and strict interactive upgrades preserve those pixels. These numbers describe this local candidate and fixture, vary with the deck and bundler, and are recorded in the production delivery report. The measurement-enabled JavaScript cost remains about 500 KB gzip. Copying the approximately 34 MiB font root does not make the browser fetch it all: this fixture fetches only Roboto Regular and Bold; other documents fetch their own required faces.
|
|
438
449
|
|
|
439
450
|
### The slideshow
|
|
440
451
|
|
|
@@ -544,9 +555,9 @@ Characters are assigned to slots following PowerPoint where its rules are known:
|
|
|
544
555
|
|
|
545
556
|
Limits:
|
|
546
557
|
|
|
547
|
-
- Alignment is logical for right-to-left text (RR-05, needs the core release that composes right-to-left decks): `
|
|
558
|
+
- Alignment is logical for right-to-left text (RR-05, needs the core release that composes right-to-left decks): `start` is the edge a paragraph starts on, so a right-to-left paragraph is drawn against the right edge, its list markers sit at the right (`text-anchor="end"`), the composition is mirrored (the `start` region and the first table column at the right, cover logo and header/footer zones swapped), tables run right to left and column, line and area charts reverse their categories with the value axis at the right. Every wrapped line takes its paragraph's direction from core (`fit.directions`). A left-to-right deck is drawn exactly as before.
|
|
548
559
|
- Known differences from PowerPoint: the character tables above are approximations, not PowerPoint's full per-character table. Non-ASCII common characters, such as Latin-1 symbols and other general punctuation, join the neighbouring run instead of following PowerPoint's per-character slot, and PowerPoint's `hint="eastAsia"` run property is not modelled.
|
|
549
|
-
- Per-run language (`
|
|
560
|
+
- Per-run language (`language` on individual runs) is not modelled. Han text uses kana or Hangul context, then the document language, and defaults to Simplified Chinese.
|
|
550
561
|
- Faces have no italics, so italic script text uses upright advances. Browsers may slant it synthetically.
|
|
551
562
|
- Serif CJK replacements (Noto Serif JP/SC/TC/KR) are designated but not pinned; serif CJK requests, and serif Latin, Cyrillic and Greek fallback text, use the sans face unless you supply a serif face (a loaded designated serif family is preferred automatically).
|
|
552
563
|
- Shaping uses fontkit. An offline Chromium check keeps 37 runs across 28 cases within 0.1 px of HarfBuzz advances (`npm run test:script-fonts-browser`). Other texts, fonts and PowerPoint's own shaping are not certified.
|
|
@@ -574,7 +585,7 @@ Symbol, Wingdings, Wingdings 2, Wingdings 3 and Webdings keep their glyphs at th
|
|
|
574
585
|
|
|
575
586
|
## Small conveniences (FA-13)
|
|
576
587
|
|
|
577
|
-
`code.highlight` draws one theme-derived band (an SVG `rect`) behind each run of marked lines and dims the unmarked lines; marked lines keep their syntax colours, and every colour stays at least 4.5:1 on what it sits on (core `codeHighlightColors`). A text `design.watermark` is one `text` element in the heading font and the theme text color, centered and rotated 30 degrees counterclockwise at the watermark opacity (core `layoutWatermark`). A `TextRun` with `code: true` draws in the design's code font with a monospace generic fallback, in text, lists and tables. A run with `
|
|
588
|
+
`code.highlight` draws one theme-derived band (an SVG `rect`) behind each run of marked lines and dims the unmarked lines; marked lines keep their syntax colours, and every colour stays at least 4.5:1 on what it sits on (core `codeHighlightColors`). A text `design.watermark` is one `text` element in the heading font and the theme text color, centered and rotated 30 degrees counterclockwise at the watermark opacity (core `layoutWatermark`). A `TextRun` with `code: true` draws in the design's code font with a monospace generic fallback, in text, lists and tables. A run with `language` writes `lang`/`xml:lang` on its text and is measured and drawn with the script fonts of that language (Han text takes the Japanese or the Simplified Chinese face). `1:1`, `4:5` and `9:16` compose at 7.5 x 7.5, 7.5 x 9.375 and 7.5 x 13.333 inches.
|
|
578
589
|
|
|
579
590
|
## Numbered lists (RR-33)
|
|
580
591
|
|
|
@@ -606,9 +617,11 @@ Chartex chart previews (FF-22b) draw the constructs opf-pptx exports as Office 2
|
|
|
606
617
|
|
|
607
618
|
Combo charts (FA-15): `type: "combo"` draws clustered columns with line series (lines with markers) in one plot. Core's `resolveChartData` resolves the plan, so the preview and the PPTX export agree: the series that `chart.line` names (by default the last series) are lines, `chart.secondaryAxis` puts lines on a secondary value axis at the right (at the left right to left) with its own scale and its tick labels in the first secondary series' column format, and the series are drawn and listed in the legend columns first, then the primary-axis lines, then the secondary-axis lines. Gridlines follow the primary axis; `axisTitles.secondary` titles the secondary axis (rotated, inside a right legend); data labels sit outside the end of the columns and above the line points unless `dataLabels.position` says otherwise.
|
|
608
619
|
|
|
620
|
+
Explicit chart reference lines (LH-110): `chart.referenceLines` holds ordered numeric values in their own value-axis units, optional verbatim endpoint labels and independent ColorRef/width/solid-dash-dot strokes. A line chart keeps its existing solid data line while a target can be dashed. Column, bar, line, line-with-markers, area and combo are supported; absence or an empty list draws none. Titles/subtitles never create thresholds or period bands. Shared composition supplies bounds, plot and label placement, including RTL and collisions; combo primary/secondary scales are shared with PPTX. Vertical references span first-to-last category centers when there are at least two categories; bar and singleton fallbacks span the full plot. See [the contract and PPTX edit/import limits](../../docs/chart-options.md#explicit-reference-lines).
|
|
621
|
+
|
|
609
622
|
Chart options (RR-35): a chart's optional `axisTitles`, `legend` and `dataLabels` (core `docs/chart-options.md`) are drawn. A named legend position is carved from the chart box before the plot is laid out, axis titles sit beside the axes (the value title rotated 270 degrees), and data labels follow the content (category, value, percent), position and separator the chart type supports. An option a type cannot show is dropped with a `chart-option-adapted` diagnostic; a chart without the fields draws as before.
|
|
610
623
|
|
|
611
|
-
Chart colours, text and value axis (RR-89, RR-90, RR-92; need core 0.22.0: `chartSeriesPalette`, `chartTextSize` and the composed `chart.valueAxis`): series are drawn in core's `chartSeriesPalette` of the deck's resolved colour scheme (`accent1` to `accent6`, then the same accents tinted toward white), adjusted per chart panel by `chartPaletteForFill`, so `design.colorScheme` recolours charts; chart axis, legend, category and data-label text is core's `chartTextSize` (20 px, shrunk only for a small chart box, never below `minFontSize`); and a column, bar, line or area chart draws the value axis (`min`, `max`, `majorUnit`) core composes for its box, the axis the PPTX export writes.
|
|
624
|
+
Chart colours, text and value axis (RR-89, RR-90, RR-92; need core 0.22.0: `chartSeriesPalette`, `chartTextSize` and the composed `chart.valueAxis`): series are drawn in core's `chartSeriesPalette` of the deck's resolved colour scheme (`accent1` to `accent6`, then the same accents tinted toward white), adjusted per chart panel by `chartPaletteForFill`, so `design.colorScheme` recolours charts; chart axis, legend, category and data-label text is core's `chartTextSize` (20 px, shrunk only for a small chart box, never below `minFontSize`); and a column, bar, line or area chart draws the value axis (`min`, `max`, `majorUnit`) core composes for its box, the axis the PPTX export writes. Combo charts likewise consume composed primary and secondary axes; chart constructs without composed bounds retain their own scale.
|
|
612
625
|
|
|
613
626
|
Chart emphasis (FA-14): `chart.highlight` names the series (data columns) and categories (row labels) that carry the message. Highlighted marks are filled with the deck primary and every other mark with a muted neutral derived from the chart panel and text colors (core `chartHighlightColors`; core `chartHighlightMarks` decides which marks are named: a mark is highlighted when its series or its category is). It colors columns, bars, line series and (for a category highlight) line points, areas, scatter and radar series, and pie and doughnut slices, with legend keys and data label contrast following; the chartex constructs draw as before and the `chart-option-adapted` diagnostic names the dropped part. Series keep their order and a chart without `highlight` draws the same SVG as before.
|
|
614
627
|
|
|
@@ -685,7 +698,7 @@ pnpm run golden:update
|
|
|
685
698
|
|
|
686
699
|
## Release Lane
|
|
687
700
|
|
|
688
|
-
Public npm package publication is handled by the repository's one `npm-publish.yml` through npm Trusted Publishing (GitHub Actions OIDC) with npm provenance; no npm token is stored. All
|
|
701
|
+
Public npm package publication is handled by the repository's one `npm-publish.yml` through npm Trusted Publishing (GitHub Actions OIDC) with npm provenance; no npm token is stored. All seven packages (`@openpresentation/opf`, `@openpresentation/cli`, `@openpresentation/gallery`, `@openpresentation/opf-render`, `@openpresentation/opf-pptx`, `@openpresentation/opf-editor` and `@openpresentation/mcp`) share one version and are released together: see [docs/release-process.md](../../docs/release-process.md) at the repository root. Start the **Release** workflow on `main` with `dry-run` true, then run the same version with `dry-run` false after the rehearsal succeeds. The owner authorized agents to prepare and publish npm releases whenever a release is required (2026-09-29). This authorization does not waive any gate. Fragments for this package are `changes/<slug>.md` files at the repository root with `packages: [render]`. Never republish an existing version.
|
|
689
702
|
|
|
690
703
|
## Shared dynamic composition (local development)
|
|
691
704
|
|
|
@@ -731,4 +744,4 @@ Every covered position is explicit `null`. Each merged anchor renders once; trac
|
|
|
731
744
|
|
|
732
745
|
The Node20/24 renderer suite retains all 805 existing raster baselines. Browser fixtures verify merged text containment and styled-cell typing, formatting, cancellation and undo with actual loaded fonts. Native PowerPoint appearance remains a separate converter verification boundary.
|
|
733
746
|
|
|
734
|
-
Version 0.8.0 preserves scalar spaces, literal tabs and exact hard-line source ranges across core layout and SVG. Explicit tab positions and whitespace-preserving SVG text prevent source collapse. Its separate 805-slide checkpoint follows review of all 279 changed slides in 35 paired sheets and six full-size pairs; historical baselines remain retained. See
|
|
747
|
+
Version 0.8.0 preserves scalar spaces, literal tabs and exact hard-line source ranges across core layout and SVG. Explicit tab positions and whitespace-preserving SVG text prevent source collapse. Its separate 805-slide checkpoint follows review of all 279 changed slides in 35 paired sheets and six full-size pairs; historical baselines remain retained. See the review and bounds. Estimated wrapping/advances, multilingual shaping and native Office remain separate gates.
|
package/dist/chart-options.js
CHANGED
|
@@ -90,8 +90,10 @@ export function labelString(c, { category, value, share, format, group }) {
|
|
|
90
90
|
const labels = c.dataLabels;
|
|
91
91
|
const parts = {};
|
|
92
92
|
if (category !== undefined && category !== null) parts.category = String(category);
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
// LH-106: the value and the percentage are in the numbering system of the deck (or slide) language.
|
|
94
|
+
const language = typeof c.language === "string" ? c.language : undefined;
|
|
95
|
+
if (typeof value === "number" && Number.isFinite(value)) parts.value = format !== undefined ? formatDataNumber(value, format, language) : formatChartLabelNumber(value, group ? { language } : undefined, language);
|
|
96
|
+
if (typeof share === "number" && Number.isFinite(share)) parts.percent = formatChartLabelPercent(share, language);
|
|
95
97
|
return chartLabelText(parts, labels.content, labels.separator);
|
|
96
98
|
}
|
|
97
99
|
|