kumiori 0.5.0 → 0.6.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.
Files changed (162) hide show
  1. package/CHANGELOG.en.md +32 -0
  2. package/CHANGELOG.md +32 -0
  3. package/README.en.md +2 -1
  4. package/README.md +2 -1
  5. package/THIRD_PARTY_NOTICES.md +2232 -7
  6. package/dist-browser/THIRD_PARTY_NOTICES.md +2232 -7
  7. package/dist-browser/chunks/{UTIF-KG0m1IdM.js → UTIF-CB7QpC03.js} +4 -4
  8. package/dist-browser/chunks/bg-BHkWBdmK.js +16 -0
  9. package/dist-browser/chunks/ca-CLlkRkVU.js +18 -0
  10. package/dist-browser/chunks/callContext-B0aKFxzs.js +98 -0
  11. package/dist-browser/chunks/{ccitt-VTTPFdAq.js → ccitt-zKTiYBne.js} +203 -328
  12. package/dist-browser/chunks/{cgm-ConNL6R-.js → cgm-BYXND-Lt.js} +508 -505
  13. package/dist-browser/chunks/cy-BY4_JDK8.js +20 -0
  14. package/dist-browser/chunks/da-CsG7AHvT.js +20 -0
  15. package/dist-browser/chunks/de-1901-DSuSYjhi.js +20 -0
  16. package/dist-browser/chunks/de-1996-B77PsMmO.js +20 -0
  17. package/dist-browser/chunks/de-ch-1901-BCOLXvd-.js +20 -0
  18. package/dist-browser/chunks/el-monoton-B_TpVuH7.js +20 -0
  19. package/dist-browser/chunks/en-gb-Cqb1Ks_t.js +20 -0
  20. package/dist-browser/chunks/en-us-B3tVDBHW.js +10 -0
  21. package/dist-browser/chunks/{eps-Dngej5a8.js → eps-B_0j0eX4.js} +1617 -1614
  22. package/dist-browser/chunks/epsInfo-BAniBFe7.js +33 -0
  23. package/dist-browser/chunks/es-BC8rc6n4.js +20 -0
  24. package/dist-browser/chunks/{sniff-CYNZW-f9.js → es-BXkrL5AZ.js} +2259 -2298
  25. package/dist-browser/chunks/{esm-BwQHdGL5.js → esm-1L_VrSzb.js} +4 -4
  26. package/dist-browser/chunks/{esm-Bur2GgqP.js → esm-B9N-jNux.js} +3 -3
  27. package/dist-browser/chunks/et-FQX9D5Tv.js +20 -0
  28. package/dist-browser/chunks/eu-CADvIbQb.js +39 -0
  29. package/dist-browser/chunks/{export-contract-Dizj1UsO.js → export-contract-BbbwqBzG.js} +3 -3
  30. package/dist-browser/chunks/fi-BIkMpMfd.js +9 -0
  31. package/dist-browser/chunks/fr-CBFdzRvP.js +20 -0
  32. package/dist-browser/chunks/ga-DJaPfnhm.js +20 -0
  33. package/dist-browser/chunks/gl-DGevCHr4.js +9 -0
  34. package/dist-browser/chunks/hr-bftpeWZg.js +40 -0
  35. package/dist-browser/chunks/hu-8HD8lzAY.js +96365 -0
  36. package/dist-browser/chunks/imageInfo-Dr3-_PDq.js +136 -0
  37. package/dist-browser/chunks/imageLimits-BNE4vKzW.js +778 -0
  38. package/dist-browser/chunks/is-cTsI-jVB.js +18 -0
  39. package/dist-browser/chunks/it-B2LlJQmC.js +20 -0
  40. package/dist-browser/chunks/la-D9Xb8xYk.js +20 -0
  41. package/dist-browser/chunks/{load-Cb6TEIjm.js → load-DdrxdcBX.js} +3575 -2457
  42. package/dist-browser/chunks/lt-CVoaZiBe.js +20 -0
  43. package/dist-browser/chunks/{matrix-C-5rhIt0.js → matrix-B5FnADSk.js} +2 -2
  44. package/dist-browser/chunks/{metafile-CnBftNGE.js → metafile-DptHG7TB.js} +573 -572
  45. package/dist-browser/chunks/nb-BUmdhV6O.js +17 -0
  46. package/dist-browser/chunks/nl-CjmaftXs.js +20 -0
  47. package/dist-browser/chunks/{pako-uucVXsP5.js → pako-GQeNQtI7.js} +4 -4
  48. package/dist-browser/chunks/pixels-6XFJVQ7a.js +411 -0
  49. package/dist-browser/chunks/pl-CIdOeNJN.js +20 -0
  50. package/dist-browser/chunks/{epsInfo-DpkWEFcD.js → psFilters-B5cwwBCH.js} +4 -29
  51. package/dist-browser/chunks/pt-B_XiZgDR.js +35 -0
  52. package/dist-browser/chunks/{rolldown-runtime-DMd8KBjB.js → rolldown-runtime-BgYtpjgF.js} +2 -2
  53. package/dist-browser/chunks/ru-D59C1Hnv.js +18 -0
  54. package/dist-browser/chunks/sh-cyrl-OIQoxj7t.js +18 -0
  55. package/dist-browser/chunks/sh-latn-Ch7jGS2Z.js +18 -0
  56. package/dist-browser/chunks/sk-B9t8mYnS.js +20 -0
  57. package/dist-browser/chunks/sl-BIcTOy-o.js +20 -0
  58. package/dist-browser/chunks/sniff-DkrGZ2aV.js +45 -0
  59. package/dist-browser/chunks/{strokeOutline-DSM8B9ds.js → strokeOutline-l2xN2FSn.js} +37 -37
  60. package/dist-browser/chunks/sv-CAQHcWz1.js +18 -0
  61. package/dist-browser/chunks/tr-CXyCGZVy.js +18 -0
  62. package/dist-browser/chunks/uk-BPNl3LhJ.js +20 -0
  63. package/dist-browser/kumiori.js +18616 -14961
  64. package/dist-cli/THIRD_PARTY_NOTICES.md +2232 -7
  65. package/dist-cli/assets/callContext-DjdP5mw2.js +175 -0
  66. package/dist-cli/assets/{cgm-KDeQnQKd.js → cgm-BghxgcD_.js} +11 -10
  67. package/dist-cli/assets/{drawioPin--INN4wXl.js → drawioPin-D4FbRxne.js} +3 -3
  68. package/dist-cli/assets/{drawioStencil-BfKkpoEe.js → drawioStencil-BSMGOn9D.js} +9 -8
  69. package/dist-cli/assets/{eps-OJOdWnxf.js → eps-DYToaw7H.js} +25 -23
  70. package/dist-cli/assets/epsInfo-BYw7E7_Q.js +65 -0
  71. package/dist-cli/assets/imageLimits-CJwrsFd4.js +1106 -0
  72. package/dist-cli/assets/{load-DKJw5pc8.js → load-Bo3ySXQb.js} +72 -28
  73. package/dist-cli/assets/{metafile-0xNymmpL.js → metafile-BhJ2ragE.js} +7 -7
  74. package/dist-cli/cli.js +6783 -1220
  75. package/dist-lib/THIRD_PARTY_NOTICES.md +2232 -7
  76. package/dist-lib/{api-BCRMQoJy.js → api-AFNmZl7M.js} +15170 -11564
  77. package/dist-lib/callContext-B0aKFxzs.js +98 -0
  78. package/dist-lib/{cgm-GzRHYfjQ.js → cgm-B7nKv2jt.js} +512 -511
  79. package/dist-lib/{eps-wXi2WEGi.js → eps-CSf22yLI.js} +1662 -1661
  80. package/dist-lib/epsInfo-BAniBFe7.js +33 -0
  81. package/dist-lib/imageInfo-gS8ZraZD.js +136 -0
  82. package/dist-lib/imageLimits-BNE4vKzW.js +778 -0
  83. package/dist-lib/index.js +882 -11
  84. package/dist-lib/{load-Dkw362LJ.js → load-CVKiKdwi.js} +3001 -2968
  85. package/dist-lib/{metafile-21bqsyGl.js → metafile-C98crjki.js} +592 -592
  86. package/dist-lib/node.js +1254 -47
  87. package/dist-lib/types/api.d.ts +100 -12
  88. package/dist-lib/types/assets.d.ts +21 -0
  89. package/dist-lib/types/callContext.d.ts +87 -0
  90. package/dist-lib/types/canvasRenderer.d.ts +11 -4
  91. package/dist-lib/types/colorGlyph.d.ts +1 -16
  92. package/dist-lib/types/cssCascade.d.ts +7 -12
  93. package/dist-lib/types/cssSelector.d.ts +9 -0
  94. package/dist-lib/types/cssUnsupported.d.ts +26 -2
  95. package/dist-lib/types/diagnostics.d.ts +1 -1
  96. package/dist-lib/types/documentResources.d.ts +2 -5
  97. package/dist-lib/types/drawio/drawio.d.ts +16 -1
  98. package/dist-lib/types/drawio/drawioXml.d.ts +1 -1
  99. package/dist-lib/types/drawio/load.d.ts +2 -0
  100. package/dist-lib/types/epsInfo.d.ts +0 -8
  101. package/dist-lib/types/foMathFallback.d.ts +0 -7
  102. package/dist-lib/types/fontKind.d.ts +29 -0
  103. package/dist-lib/types/fontLoader.d.ts +5 -0
  104. package/dist-lib/types/fontManager.d.ts +99 -2
  105. package/dist-lib/types/fontMapping.d.ts +6 -0
  106. package/dist-lib/types/gradientStops.d.ts +15 -0
  107. package/dist-lib/types/gridTracks.d.ts +2 -0
  108. package/dist-lib/types/htmlImport.d.ts +6 -0
  109. package/dist-lib/types/htmlPaged.d.ts +10 -0
  110. package/dist-lib/types/htmlPrepare.d.ts +1 -0
  111. package/dist-lib/types/hyphenation.d.ts +19 -2
  112. package/dist-lib/types/iccRegistry.d.ts +19 -0
  113. package/dist-lib/types/imageFormats.d.ts +6 -0
  114. package/dist-lib/types/imageInfo.d.ts +8 -0
  115. package/dist-lib/types/imageLimits.d.ts +23 -6
  116. package/dist-lib/types/index.d.ts +4 -1
  117. package/dist-lib/types/inlineLayout.d.ts +11 -9
  118. package/dist-lib/types/languageTag.d.ts +28 -0
  119. package/dist-lib/types/layoutEngine.d.ts +328 -3
  120. package/dist-lib/types/limits.d.ts +575 -0
  121. package/dist-lib/types/linkPolicy.d.ts +3 -3
  122. package/dist-lib/types/lnode.d.ts +4 -0
  123. package/dist-lib/types/mathContent.d.ts +0 -5
  124. package/dist-lib/types/mathLayout.d.ts +0 -11
  125. package/dist-lib/types/messages.d.ts +4 -15
  126. package/dist-lib/types/node.d.ts +3 -0
  127. package/dist-lib/types/nodeSystemFonts.d.ts +95 -0
  128. package/dist-lib/types/pageRaster.d.ts +11 -22
  129. package/dist-lib/types/paint.d.ts +16 -0
  130. package/dist-lib/types/pdfFlatten.d.ts +0 -23
  131. package/dist-lib/types/pdfImage.d.ts +105 -0
  132. package/dist-lib/types/pdfImageEmbed.d.ts +97 -0
  133. package/dist-lib/types/pdfPageLabels.d.ts +20 -0
  134. package/dist-lib/types/pdfRenderer.d.ts +34 -5
  135. package/dist-lib/types/pdfStandard.d.ts +23 -3
  136. package/dist-lib/types/pdfStreamGuard.d.ts +44 -0
  137. package/dist-lib/types/pdfTags.d.ts +8 -1
  138. package/dist-lib/types/pdfxVerify.d.ts +2 -2
  139. package/dist-lib/types/pixels.d.ts +1 -1
  140. package/dist-lib/types/psGraphics.d.ts +0 -9
  141. package/dist-lib/types/psInterp.d.ts +0 -8
  142. package/dist-lib/types/resources.d.ts +6 -0
  143. package/dist-lib/types/snapshot.d.ts +91 -0
  144. package/dist-lib/types/snapshotCss.d.ts +57 -0
  145. package/dist-lib/types/svg.d.ts +15 -0
  146. package/dist-lib/types/svgFilterRaster.d.ts +10 -16
  147. package/dist-lib/types/svgRenderer.d.ts +41 -5
  148. package/dist-lib/types/tableLimits.d.ts +0 -16
  149. package/dist-lib/types/types.d.ts +102 -1
  150. package/dist-lib/types/xmlParse.d.ts +7 -0
  151. package/dist-lib/types/xslfoImport.d.ts +9 -1
  152. package/package.json +7 -4
  153. package/dist-browser/chunks/el-monoton-RX3dXQyi.js +0 -684
  154. package/dist-browser/chunks/en-gb-CWSEx_aY.js +0 -13027
  155. package/dist-browser/chunks/en-us-DAXlLA12.js +0 -9109
  156. package/dist-browser/chunks/la-I5rV_oNf.js +0 -548
  157. package/dist-browser/chunks/pixels-CmBhR0Gf.js +0 -714
  158. package/dist-browser/chunks/ru-DZuNnLHw.js +0 -9694
  159. package/dist-browser/chunks/uk-Dy8Pyatw.js +0 -6134
  160. package/dist-cli/assets/pixels-KdRNvKJI.js +0 -1286
  161. package/dist-lib/epsInfo-DpkWEFcD.js +0 -565
  162. package/dist-lib/pixels-CmBhR0Gf.js +0 -714
package/CHANGELOG.en.md CHANGED
@@ -4,6 +4,38 @@
4
4
 
5
5
  Version numbers follow [Semantic Versioning](https://semver.org/). During 0.x, incompatible changes may also be released in a minor version (such as 0.2.0).
6
6
 
7
+ ## 0.6.0 (2026-11-23)
8
+
9
+ - **Typesetting a page built by JavaScript, by turning it into text in the browser window** (new API function `snapshotDocument`, available from `kumiori` and `kumiori/browser`; it works only where there is a DOM and a rendered page (a browser window); the typeset result does not change): Kumiori does not run JavaScript, but a page whose content JavaScript builds (charts, Web Components, CSS-in-JS screens, etc.) can now be typeset by turning the document as JavaScript left it into text. `snapshotDocument(document, options)` waits for the document load, the font loading, the page's own signal (`waitFor`) and rendering to settle (up to `timeoutMs` in all; 10 seconds by default), picks up what `outerHTML` loses, and returns `{ html, options, baseUrl, diagnostics, warnings }`, which can be typeset as is with `typeset(snap.html, { ...snap.options })`. What it picks up: the drawing of canvases (turned into PNG and replaced with `img`), rules added through the CSSOM (`insertRule`; the source text of `<style>` is kept), constructed stylesheets (`adoptedStyleSheets`), Shadow DOM (expanded into the flat tree, with the shadow tree's styles applied only inside it; closed roots only when passed in `shadowRoots`), the current values of forms (written back to attributes; passwords and hidden values are not written), the content of blob: URLs, fonts added by JavaScript (obtained through `fontSources`), relative URLs (made absolute against the document base, with references into the document kept in the `#` form) and the image chosen by `srcset`. `<script>`, event handlers, `javascript:` URLs (including those hidden with spaces or control characters, and SVG animations that change `href` to `javascript:`), document `data:` URLs of `<iframe>`, `<object>` and `<embed>`, `<noscript>` and comments are removed (inside `<template>` too), and `</style` inside the text of a `<style>` is escaped, so that no elements are injected when the copy is parsed again. What could not be taken is reported with new `snapshot/…` diagnostics (9 warnings). The limits are `limits` (`imagePixels`, `fileBytes`, and `snapshotBytes`, which is for snapshots only; 512MB by default). See "Typesetting a page built by JavaScript" in [`docs/en/library.md`](docs/en/library.md)
10
+ - **Page SVG output now has links** (`renderPageToSvg` in the API, `--format svg` in the CLI; **compatibility changes**: the SVG of a document with links gets `a` elements and elements carrying the destination ids; new option `RenderPageSvgOptions.pageHref`; the typeset result, the PDF and PNG output do not change): links on the pages (HTML `a`, XSL-FO `fo:basic-link`) and links inside SVG images (SVG 2 `a` elements) become SVG `a` elements. Links leaving the document are written only when they pass the same link rules as the PDF (`links`, `--link-schemes`, `--link-launch`, `--link-relative`); the others (by default `javascript:`, `data:`, `ftp:` and so on) are not written and a warning is given (`link/action-dropped`). URLs are escaped as XML attributes. A link on a page is a transparent rectangle over the link area, on top of the page content. A destination within the document becomes `#id` on the same page; a link to another page is written as `<URL>#id` in the API only when `pageHref` (a function that takes a page number and returns the URL of that page's SVG) is given (otherwise it is not written), and in the CLI it uses the file name that page is written to (`book-3.svg#id`). The destination id is put on an unpainted rectangle covering that page in its SVG (ids made inside the output avoid the document's ids). When the written SVG is shown with `img`, browsers do not let its links be followed (they can be when it is opened directly or put straight into HTML). Up to 0.5.0, no links were written.
11
+ - **Page SVG and PNG output now also chooses `switch` children in SVG images by `svgLanguages` and draws the content of `foreignObject`** (`renderPageToSvg` and `renderPageToPng` in the API, `--format svg|png` in the CLI; **SVG and PNG output changes** for documents with SVG images that use `switch` or `foreignObject`; the typeset result and the PDF do not change): when SVG images are turned into shapes, `systemLanguage` (SVG 2 §5.6.5) is matched against `svgLanguages` (`--svg-lang`) as in the PDF (a language given where the image is placed wins), and the content of `foreignObject` (SVG 2 §23.2; HTML and MathML) is typeset like the body text and drawn. In 0.5.0 the runtime language was used and only the text of `foreignObject` was approximated (the caveat noted for 0.5.0).
12
+ - **PDF as images** (`<img src="a.pdf">`, `fo:external-graphic`. **Typesetting results change** only for documents that refer to a PDF as an image; before, a "missing image" placeholder was drawn): a page of a PDF is read as an image and embedded in PDF output as a Form XObject, staying vector. The page is chosen with `#page=N` (RFC 8118), the size is the CropBox (clipped to the MediaBox), and `/Rotate` and `UserUnit` are applied. The Antenna House extensions (page ranges, `bbox=`, `page=` in data: URIs) are read only in compatibility mode, and only the first page of a range is placed. Annotations, bookmarks and the structure tree are not carried over (the MCIDs of marked content and the `StructParents` of XObjects are removed, including those of Form XObjects and the like in the resources). Screen, SVG and PNG output draw a placeholder frame (`image/pdf-placeholder`). With PDF/X, PDF/A and PDF/UA-1, each page is checked before it is embedded, and pages that do not meet the requirements (in PDF/A, also pages with optional content) are not placed and are reported (the whole document no longer fails). New limits `pdfImageObjects`, `pdfImagePages`, `pdfImageDepth`, `pdfImageStreamBytes`, `pdfImageLoadMs` (compressed streams, including object streams, cross-reference streams and streams in the resources, are limited in size and time before and while they are decompressed; streams in the resources are copied as the bytes decompressed within the limits, compressed again), and new diagnostics `image/pdf-*`, `pdfx/embedded-pdf`, `pdfa/embedded-pdf`, `pdfua/embedded-pdf` ("PDF images" in [`docs/en/library.md`](docs/en/library.md))
13
+ - **More languages for hyphenation** (HTML and XSL-FO. **Typesetting results change**: only for documents that use hyphenation (`hyphens: auto`, `hyphenate="true"`) in the added languages, and XSL-FO documents with hyphenation whose `language` is an ISO 639-2 three-letter code or whose `country` is an ISO 3166 three-letter or three-digit code): rules (hyph-utf8 patterns, from the hyphen dependency) were added for German (reformed orthography; also the traditional orthography `de-1901` and the Swiss traditional orthography `de-CH-1901`), French, Spanish, Italian, Portuguese, Dutch, Polish, Danish, Swedish, Norwegian (`nb`, `nn`, `no`), Finnish, Hungarian, Slovak, Slovenian, Croatian, Serbian (Latin and Cyrillic script), Bulgarian, Estonian, Lithuanian, Irish, Welsh, Catalan, Galician, Basque, Icelandic and Turkish. The rules are loaded only when a document using the language is opened. Czech, Latvian, Romanian, Indonesian and Macedonian are not hyphenated, because the available rules are under licences that do not fit (GPL or LGPL only) or have no licence statement (the same as a language without resources in CSS Text 3 §5.3). Language tags (BCP 47) are read as language, script, region and variants, and rules are not applied when the script differs from the script of the rules (such as `ru-Latn`). XSL-FO documents whose `language` is a three-letter code (`eng`, `deu`, `rus` and so on; XSL 1.1 allows ISO 639-2) were not hyphenated; this was fixed. Three-letter and three-digit `country` codes (`GBR`, `826` and so on; XSL 1.1 §7.10.1 allows ISO 3166 codes) are also read as the two-letter region (`GB`) (before, `language="en" country="GBR"` was hyphenated with American rules as `en` without a region, and the language in tagged PDF was written as `en-GBR`). For the added languages whose rules are made to leave 3 letters at the end of a word (Portuguese, Slovak, Irish, Welsh and Estonian), 3 letters are left at the end when `hyphenate-limit-chars` does not give the numbers before and after the break. The browser build (`dist-browser/`) puts the rules in a separate file per language and minifies them except for Hungarian (`kumiori.js` does not grow). The copyright and licence notices of each set of rules are at the top of its file and in section 1.4 of `THIRD_PARTY_NOTICES.md` (Hungarian is under the MPL 1.1, Swedish and some others under the LPPL 1.3c, and the others under MIT, BSD and similar permissions)
14
+ - **Structure and reading order of inline absolutely positioned elements in tagged PDF** (HTML; **PDFs change** for tagged PDF (the default) with an absolutely or fixed positioned element inside a paragraph with text or inside an inline element; the page appearance does not change): an inline absolutely positioned element such as `<p>before<span style="position: absolute">abs</span>after</p>` had no structure element, so its text was direct text of the parent paragraph in drawing order (after the paragraph's text). It is now a Span structure element placed among the parent's text where it is written (the reading order is document order; ISO 32000-1 §14.8.2.3), and the paragraph's marked content is split there. A zero-width marker box is placed where the element is written (line break opportunities, line heights and glyph positions do not change; in the Area Tree, the inline area of the text is split there and the marker box is added)
15
+ - **Words across lines when tagged PDF is read in structure order** (HTML and XSL-FO; **PDFs change** for tagged PDF (the default) with lines broken at a space or by hyphenation; the page appearance does not change, and untagged PDF does not change): when the text was read in structure order (read aloud, exported to another format, and so on), the last word of a line and the first word of the next line ran together with no space (`documentation` + `characteristically` → `documentationcharacteristically`), and a hyphen added at the end of a line by hyphenation was read as a hyphen inside the word (`inter-national`). Now a line broken at a space gets the space removed at the end of the line, written as an invisible character after its last character (ISO 32000-1 §14.8.2.5: word breaks are represented by space characters), and a hyphenation hyphen gets a soft hyphen (U+00AD) as the replacement text (`ActualText`, §14.9.4) of its marked content (the marked content of the structure element is split at the hyphen). The characters of the Area Tree (`GlyphArea`) also get `hyphen`, a mark for a character added by hyphenation, and `breakSpace`, the space removed at the end of the line (the Area Tree JSON changes)
16
+ - **PDF/X output intents and output ICC profiles** (output that is not PDF/X does not change; **compatibility changes**: some inputs that produced a PDF before are now errors; **PDFs change**: the PDF/X output intent when only a profile is given): (1) PDF/X-3 now also reports an error (`pdfx/profile-required`) when the printing condition (`pdfx.condition`, `--output-condition`) is not in the ICC registry and no output ICC profile (`pdfx.profile`, `--output-profile`) is given (the same rule as PDF/X-1a; ISO 15930-1 §6.3.2). Before, it wrote an output intent with neither RegistryName nor DestOutputProfile, which does not identify the printing condition. The check after writing applies the same rule to the X-3 output intent. A profile given for X-3 must be CMYK (this was not checked before). (2) When only a profile is given and no printing condition name, the name was JC200103 (the registry name of Japan Color 2001 Coated) and the registry (RegistryName) was written; now the profile's description (the text of its desc tag) is the name (OutputConditionIdentifier, OutputCondition and Info) and RegistryName is not written (so the PDF does not claim a printing condition other than the embedded profile's). For the previous output intent, give `condition: 'JC200103'` or `--output-condition JC200103`. With neither a profile nor a name, it is JC200103 as before. (3) The output ICC profile is now checked up to its header and tag table, not just the color space and device class in the header (ICC.1:2010 §7.2 and §7.3: the profile size in the header, `acsp`, the tag count and the offset and size of each tag's data, and the desc description tag that every profile needs (§8.2)); otherwise it is an error (`pdfx/profile-invalid`). Before, a 144-byte header with only tag signatures was accepted
17
+ - **PDF page labels** (XSL-FO and HTML; **PDFs change** for documents with a non-decimal page number format or renumbered pages; the typeset pages do not change): the page numbers a viewer shows now follow the page numbers on the page (`/PageLabels` in the catalog; ISO 32000-1 §12.4.2). Before, a viewer showed consecutive numbers from 1 even for documents whose front matter is numbered i, ii and whose body starts again at 1. The format comes from the `format` and `initial-page-number` of the XSL-FO `fo:page-sequence`, and from the type of `counter(page, <type>)` in CSS margin boxes and `page` in `counter-reset` and `counter-set`; a new range starts where the format changes or the numbers do not continue. Pages whose numbers PDF cannot write with the same characters as on the page (decimal, Roman numerals and letters), such as kanji numerals, circled numbers, full-width or zero-padded digits, Roman numeral characters, letters that differ from PDF's (ab on page 28, for example) and numbers of 0 or less, are written page by page with the same characters as on the page. The characters around the number (the "-" of "- 1 -") are not included. Documents numbered in decimal from 1 throughout get no page labels. `page` in the area tree gets `pageNumberFormat`, the format of non-decimal pages ([`docs/en/area-tree.md`](docs/en/area-tree.md), "Page numbers")
18
+ - **Nested list content no longer goes one block per page at page ends, leaving runs of nearly empty pages** (HTML and XSL-FO; **typesetting results change** for documents whose nested lists (`ul > li > ul > li`, nested `fo:list-block`) cross a page): when the text and paragraphs (blocks) in a nested list item reached the end of a page, each following page took only one block before moving on to the next, leaving runs of pages with a few lines (this happened in ordinary documents with two levels of nesting; the bug predates 0.4.0 and is not a regression). Lists are laid out as tables with a marker column and a body column, and a nested list becomes a table inside the body of the outer item. When the outer item was split across pages, the height of the continuation of the inner item was taken from what was left on the page holding the outer item, not from the height of the next page. Continuations now fill the height of the next page (XSL 1.1 §6.8 and §4.8, CSS 2.1 §13.3.5). Example: an A5 document that took 5 pages (body lines 33, 1, 3, 1, 3) now takes 2 (33, 8). The random nested documents (nest and fonest from `scripts/gen-stress-docs.mjs`) at size 300 went from 29 to 16 pages and from 30 to 16 pages
19
+ - **The PDF creation and modification dates can be given** (`PdfOptions.date` in the API, the `SOURCE_DATE_EPOCH` environment variable on the command line; without them the PDF does not change): the time given as `date` (a `Date`) to `toPdf`, `typesetToPdf` and the typesetter's `typesetToPdf` is written as the PDF creation and modification dates (`CreationDate` and `ModDate` in Info, and `xmp:CreateDate`, `ModifyDate` and `MetadataDate` in the XMP of PDF/X, PDF/A and PDF/UA) and as the modification date of PDF/A-3 attached files (`ModDate` in `Params`), dropping anything below a second. Before, all of them were the time of typesetting. The command reads the `SOURCE_DATE_EPOCH` environment variable (the reproducible-builds.org specification: an integer number of seconds since 1970-01-01 UTC); a value that does not follow the specification is an error (exit status 1). An invalid `Date` or a time outside the years 0 to 9999 is a `KumioriOptionError` (`option` is `date`)
20
+ - **The same input gives the same PDF bytes** (**PDFs change**: the bytes of the document ID change in every PDF; the appearance and the text do not): the document ID (`ID` in the trailer, and `xmpMM:DocumentID` and `InstanceID` in the XMP of PDF/X, PDF/A and PDF/UA) is made from the SHA-256 of the written PDF instead of random numbers (the same contents give the same ID). `random` in the glyph programs of PostScript fonts (CFF inside EPS) uses random numbers from a fixed seed for each glyph, and PostScript `realtime` is made from the number of interpreter steps instead of the clock. With `date` (`SOURCE_DATE_EPOCH` on the command line), the same version of Kumiori gives the same PDF bytes for the same input, fonts and settings
21
+ - **An option to set characters no font has a glyph for in OS fonts** (API `systemFonts`, command `--system-fonts`; a new option, off by default; typesetting is unchanged without it): characters for which none of the default fonts nor the symbol and emoji fonts has a glyph are looked up in the OS font locations (the font folders on Windows and macOS; on Linux and others, the `<dir>` entries of the fontconfig configuration) and set in the font found (the user agent's system font fallback of CSS Fonts 4 §5.2). In the library, pass `createSystemFonts()` from `kumiori/node` as `systemFonts` (a `createTypesetter` option). Only those characters are set in OS fonts; the fonts and positions of other characters do not change. Characters in a serif (Mincho) context prefer a serif font and those in a sans-serif (Gothic) context a sans-serif one (the kind comes from the OS/2 PANOSE and sFamilyClass and from the name), falling back to fonts of the other kind. Only the kinds of font the document needs are loaded (a sans-serif font is not loaded for characters that appear only in a serif context). Only the tables needed (the character map `cmap` and a few others) are read from each font file to build the index (once per finder), and fonts that cannot be embedded in PDF (OS/2 `fsType`) are not used. A document's `font-family` cannot name an OS font. The OS fonts used are reported after typesetting, with the characters set in each, by the notice `font/system-fallback`, and fonts not used because they cannot be embedded by the warning `font/system-font-not-embeddable`. The number of OS fonts used in one document is capped by the limit `systemFontFaces` (default 16). `dirs` of `createSystemFonts` must be an array of strings (other values are a `TypeError`; relative paths are resolved against the current directory when the finder is created). `systemFonts` is a container option: like the other container options, it is not used when passed in the per-document options of `typesetter.typeset` (`api/setup-option-ignored`). The result depends on the fonts of the machine and the PDF reveals which fonts the machine has, so do not use it for documents written by others (on the command line, combining it with `--no-outside-files` is an error). On the command line, when characters have no glyph and `--system-fonts` is not given, a note that `--system-fonts` can look for them is added after the diagnostics
22
+ - **Placement of floats and absolutely positioned boxes written within lines in HTML** (HTML, in every style; **typesetting results change** for documents with a float written in the middle of a paragraph, an absolutely positioned box without a positioned ancestor whose top or left is auto, or a float inside a flex item): (1) a float written in the middle of a paragraph (`float: left`, `right` and so on, including one inside an inline element) is placed on the line where it is written (CSS 2.1 §9.5.1, rules 6 and 8). Before, it was placed at the start of the paragraph (on the first page for a paragraph that spans pages). A float that does not fit beside the content of that line before it is placed below that line. (2) a float inside an inline element that contains blocks (such as a `div` inside a `span`) is placed on the side where it is written (in the anonymous block, among those the inline element is split into before and after the blocks, that contains the place where the float is written; CSS 2.1 §9.2.1.1). In 0.5.0 it was placed after those blocks (the limitation noted in the 0.5.0 entry). (3) the content-based width (max-content) of a flex item now counts the width of floats inside it (CSS Flexbox 1 §9.2, CSS Sizing 3 §5). Before, it did not, and text that should fit beside the float was pushed to the next line. (4) for an absolutely positioned box (`position: absolute`) without a positioned ancestor, the directions where top and bottom, or left and right, are auto are placed at the static position (where the box would be if it were in the flow; CSS 2.1 §10.3.7, §10.6.4): a box between blocks goes below the preceding block, and a box within a line (including one inside an inline element) goes at the top of the line where it is found and at its position in the line. Before, they were placed at the top and left edges of the page's content area. Only boxes in the body flow of the page (horizontal writing, not multi-column) are placed at the static position; boxes inside multiple columns, in vertical documents and inside table cells, list items and flex items are not placed at the static position (as before, they usually go at the top left of the page's content area). The first line of the text inside the box is indented by the inherited `text-indent` (CSS Text 3 §8.1, as in browsers; this includes the default 1em indent of `p`). When typesetting in the browser (the web page), the browser's positions are used, as before
23
+ - **Laying out only the first N pages** (`maxPages` in the API, `--max-pages <N>` on the command line; without it, typesetting results do not change): to preview the first few pages of a long document, layout can now stop once the first N pages are laid out. When it stops, the result's `truncated` (`TypesetResult`, `TypesetPdfResult`; the layout tree gets `truncated: { maxPages }`) is `true`, and the info diagnostic `layout/max-pages-reached` is reported. Page number references to places after page N (`page-number-citation`, `target-counter()` and so on), the last page number of elements that continue after page N, and the total page count (`counter(pages)`, the total in running heads) cannot be resolved, so they are set as `"?"` (empty with `--style weasyprint`); index lists list only the places within the first N pages, and bookmarks pointing after page N have no destination. One `layout/beyond-max-pages` warning is reported for each kind. The layout of the kept pages is the same as for the whole document as long as their body text has nothing pointing after page N; if it has, the difference in width of those references can change line breaks (a table of contents with leaders rarely changes). Every layout pass stops at page N. Reading the document and the cascade are still done for the whole document, so what gets faster is laying out and writing the PDF. With a container (`createTypesetter`), a stopped document keeps what it remembered but does not advance the generation of the memory. See "Laying out only the first pages" in [`docs/en/library.md`](docs/en/library.md)
24
+ - **Development: before-and-after comparison and area tree fingerprint tests** (typesetting results do not change): added `npm run compare:base -- --base <commit>` (`scripts/compare-base.mjs`), which typesets the same documents with Kumiori at the commit before and after a change and lists the documents and pages whose typesetting changed. It checks out the two commits in temporary locations, builds the command for each, typesets the conformance documents, `examples` and `samples`, plus, when available locally, Antenna House's sample FO collection, the 4th edition of 『CSSページ組版入門』 and the WeasyPrint samples (earlier versions that cannot be given the date are run with the clock and random numbers frozen), and compares the PDF bytes, page counts, the text of each page (words and positions from pdftotext) and the image (pixels from pdftoppm), telling documents with identical bytes from those that only look the same, writing `report.md`, `report.json` and side-by-side images of before, after and the difference for the changed pages. Also, fingerprints (SHA-256) of the area trees of the conformance documents' samples and whole documents, and of the documents in `examples` and `samples/check`, are kept in `test/fingerprints/`, so that `npm test` fails and shows the changed pages when the typesetting changes. When the change is intended, rewrite them with `npm run fingerprints:update` (narrowed with `-t`, only the fingerprints of the documents typeset are rewritten and the others are kept; see "Comparing before and after" and "Area tree fingerprints" in `docs/en/development.md`)
25
+ - **Input limits can be changed with options** (`limits` in the API, `--limit <name>=<value>` and `--list-limits` on the command line; without them the typesetting results do not change): the limits that keep a small input from using up time and memory (image pixels, file sizes, fetch sizes, EPS time and memory, EPUB decompression, draw.io diagrams, table columns, formula glyphs, nesting depths, the work of writing PNG and others; 62 in all) can now be raised for large trusted documents and lowered to tighten a server. Any limit can be lowered; only time and size limits can be raised (nesting-depth limits are lower only; raising one is a `KumioriOptionError`, or an error on the command line). The defaults are unchanged. Raising a limit does not change the limits by file size (code density, decompression ratios). A raised limit is reported with the notice `limit/raised`. `limits` in the `createTypesetter` setup becomes the default for each document, and the typesetter does not reuse what it kept for a document with different limits. The `load` context of plugins gets a read-only `limits`. The names and defaults are in "Input limits" in [`docs/en/library.md`](docs/en/library.md) (the EPUB decompression limits are used only when the browser app reads an EPUB, with the default values there; the API and the command line do not read EPUB, so changing them has no effect). The security policy ([`SECURITY.en.md`](SECURITY.en.md)) treats using more than the set limits (lowered ones included) as a vulnerability, but not using a lot of time or memory within raised limits
26
+ - **Fewer pages and no runs of nearly empty pages in multi-column documents with many footnotes** (XSL-FO and HTML; **typesetting results change** for documents whose multi-column pages have footnotes at the bottom of the page): 0.5.0 changed the re-typesetting that decides the height of the footnote area on multi-column pages (the per-page reservation) to settle pages one by one from the front. In long multi-column documents with many footnotes, the front-to-back passes only got through the first few pages, and the remaining passes piled up reservations, so pages with only a few body lines and no footnotes appeared throughout the document, the page count grew by 40 to 50 percent over 0.4.0, and typesetting took more than twice as long (a regression in 0.5.0; the 0.5.0 change log says this re-typesetting reduced pages with only a few body lines, which was the opposite for such documents). The reservation is now decided during typesetting, at the start of each page: from the positions of the footnote references in the body flow of the previous pass (the amount of body text, independent of where the columns break), the footnotes that fall on the page and the height they need are estimated, and the smallest reservation that holds them is used. A page that starts at the same place keeps the reservation that fit in an earlier pass, and raises it if it did not fit. When the reservation of an earlier page changes and the body shifts, the reservations of later pages follow the shifted body, so typesetting usually settles in 2 to 4 passes. The same change fixes pages where the footnotes are more than fit on a page: the reservation used to swing up and down, settle on the larger value and leave nearly empty pages (present since 0.4.0). On a page with body text, the reservation leaves one and a half lines of body (a line with a footnote call can be taller than the line height; it was one line). In a randomly generated two-column document with many footnotes (3,000 body lines, 238 footnotes; mix3000a.html from `scripts/gen-column-footnotes.mjs`), 288 pages and 52 seconds just before this change (an unreleased version after 0.5.0) became 143 pages and 9 seconds (0.4.0: 204 pages, 26 seconds, and it dropped 56 footnote lines), and footnotes whose first part is on a different page from the reference went from 41 (0.4.0: 44) to 0. The layout of footnotes on multi-column pages (where footnotes split, the space between the body and the footnotes, and the number of pages) changes
27
+ - **A link from the app to the API reference** (app; typesetting results do not change): "API reference" (API の説明書) was added to the bar at the top of the app. It opens the list of the library's functions, types and options (`api/` under the app on GitHub Pages) in a new tab. On narrow screens, it is under "Other" (そのほか) in "Settings" (設定)
28
+ - **Faster re-typesetting of a slightly edited document** (the `createTypesetter()` container in the API; the layout result and the PDF do not change): the container remembers the preparation of `@font-face` font files (decompressing WOFF2, checking the tables) and the line breaking of paragraphs with the same content, style and width from the previous document, and reuses them for the next document. Re-typesetting while editing one paragraph at a time takes about 9 s instead of about 13 s for a 151-page HTML document, and about 3.2 s instead of about 4.1 s for a 103-page XSL-FO document (from the second or third re-typesetting, once the order of the fonts is the same; paragraphs containing inline boxes, images, footnotes or page number references are not reused). It uses memory for what it remembers (one previous document; at most about 400 MB); `createTypesetter({ reuse: false })` turns it off. In documents with many tables, the reuse can make re-typesetting the same document about 20 percent slower than in 0.5.0 (with `reuse: false` the speed is about the same as in 0.5.0)
29
+ - **Per-call message language** (API; typesetting results do not change): `TypesetOptions.lang` is now kept in a per-call context. `typeset` and container `typeset` calls with different `lang` values that run at the same time (without awaiting each other) each write warnings and error messages in their own language (before, the language of the call that started last applied while they overlapped; both in Node and in browsers). A call without `lang` keeps the language that was in effect when it started. Warnings from the result's `renderPage` (Canvas) are also written in the language of the typesetting call, as with `toPdf` (before, the default language at that moment)
30
+ - **A signal to stop typesetting, and progress** (new API options; nothing changes, including speed, unless they are passed; typesetting results do not change): `signal` (an AbortSignal) and `onProgress` for `typeset`, `typesetToPdf` and the container's `typeset` and `typesetToPdf`; `setup.signal` and `setup.onProgress` for `createTypesetter`; `signal` and `onProgress` for the result's `toPdf`; and `signal` for `renderPageToSvg` and `renderPageToPng`. When stopped, the returned Promise rejects with `signal.reason` (an `AbortError` `DOMException` if no reason was given). An already aborted signal fails before anything is read; the signal is checked each time a font or resource is read, and fetches in flight are stopped. `resolveResource` and `loadFont` receive `{ signal }` as a second argument (the fonts a container first loads when a document needs them (math, monospace, symbols and emoji) are shared with the other calls typesetting with the same container at the same time, so `loadFont` gets the timeout only, and a stopped call just stops waiting; the loads of the other calls do not fail). For `typesetToPdf`, the `signal` and `onProgress` of the typesetting options (`options`) apply through writing the PDF, and passing them in the PDF options (the third argument) throws `KumioriOptionError`. It is also checked each time a page is laid out and each time a PDF page is written, and progress reports the font (`fonts`), resource (`resources`), import (`import`), layout (`layout`; pass and page count) and PDF (`pdf`; pages written and total) phases. When they are passed, Kumiori pauses at layout pass, page-sequence and PDF page boundaries (it does not pause in the middle of laying out one page-sequence, so to stop there, stop inside `onProgress`). The container stays usable after a stop, and its cross-document memory does not count the stopped document as a generation. See "Stopping and progress" in [`docs/en/library.md`](docs/en/library.md)
31
+ - **Work and layer counting of PNG output** (PDF, SVG and the PNG of pages that do not reach the limits do not change): the color of a gradient with many color stops (a fine `repeating-linear-gradient` has about 4,000) was found by searching the stops from the start for each pixel; it now uses a binary search (40 such boxes on A4 at 300dpi took 16 seconds, now 1.4 seconds; a two-color gradient takes 0.9 seconds). The work count adds log2 of the number of stops per pixel for gradients with more than 16 stops. The limit on layers held at once (`pngLayerPixels`) now counts the layers of opacity groups and masks by the size they actually grow to, not by the area they may draw into when made (often the whole page; on large pages or at high resolutions, even shallow nesting of small opacity boxes reached the limit and overlaps inside were drawn darker). When growing the layer of an opacity group would exceed the limit, its contents so far are composited before drawing the rest. Fixed the contents of the outermost clip (such as inside an SVG opacity group) not being drawn when the count was near the limit. The note in the 0.5.0 documentation and SECURITY.md that the work of such gradients is not counted has been removed
32
+ - **Faster typesetting of long content inside nested tables and lists** (HTML and XSL-FO; typesetting results do not change): for a table inside a table cell (HTML lists are laid out as tables too), every time an outer level split a row across pages, the layout that measures the inner level's row height was redone, so a table at depth k was laid out k times (1.7 seconds for 4,000 `<p>` elements inside a list nested 16 levels deep). During one typesetting run, the height of each one-row layout is now remembered, and the measuring layout is skipped for rows that will be split across pages; the same document typesets in 0.6 seconds. A row that could not be split is no longer split again under the same conditions (in some places the number of attempts doubled at each nesting level). Rows whose layout leaves traces outside the table (markers, absolutely positioned boxes) are measured as before
33
+ - **Faster typesetting of documents with many subsequent-sibling combinator (`A ~ B`) rules** (HTML and SVG `<style>`; typesetting results do not change): matching walked back over every previous sibling of each element to find one that matches the left part of `~`, so the work grew as rules × elements × siblings (about 40 seconds for 4,500 `.cN ~ *` rules and 400 sibling `<p>` elements). During one cascade, the position of the first child matching each left part, and how far the children have been matched, are now remembered per parent, and the same document typesets in 1.4 seconds (about the same as the same number of next-sibling combinator `+` rules; Selectors 4 §16.4)
34
+ - **Diagnostics for CSS declarations with invalid values, XSL-FO import notes and reached limits** (HTML and XSL-FO; typesetting results and the PDF do not change; **compatibility changes**: diagnostics and exit codes. They are added to `warnings` and `diagnostics`, and the exit code with `--fail-on warning` (and with `--fail-on error` for `fo/master-reference-not-found`) on the command line changes): (1) Declarations of known CSS properties with invalid values (such as `display: foo`, `color: notacolor` or `margin: foo`, which CSS 2.1 §4.2 ignores as a whole) are reported with the new diagnostic `css/invalid-value` (a warning; args `property` and `value`). Before, they were dropped without a warning. Only declarations in author style sheets and `style` attributes are counted, one per "property: value". Values with `var()` or `attr()`, prefixed values (such as `-webkit-box`) and declarations with a readable declaration of the same property in the same rule (or `style` attribute; fallback values for browsers) are not counted. Values that are valid CSS but that Kumiori does not read (system font names such as `font: caption`, and `font-size: math`) are reported as `css/unsupported`, and extension values written on an unprefixed property that are read only with the compatibility option `--style ah` (such as `border-style: dot-dash`) are reported as `css/unsupported` ("a value read only with --style ah") when that option is not given. They are also shown in the app's conversion report. (2) XSL-FO import notes (approximations and defaults used instead: a too-large number of columns was capped, no region matches `flow-name` so the content was flowed into the body region, `axf:document-info name="title"`, which is not in the Antenna House documentation, and so on) were shown only in the app's conversion report. They are now also reported on the command line and in the API's `diagnostics` as the new diagnostic `fo/note` (a warning). When no page master matches the `master-reference` of an `fo:page-sequence`, typesetting ended with 0 pages and no message; it is now reported with the new diagnostic `fo/master-reference-not-found` (an error, since the content of that `page-sequence` is missing from the output; args `name`). (3) When the input limits (`limits`, `--limit`) are lowered, the places that cut the input without a diagnostic (grid track lists `gridTracks`, leaders of repeated characters `leaderRepeats`, selectors expanded from nested rules `nestedSelectors`, collected stylesheet and font references `styleRefs`, the depth of `@import` `importDepth`, `tableColumns` lowered below the HTML limit of 1,000 for the `span` of `col` and `colspan`, and `pdfImage*` for PDF images that were not drawn) now report the new diagnostic `limit/reached` (a warning; args `limit` and `value`), once per limit name per typesetting (limits reached during `toPdf`, `renderPageToSvg` and `renderPageToPng` of a result are added to its `warnings` and `diagnostics` afterwards). With the default limits, ordinary documents do not get it. (4) The warnings for an `fo:block-container` with `overflow="condense"` (`layout/condense-overflow`, `layout/condense-capped`, `layout/condense-height-unknown`) were not reported when the container was inside an inline box (`fo:inline-container`) or a footnote body (`fo:footnote-body`), because the layout that measures the content did not report warnings. They are now reported once each, as elsewhere. (5) The `args` of a diagnostic code are now the same wherever it is reported: `font/file-unreadable` always has `file` (the name of the file that could not be read), and also the font name `font` for `@font-face` (before, `@font-face` had only `font`). Font fetch errors (`KumioriFontError`, `font/load-failed`) always have `font`. `png/image-not-drawn` and `png/image-limit` have, for images inside SVG, the `src` of the SVG image that contains them (before, they had no `src`)
35
+ - **Empty values and `--watch` in the command** (command; typesetting results do not change. **Compatibility changes**: how empty values are treated): (1) an empty value (`''`; for comma-separated lists, also a value with no items) for an option that takes a file, directory or plugin path (`--font-dir`, `--font-cache`, `--font`, `--css`, `--base`, `--spot-colors`, `--output-profile`, `--drawio-stencils`, `--plugin`) or a name (`--ignore-warning`, `--output-condition`) is now an invalid value (exit code 1). Before, it was accepted and taken as the current directory (`--font-dir ''` read fonts from the current directory, `--base ''` resolved against the current directory) or as not given (`--css ''`, `--ignore-warning ''`) (`-o ''` became an error in 0.5.0). (2) `--watch` stopped re-typesetting from the second save made by writing a new file and renaming it over the old one, as editors do (Node's recursive `fs.watch` on Linux does not watch the file after the rename); this is fixed. On Linux, the input directory and each directory below it are now watched (including directories created later). (3) The warning for an unknown name given to `--ignore-warning` (`api/unknown-diagnostic-code`) now names `--ignore-warning`, not the API option (`diagnostics.ignore`). (4) The exit status section of the command guide now says that even with `--watch`, a plugin that cannot be loaded ends the run with exit code 1 without watching (before, it only said that `--watch` does not change the exit code)
36
+ - **Checked to run on Deno and Bun** (documentation and a development tool; layout results unchanged): the library (`kumiori`, `kumiori/node`, `kumiori/browser`) and the command were checked to run on Deno 2.9 and Bun 1.4, and what was checked is written in the README and in "Package entry points and requirements" of the guide. It also notes that the single browser file is the one to use where there is neither the Node API nor a DOM, such as Cloudflare Workers (not tried on Workers itself). Added `node scripts/check-runtimes.mjs`, which loads the packed package on Node, Deno and Bun.
37
+ - **A promise on API stability** (documentation; typesetting results do not change): the public API is divided into what is kept across versions (the entry functions, `TypesetResult`, the main options, error types and names, `kumiori/node`, the functions that walk the Area Tree) and what may change (the layout result, details of Area Tree fields, message wording, the internal structure of the output, new and experimental options), written with how they relate to `PLUGIN_API_VERSION` and `AREA_TREE_SCHEMA_VERSION` in "API stability" of the library guide. While the version is 0.x, even the stable parts may break compatibility in a minor version, and such changes are marked "**compatibility changes**" in the changelog.
38
+
7
39
  ## 0.5.0 (2026-11-22)
8
40
 
9
41
  - **Image warnings inside inline boxes and footnote bodies** (HTML and XSL-FO; typesetting results and PDF output do not change; **compatibility changes**: diagnostics and exit codes): 0.4.0 reported nothing for missing images (`image/not-found`, severity error), images that cannot be drawn (`image/unsupported`), images that can be drawn only in part (`image/partial`) and missing references inside SVG (`image/reference-not-found`) inside `inline-block`, `fo:inline-container` and footnote bodies (HTML `float: footnote`, `fo:footnote-body`), because the layouts that measure their content did not report warnings. They are now reported once each, as elsewhere. They are added to `warnings` and `diagnostics`, and the exit codes of `--fail-on error` (missing images) and `--fail-on warning` on the command line change
package/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@
4
4
 
5
5
  版の番号は [セマンティック バージョニング](https://semver.org/lang/ja/) に従います。0.x の間は、互換の無い変更も minor の版 (0.2.0 など) で出すことがあります。
6
6
 
7
+ ## 0.6.0 (2026-11-23)
8
+
9
+ - **JS が組み上げたページを、ブラウザの画面で文字にして組む** (API の新しい関数 `snapshotDocument`。`kumiori`・`kumiori/browser` から使え、DOM と画面のある所 (ブラウザの画面) だけで動く。組版の結果は変わらない): Kumiori は JS を動かさないが、JS で中身を作るページ (グラフ・Web Components・CSS-in-JS の画面など) を、JS が組み上げた後の文書を文字にして組めるようにした。`snapshotDocument(document, options)` は、文書の読み込み・書体の読み込み・ページの側の合図 (`waitFor`)・描画の落ち着きを待ってから (合わせて `timeoutMs`。既定 10 秒)、`outerHTML` では落ちるものを拾って `{ html, options, baseUrl, diagnostics, warnings }` を返し、`typeset(snap.html, { ...snap.options })` でそのまま組める。拾うもの: canvas の絵 (PNG にして `img` に置き換える)・CSSOM で足した規則 (`insertRule`。`<style>` の元の字は残す)・作ったスタイルシート (`adoptedStyleSheets`)・Shadow DOM (平らな木に展開し、影の木のスタイルをその中だけに当てる。閉じた根は `shadowRoots` で渡したものだけ)・フォームのいまの値 (属性に書き戻す。パスワード・hidden の値は書かない)・blob: の URL の中身・JS で足した書体 (`fontSources` でもらう)・相対の URL (文書の基準で絶対にし、文書の中を指す参照は `#` の形に残す)・`srcset` で選んだ画像。`<script>`・イベントの扱い手・`javascript:` の URL (空白・制御字で隠したものも。SVG のアニメーションで `href` を `javascript:` に動かすものも)・`<iframe>`・`<object>`・`<embed>` の文書の `data:` の URL・`<noscript>`・注釈は取り除き (`<template>` の中も)、`<style>` の字の中の `</style` は逃がして、写しを読み直したときに要素が差し込まれないようにする。取れなかったものは、新しい診断 `snapshot/…` (警告 9 種) で知らせる。上限は `limits` (`imagePixels`・`fileBytes` と、snapshot だけの `snapshotBytes`。既定 512MB)。説明は [`docs/library.md`](docs/library.md) の「JS が組み上げたページを組む」
10
+ - **ページの SVG の書き出しに、リンクを書く** (API の `renderPageToSvg`・コマンドの `--format svg`。**互換が変わる**: リンクのある文書の SVG に、`a` 要素と、飛び先の id の要素が入る。新しい選択肢 `RenderPageSvgOptions.pageHref`。組版の結果・PDF・PNG は変わらない): 本文のリンク (HTML の `a`・XSL-FO の `fo:basic-link`) と、SVG の画像の中のリンク (SVG 2 の `a` 要素) を、SVG の `a` 要素にする。外への飛び先は、PDF と同じリンクの決まり (`links`・`--link-schemes`・`--link-launch`・`--link-relative`) に通したものだけを書き、通さないもの (既定では `javascript:`・`data:`・`ftp:` など) は書かずに警告する (`link/action-dropped`)。URL は XML の属性としてエスケープする。本文のリンクは、リンクの領域の透明の矩形を、ページの中身の上に重ねる。文書の中の飛び先は、同じページなら `#id`、別のページは、API では `pageHref` (ページの番号を受けて、そのページの SVG の URL を返す関数) を渡したときだけ `<URL>#id` に書き (渡さなければ書かない)、コマンドでは、そのページを書くファイルの名前 (`book-3.svg#id`) にする。飛び先の id は、そのページの SVG の、ページの全体の塗らない矩形の id にする (書き出しの中で付ける id は、文書の id とぶつからないものにする)。書き出した SVG を `img` で載せたときは、ブラウザの決まりでリンクは押せない (そのまま開くか、HTML に直に入れたときに押せる)。0.5.0 まではリンクを書かなかった。
11
+ - **ページの SVG・PNG の書き出しでも、SVG の画像の `switch` を `svgLanguages` で選び、`foreignObject` の中身を描く** (API の `renderPageToSvg`・`renderPageToPng`、コマンドの `--format svg|png`。**SVG・PNG が変わる**: `switch`・`foreignObject` を使う SVG の画像を置いた文書。組版の結果・PDF は変わらない): SVG の画像を図形にするとき、PDF と同じく、`systemLanguage` (SVG 2 §5.6.5) を `svgLanguages` (`--svg-lang`) で照らし (置いた所の言語の指定が勝つ)、`foreignObject` (SVG 2 §23.2) の中身 (HTML・MathML) を本文と同じ組版で組んで描く。0.5.0 では、実行環境の言語で選び、`foreignObject` は中身の字だけを近似して描いていた (0.5.0 の説明に書いた断り)。
12
+ - **PDF を画像として貼る** (`<img src="a.pdf">`・`fo:external-graphic`。**組版の結果が変わる**: PDF を画像として指した文書だけ。前は「見つからない画像」の仮の枠): PDF のページを図として読み、PDF の出力には Form XObject としてベクタのまま埋め込む。ページは `#page=N` (RFC 8118)、大きさは CropBox (MediaBox に切り詰める)、`/Rotate`・`UserUnit` を見る。アンテナハウスの拡張 (ページの範囲・`bbox=`・data: の URI の `page=`) は互換の指定のときだけ読み、範囲は最初のページだけを貼る。注釈・しおり・構造の木は持ち込まない (資源の中の Form XObject なども含めて、印の付いた内容の MCID と XObject の `StructParents` を外す)。画面・SVG・PNG は仮の枠で描く (`image/pdf-placeholder`)。PDF/X・PDF/A・PDF/UA-1 では、埋め込む前にページを検査し、合わないページ (PDF/A では任意の内容を持つページも) は貼らずに知らせる (文書の全体を誤りにしない)。新しい上限 `pdfImageObjects`・`pdfImagePages`・`pdfImageDepth`・`pdfImageStreamBytes`・`pdfImageLoadMs` (圧縮した流れは、オブジェクトの流れ・相互参照の流れ・資源の中の流れも、解く前・解く間に大きさと時間で縛る。資源の中の流れは、縛りの中で解いたものを詰め直して写す)、新しい診断 `image/pdf-*`・`pdfx/embedded-pdf`・`pdfa/embedded-pdf`・`pdfua/embedded-pdf` ([`docs/library.md`](docs/library.md) の「PDF の画像」)
13
+ - **欧文の分綴の言語を足す** (HTML・XSL-FO。**組版の結果が変わる**: 足した言語で分綴 (`hyphens: auto`・`hyphenate="true"`) を使う文書と、`language` を ISO 639-2 の 3 字の符号で書いたか、`country` を ISO 3166 の 3 字・3 桁の数字の符号で書いた、分綴を使う XSL-FO の文書だけ): ドイツ語 (新正書法。`de-1901` の旧正書法と `de-CH-1901` のスイスの旧正書法も)・フランス語・スペイン語・イタリア語・ポルトガル語・オランダ語・ポーランド語・デンマーク語・スウェーデン語・ノルウェー語 (`nb`・`nn`・`no`)・フィンランド語・ハンガリー語・スロバキア語・スロベニア語・クロアチア語・セルビア語 (ラテン文字とキリル文字)・ブルガリア語・エストニア語・リトアニア語・アイルランド語・ウェールズ語・カタルーニャ語・ガリシア語・バスク語・アイスランド語・トルコ語の規則 (hyph-utf8 のパターン。依存の hyphen にあるもの) を足した。規則は、その言語を使う文書を開いたときだけ読む。チェコ語・ラトビア語・ルーマニア語・インドネシア語・マケドニア語は、使える規則のライセンスが合わない (GPL・LGPL だけか、ライセンスの表示が無い) ので、分綴しない (CSS Text 3 §5.3 の、資源の無い言語と同じ)。言語のタグ (BCP 47) は、言語・文字・地域・異形を分けて読み、文字が規則の文字と違えば当てない (`ru-Latn` など)。XSL-FO の `language` の 3 字の符号 (`eng`・`deu`・`rus` など。XSL 1.1 は ISO 639-2 を許す) で分綴しなかったのを直した。`country` の 3 字・3 桁の数字の符号 (`GBR`・`826` など。XSL 1.1 §7.10.1 は ISO 3166 の符号を許す) も、2 字の地域 (`GB`) に直して読む (前は、`language="en" country="GBR"` を、地域の無い `en` として米国式で分け、タグ付き PDF の言語も `en-GBR` と書いていた)。足した言語のうち、規則の作りが語の終わりに 3 字を残すもの (ポルトガル語・スロバキア語・アイルランド語・ウェールズ語・エストニア語) は、`hyphenate-limit-chars` の前後の字数を指定しないとき、終わりに 3 字を残す。ブラウザ向けの配布物 (`dist-browser/`) は、規則を言語ごとの別ファイルに入れ、ハンガリー語のほかは縮める (`kumiori.js` は大きくならない)。規則ごとの著作権とライセンスの表示は、そのファイルの先頭と `THIRD_PARTY_NOTICES.md` の 1.4 節にある (ハンガリー語は MPL 1.1、スウェーデン語などは LPPL 1.3c、ほかは MIT・BSD などの許諾)
14
+ - **タグ付き PDF の、行内の絶対配置の要素の構造と読む順** (HTML。**PDF が変わる**: タグ付き PDF (既定) の、字のある段落の中か行内の要素の中に、絶対配置・固定配置の要素がある文書。ページの見た目は変わらない): `<p>前<span style="position: absolute">絶対</span>後ろ</p>` のような、行内の絶対配置の要素に構造の節が無く、中身の字が親の段落のじかの字として、描いた順 (段落の字の後ろ) に並んでいたのを、Span の構造の節にして、親の字の間の、書いた所に置く (読む順は文書の順。ISO 32000-1 §14.8.2.3)。段落の印の付いた内容は、その所で分ける。書いた所には幅 0 の目印の箱を置く (改行の機会・行の高さ・字の位置は変わらない。領域の木では、字の並びの箱がそこで分かれ、目印の箱が入る)
15
+ - **タグ付き PDF を構造の順に読んだときの、行をまたぐ語** (HTML・XSL-FO。**PDF が変わる**: タグ付き PDF (既定) の、空白の所で分けた行か、分綴した行のある文書。ページの見た目は変わらない。タグを付けない PDF は変わらない): 構造の順に読む字 (読み上げ・ほかの形式への書き出しなど) で、行の終わりの語と次の行の初めの語が、間の空白無しにつながっていた (`documentation` + `characteristically` → `documentationcharacteristically`) のと、分綴で行末に足したハイフンが、語の中のハイフンとして読まれていた (`inter-national`) のを直す。空白の所で分けた行は、行の最後の字の後ろに、行末で捨てた空白を見えない字として書き (ISO 32000-1 §14.8.2.5: 語の区切りは空白の字で表す)、分綴のハイフンは、その印の付いた内容の置き換えの文字列 (`ActualText`。§14.9.4) をソフトハイフン (U+00AD) にする (構造の節の印の付いた内容を、ハイフンの所で分けて書く)。あわせて、領域の木の字 (`GlyphArea`) に、分綴で足した字の印 `hyphen` と、行末で捨てた空白 `breakSpace` を足す (領域の木の JSON が変わる)
16
+ - **PDF/X の出力意図と出力の ICC プロファイル** (PDF/X でない出力は変わらない。**互換が変わる**: 前は出せた入力が誤りになるものがある。**PDF が変わる**: プロファイルだけを渡した PDF/X の出力意図): (1) PDF/X-3 でも、印刷条件 (`pdfx.condition`・`--output-condition`) が ICC の登録簿に無いのに出力の ICC プロファイル (`pdfx.profile`・`--output-profile`) が無ければ、誤り (`pdfx/profile-required`) にする (PDF/X-1a と同じ決まり。ISO 15930-1 §6.3.2)。前は、RegistryName も DestOutputProfile も無い、印刷条件を特定できない出力意図を書いていた。書き出した後の確かめも、X-3 の出力意図を同じ決まりで調べる。X-3 でプロファイルを渡すなら、CMYK のものに限る (前は確かめなかった)。(2) プロファイルだけを渡して印刷条件の名前を書かないと、名前を JC200103 (Japan Color 2001 Coated の登録名) にして、登録簿 (RegistryName) も書いていたのを、プロファイルの説明 (desc のタグの文) を名前 (OutputConditionIdentifier・OutputCondition・Info) にし、RegistryName は書かないようにする (埋め込んだプロファイルと違う印刷条件を名乗らないため)。前と同じ出力意図にするには、`condition: 'JC200103'`・`--output-condition JC200103` を書く。プロファイルも名前も無いときは、これまでどおり JC200103。(3) 出力の ICC プロファイルを、頭の色空間と機器の種類だけでなく、頭とタグの表まで確かめる (ICC.1:2010 §7.2・§7.3: 頭の大きさの欄・`acsp`・タグの数と、各タグの中身の位置と大きさ。どのプロファイルにも要る説明のタグ desc (§8.2) も)。合わなければ誤り (`pdfx/profile-invalid`)。前は、頭とタグの署名だけの 144 バイトのものも通っていた
17
+ - **PDF のページラベル** (XSL-FO・HTML。**PDF が変わる**: 10 進でないページ番号の書式か、番号の振り直しのある文書。組版の結果 (紙面) は変わらない): ビューアが出すページの番号を、紙面のページ番号に合わせる (カタログの `/PageLabels`。ISO 32000-1 §12.4.2)。前は、前付けを i・ii、本文を 1 から振った文書でも、ビューアは 1 からの通しの番号を出していた。書式は、XSL-FO の `fo:page-sequence` の `format` と `initial-page-number`、CSS の余白の箱の `counter(page, <型>)` の型と `counter-reset`・`counter-set` の `page` から取り、書式か番号の続かない所で範囲を分ける。PDF の書き方 (10 進・ローマ数字・英字) で紙面と同じ字にならないページ (漢数字・丸数字・全角・0 埋め・ローマ数字の字、PDF と字の違う英字 (28 ページ目の ab など)、0 以下の番号など) は、ページごとに紙面と同じ字を書く。書式の前後の字 (「- 1 -」の「-」) は入れない。1 からの 10 進の通しの文書には書かない。領域の木の `page` に、10 進でないページの書式 `pageNumberFormat` を足した ([`docs/area-tree.md`](docs/area-tree.md) の「ページの番号」)
18
+ - **入れ子のリストの中身が、ページの終わりで 1 つずつ別のページに置かれ、数行だけのページが続いていたのを直す** (HTML・XSL-FO。**組版の結果が変わる**: 入れ子のリスト (`ul > li > ul > li`・入れ子の `fo:list-block`) の中身がページをまたぐ文書): 入れ子のリストの項目の中の字と段落 (ブロック) がページの終わりにかかると、続きのページにブロックを 1 つしか置かずに次のページへ送り、数行だけのページが続いていた (2 段の入れ子のふつうの文書でも起きた。0.4.0 より前からあった誤りで、後戻りではない)。リストは記号の列と本文の列の表として組み、入れ子のリストは外側の項目の本文の中の表になる。外側の項目をページで分けるとき、中の項目の続きの高さを、次のページの高さでなく、外側の項目を置くページの残りの高さで出していた。続きは、次のページの高さいっぱいに置く (XSL 1.1 §6.8・§4.8、CSS 2.1 §13.3.5)。例: A5 の文書で 5 ページ (本文の行 33・1・3・1・3) になっていたものが 2 ページ (33・8) に。乱数の入れ子の文書 (`scripts/gen-stress-docs.mjs` の nest・fonest) は、300 の大きさで 29 → 16 ページ・30 → 16 ページ
19
+ - **PDF の作成日・更新日を渡せる** (API の `PdfOptions.date`・コマンドの環境変数 `SOURCE_DATE_EPOCH`。渡さなければ PDF は変わらない): `toPdf`・`typesetToPdf`・器の `typesetToPdf` の `date` (`Date`) に渡した日時を、PDF の作成日・更新日 (Info の `CreationDate`・`ModDate`、PDF/X・PDF/A・PDF/UA の XMP の `xmp:CreateDate`・`ModifyDate`・`MetadataDate`) と、PDF/A-3 の添付ファイルの更新日 (`Params` の `ModDate`) に書く (秒より下は切り捨てる)。前は、どれも組んだ時刻だった。コマンドは、環境変数 `SOURCE_DATE_EPOCH` (reproducible-builds.org の決まり: 1970-01-01 UTC からの秒の整数) を読み、決まりに合わない値は誤り (終了コード 1) にする。正しくない `Date` と 0〜9999 年の外の日時は `KumioriOptionError` (`option` は `date`)
20
+ - **同じ入力から同じバイトの PDF** (**PDF が変わる**: どの PDF も、文書の ID のバイトが変わる。見た目・字は変わらない): 文書の ID (trailer の `ID` と、PDF/X・PDF/A・PDF/UA の XMP の `xmpMM:DocumentID`・`InstanceID`) を、乱数でなく、書き出した PDF の中身の SHA-256 から作る (中身が同じなら同じ ID)。PostScript の書体 (EPS の中の CFF) の字形の手続きの `random` を、字形ごとに決まった種からの乱数にし、PostScript の `realtime` を時計でなく手続きの歩数から作る。`date` (コマンドでは `SOURCE_DATE_EPOCH`) を渡せば、同じ版の Kumiori で、同じ入力・同じ書体・同じ設定から、同じバイトの PDF になる
21
+ - **どの書体にも字形の無い字を、OS の書体で組む選択肢** (API の `systemFonts`・コマンドの `--system-fonts`。新しい選択肢で、既定では使わない。渡さなければ組版の結果は変わらない): 既定の書体・記号と絵文字の書体のどれにも字形の無い字を、OS の書体の場所 (Windows・macOS の書体のフォルダ、Linux などは fontconfig の設定の `<dir>`) から探して組む (CSS Fonts 4 §5.2 の処理系の後備の書体)。ライブラリでは `kumiori/node` の `createSystemFonts()` を `systemFonts` (`createTypesetter` の設定) に渡す。その字だけを OS の書体で組み、ほかの字の書体と位置は変わらない。明朝の文脈の字は明朝の書体、ゴシックの文脈の字はゴシックの書体を先に使い (書体の種類は OS/2 の PANOSE・sFamilyClass と名前で決める)、合う種類の書体が無ければほかの種類で補う。読み込むのは、文書で要る種類の書体だけ (明朝の文脈にしか無い字に、ゴシックの書体を読まない)。書体のファイルは字の範囲の表 (`cmap`) など要る表だけを読んで索引にし (部品ごとに 1 度)、PDF に埋め込めない書体 (OS/2 の `fsType`) は使わない。文書の `font-family` からは OS の書体を名指しできない。組むのに使った書体は、組んだ後に、その書体で組んだ字と一緒に知らせ `font/system-fallback`、埋め込めないので使わなかった書体は警告 `font/system-font-not-embeddable` で知らせる。1 つの文書で使う OS の書体の数は上限 `systemFontFaces` (既定 16)。`createSystemFonts` の `dirs` は文字列の配列にする (ほかの値は `TypeError`。相対の道は、部品を作ったときのカレントディレクトリから)。`systemFonts` は器の設定で、`typesetter.typeset` の文書ごとの設定に渡したものは、ほかの器の設定と同じく使わない (`api/setup-option-ignored`)。組んだ結果が機械の書体で変わり、組んだ PDF から機械に入っている書体が分かるので、他人の書いた文書を組むときは使わない (コマンドでは `--no-outside-files` と一緒に使うと誤り)。コマンドで、`--system-fonts` を付けずに字形の無い字があったときは、診断の後に `--system-fonts` で探せることを添える
22
+ - **HTML の行の中に書いた float と絶対配置の箱の置き場所** (HTML のどのスタイルでも。**組版の結果が変わる**: 段落の途中に float を書いた文書、位置の決まった祖先の無い絶対配置の箱で top・left が auto のものを書いた文書、flex の項目の中に float を書いた文書): (1) 段落の途中に書いた float (`float: left`・`right` など。行内の要素の中のものも) を、書いた所のある行に置く (CSS 2.1 §9.5.1 の規則 6・8)。前は段落の頭 (ページをまたぐ段落では 1 ページ目の頭) に置いていた。書いた所より前の、その行の中身の横に入らない float は、その行の下に置く。(2) ブロックを含む行内の要素 (`span` の中に `div` を書いたものなど) の中の float を、書いた所の側 (中のブロックの前後で分けた匿名のブロックのうち、float を書いた所のあるもの) に置く (CSS 2.1 §9.2.1.1)。0.5.0 では、その中のブロックの後に置いていた (0.5.0 の変更の記録に書いた断りのもの)。(3) flex の項目の中身による幅 (max-content) に、中の float の幅を数える (CSS Flexbox 1 §9.2・CSS Sizing 3 §5)。前は数えず、float の横に入るはずの字が次の行へ送られていた。(4) 位置の決まった祖先の無い絶対配置の箱 (`position: absolute`) の、top・bottom が auto の向きと left・right が auto の向きを、static position (箱を流れの中に置いたとしたときの位置。CSS 2.1 §10.3.7・§10.6.4) に置く: ブロックの間の箱は、前のブロックの下、行の中の箱 (行内の要素の中のものも) は、見つけた所の行の上端と、行の中の位置。前は、ページの本文領域の上端・左端に置いていた。static position に置くのは、ページの本文の流れ (横書きで、段組でないもの) の中の箱だけで、段組の中・縦書きの文書と、表のセル・リストの項目・flex の項目の中の箱は、static position にならない (前のまま、ふつうは本文領域の左上に置く)。箱の中の字は、受け継いだ `text-indent` で 1 行目を字下げする (CSS Text 3 §8.1。ブラウザも同じ。既定の `p` の 1em の字下げも受け継ぐ)。ブラウザで組むとき (画面) は、前からブラウザの位置を使う
23
+ - **先頭から N ページで止めて組む** (API の `maxPages`・コマンドの `--max-pages <N>`。渡さなければ組版の結果は変わらない): 長い文書の初めの数ページのプレビューのために、先頭から N ページまで組んだら止める選択肢を足した。止めたら、結果の `truncated` (`TypesetResult`・`TypesetPdfResult`。組んだ結果の木には `truncated: { maxPages }`) が `true` になり、知らせ `layout/max-pages-reached` を出す。N ページより後ろにある所を指すページ番号の参照 (`page-number-citation`・`target-counter()` など)・後ろへ続く要素の最後のページの番号・総ページ数 (`counter(pages)`・柱の総ページ数) は決まらないので `"?"` で組み (`--style weasyprint` の組み方では空)、索引は N ページまでの所だけを並べ、しおりは飛び先の無いしおりにして、警告 `layout/beyond-max-pages` を種類ごとに 1 件出す。残したページの組みは、本文に N ページより後ろを指すものが無ければ全体を組んだときと同じで、あると、その字の幅の違いで行分けが変わることがある (リーダーの付いた目次はまず変わらない)。組み直しの回は、どの回も N ページで止める。文書の読み込みとカスケードは全体で行うので、速くなるのは組版と PDF の書き出しの分。器 (`createTypesetter`) で組むと、止めた文書でも覚えは残し、覚えの世代は進めない。説明は [`docs/library.md`](docs/library.md) の「先頭の数ページだけを組む」
24
+ - **開発: 前と後の組み比べと、領域の木の指紋の試験** (組版の結果は変わらない): 直す前と後のコミットの Kumiori で同じ文書を組み比べ、組版の結果の変わった文書とページを一覧にする `npm run compare:base -- --base <コミット>` (`scripts/compare-base.mjs`) を足した。2 つのコミットを一時的な場所に取り出してコマンドを作り、対応仕様説明書・`examples`・`samples` と、手元にあればアンテナハウスのサンプル FO 集・『CSSページ組版入門』第 4 版・WeasyPrint の見本を組み (日時を渡せない前の版は、時計と乱数を止めて組む)、PDF のバイト列・ページ数・ページごとの字 (pdftotext の語と位置)・絵 (pdftoppm の画素) を比べて (バイトも同じ文書と、見た目だけ同じでバイトの違う文書を分ける)、`report.md`・`report.json` と、変わったページの前・後・差を並べた絵を書く。あわせて、対応仕様説明書の見本と全体、`examples`・`samples/check` の文書の領域の木の指紋 (SHA-256) を `test/fingerprints/` に置き、組版の結果が変わると `npm test` が変わったページを出して落ちるようにした。意図して変えたときは `npm run fingerprints:update` で書き直す (`-t` で絞れば、組んだ文書の指紋だけを書き直し、ほかは残す。`docs/development.md` の「前と後の組み比べ」「領域の木の指紋」)
25
+ - **入力の上限を選択肢で変えられる** (API の `limits`・コマンドの `--limit <名前>=<値>`・`--list-limits`。渡さなければ組版の結果は変わらない): 小さな入力で時間とメモリを使い切らせないための上限 (画像の画素の数・ファイルの大きさ・取得の大きさ・EPS の時間とメモリ・EPUB の展開・draw.io の図・表の列・数式の字・入れ子の深さ・PNG の書き出しの手間など、62 個) を、信頼できる大きな文書のために上げ、サーバーで絞るために下げられるようにした。下げるのはどれもでき、上げるのは時間・大きさの上限だけ (入れ子の深さの上限は下げるだけ。上げようとすると `KumioriOptionError`・コマンドは誤り)。既定の値は前と同じ。上げても、ファイルの大きさによる縛り (符号の密度・展開の比) は変わらない。上げた上限があれば、知らせ `limit/raised` を出す。`createTypesetter` の設定の `limits` は文書ごとの既定になり、上限の違う文書では器の覚えを使い回さない。プラグインの `load` の文脈に、読むだけの `limits` を渡す。名前と既定の値は [`docs/library.md`](docs/library.md) の「入力の上限」 (EPUB の展開の上限は、画面で EPUB を読むときだけ使い、画面では既定の値。API・コマンドは EPUB を読まないので、変えても効かない)。安全の決まり ([`SECURITY.md`](SECURITY.md)) は、決めた上限 (下げた上限も) を超えて使わせられるものを脆弱性として扱い、上げた上限の中で多く使うことは扱わない
26
+ - **段組の脚注の多い文書で、ページが増え、本文が数行だけのページが続いていたのを直す** (XSL-FO・HTML。**組版の結果が変わる**: 段組のページに、本文の領域の下に置く脚注がある文書): 0.5.0 で、段組のページの脚注の領域の高さ (ページごとの予約) を決める組み直しを、前のページから順に固める形にしたが、脚注の多い長い段組の文書では、前から固める回が文書の初めの数ページしか進まず、残りの回が予約を積んで、本文が数行だけで脚注の無いページが文書じゅうにでき、ページが 0.4.0 より 4〜5 割増え、組版の時間も 2 倍を超えていた (0.5.0 の後戻り。0.5.0 の変更の記録には、この組み直しで本文が数行だけのページが減ったと書いたが、このような文書では逆だった)。予約は、組版の中で、ページの始まりごとに決めるようにした: 前の回の組版の脚注の参照の、本文の並びの位置 (段の区切りによらない、本文の量) から、そのページに入る脚注と要る高さを見積もり、収まる最小の予約にする。同じ所から始まるページは、前の回に収まった予約に固め、収まらなかったら上げる。前のページの予約が変わって本文がずれても、後ろのページの予約はずれた本文に合わせて決まるので、ふつうは 2〜4 回の組版で収まる。脚注の量がページに入るより多いページで、予約が上げ下げで振れて大きい方に固まり、ほとんど白いページが残ることがあったのも (0.4.0 からあったもの)、同じ直しで直った。本文のあるページの予約は、本文の 1 行半の高さを残す (脚注の参照の印のある行は、行の高さより高くなることがある。前は 1 行)。乱数で作った脚注の多い 2 段の文書 (本文 3000 行・脚注 238 個。`scripts/gen-column-footnotes.mjs` の mix3000a.html) では、この直しの直前の版 (0.5.0 より後の、公開していない版) で 288 ページ・組版 52 秒だったものが 143 ページ・9 秒になり (0.4.0 は 204 ページ・26 秒で、脚注の行を 56 行落としていた)、参照と別のページに頭を置いた脚注は 41 個 (0.4.0 は 44 個) から 0 個になった。段組の脚注の組版の結果 (脚注の分け目、本文と脚注の間の空き、ページの数) が変わる
27
+ - **画面から API の説明書へのリンク** (画面。組版の結果は変わらない): 画面の上の並びに「API の説明書」を足し、ライブラリの関数・型・選択肢の一覧 (GitHub Pages の画面の下の `api/`) を新しいタブで開けるようにした。狭い画面では、「設定」の「そのほか」に置く
28
+ - **少し直した文書の組み直しを速くする** (API の `createTypesetter()` の器。組版の結果・PDF は変わらない): 器が、前の文書を組んだときの `@font-face` の書体のファイルの下ごしらえ (WOFF2 の展開・表の確かめ) と、中身・書式・幅の同じ段落の行分けの結果を覚えて、次の文書で使い回す。1 段落ずつ直しながら組み直すと、151 ページの HTML の文書で約 13 秒が約 9 秒、103 ページの XSL-FO の文書で約 4.1 秒が約 3.2 秒になる (書体の並びが同じになる 2 回目か 3 回目の組み直しから。行内の箱・画像・脚注・ページ番号の参照を含む段落は使い回さない)。覚える分のメモリ (前の文書 1 つ分。上限は約 400MB) を使い、`createTypesetter({ reuse: false })` で切れる。表の多い文書では、使い回しのために、同じ文書の組み直しが 0.5.0 より 2 割ほど遅くなることがある (`reuse: false` にすれば 0.5.0 と同じほどの速さになる)
29
+ - **呼び出しごとの言語** (API。組版の結果は変わらない): `TypesetOptions.lang` を、呼び出しごとの文脈に持つようにした。違う `lang` の `typeset`・器の `typeset` を同時に (待たずに) 走らせても、それぞれの呼び出しの言語で警告・誤りの文を書く (前は、重なっている間は後に始まった呼び出しの言語になった。Node でもブラウザでも)。`lang` を省いた呼び出しは、始めたときの言語で通す。結果の `renderPage` (Canvas) の警告も、`toPdf` と同じく組んだときの言語で書く (前は、そのときの既定の言語)
30
+ - **組版を止める合図と進み具合** (API の新しい選択肢。渡さなければ動きも速さも変わらない。組版の結果は変わらない): `typeset`・`typesetToPdf`・器の `typeset`・`typesetToPdf` の `signal` (AbortSignal) と `onProgress`、`createTypesetter` の `setup.signal`・`setup.onProgress`、結果の `toPdf` の `signal`・`onProgress`、`renderPageToSvg`・`renderPageToPng` の `signal`。止めると、返す Promise は `signal.reason` (理由を渡さなければ `AbortError` の `DOMException`) で失敗する。止めた合図を渡せば何も読まずに失敗し、書体・資源を読むたびに確かめ、読みかけの取得 (fetch) も止める。`resolveResource`・`loadFont` の 2 つ目の引数に `{ signal }` を渡す (器が文書によって初めて読む書体 (数式・等幅・記号・絵文字) は、同じ器で同時に組むほかの呼び出しと分け合うので、`loadFont` には時限だけを渡し、止めた呼び出しは待つのをやめるだけ。ほかの呼び出しの読み込みは失敗しない)。`typesetToPdf` では組む設定 (`options`) の `signal`・`onProgress` が PDF の書き出しまで効き、PDF の設定 (3 つ目の引数) に渡すと `KumioriOptionError`。ページを組むたびと PDF のページを書くたびにも確かめ、進み具合は、書体 (`fonts`)・資源 (`resources`)・読み込み (`import`)・組版 (`layout`。回とページの数)・PDF (`pdf`。書いたページと総ページ数) の段階を知らせる。渡したときは、組み直しの回・page-sequence・PDF のページの境目で間をあける (1 つの page-sequence の組版の途中では間をあけないので、そこで止めるには `onProgress` の中で止める)。止めた後も器はそのまま使え、文書をまたぐ覚えは、止めた文書を世代に数えない。説明は [`docs/library.md`](docs/library.md) の「組版を止める・進み具合」
31
+ - **PNG の書き出しの手間と板の勘定** (PDF・SVG と、上限に当たらないページの PNG は変わらない): 止まり点の多いグラデーション (細かい `repeating-linear-gradient` は 4,000 個ほど) の色を、画素ごとに止まり点を先頭から探していたのを、二分で探すようにした (A4 の 300dpi で、そのような箱 40 個に 16 秒かかっていたのが 1.4 秒。2 色のグラデーションは 0.9 秒)。手間の勘定には、止まり点が 16 個より多いグラデーションの塗りの 1 画素に log2 (止まり点の数) を足す。同時に持つ板の上限 (`pngLayerPixels`) は、不透明度のグループ・マスクの板を作るときの描ける範囲 (ページ全体のことが多い) でなく、実際に広げた大きさで数えるようにした (前は、ページが大きい・解像度が高いと、小さな不透明度の箱の浅い入れ子でも上限に当たり、中の重なりを濃く描いていた)。広げると上限を超える不透明度のグループの板は、そこまでの中身を重ねてから続きを描く。勘定が上限の近くにあるとき、いちばん外の切り抜き (SVG の不透明度のグループの中など) の中を描かなかったのを直す。0.5.0 の説明書と SECURITY.md に書いた、グラデーションの手間が勘定に入らない断りは消した
32
+ - **入れ子の表・リストの中の長い中身を速く組む** (HTML・XSL-FO。組版の結果は変わらない): 表のセルの中の表 (HTML のリストも表で組む) で、外の段の行をページで分けるたびに、中の段の行の高さを測る組みをやり直していたので、段 k の表を k 回組んだ (16 段の入れ子のリストの中の `<p>` 4,000 個で 1.7 秒)。1 回の組版の間、1 行の組の高さを覚え、ページで分けると決まる行では測る組みを省くようにし、同じ文書を 0.6 秒で組む。行をページで分けられなかったときに、同じ条件でもう 1 度分けようとしない (入れ子の段ごとに回数が倍になる所があった)。組みが表の外に跡を残す行 (マーカー・絶対配置の箱のある行) は、前のとおり測る
33
+ - **後続の兄弟の結合子 (`A ~ B`) の規則の多い文書を速く組む** (HTML・SVG の `<style>`。組版の結果は変わらない): `~` の左の部分に合う前の兄弟を、要素ごとに初めまでたどっていたので、手間が規則の数 × 要素の数 × 兄弟の数になった (`.cN ~ *` の規則 4,500 個と兄弟の `<p>` 400 個で 40 秒ほど)。1 回のカスケードの間、親ごと・左の部分ごとに、初めに合う子の位置と、どこまで照合したかを覚えるようにし、同じ文書を 1.4 秒で組む (隣の兄弟の結合子 `+` の同じ数の規則と同じほど。Selectors 4 §16.4)
34
+ - **読めない値の CSS の宣言・XSL-FO の読み込みの知らせ・上限に当たったことを診断に出す** (HTML・XSL-FO。組版の結果・PDF は変わらない。**互換が変わる**: 診断と終了コード。`warnings`・`diagnostics` に足され、コマンドの `--fail-on warning` (と、`fo/master-reference-not-found` では `--fail-on error`) の終了コードが変わる): (1) 知っている CSS のプロパティの、読めない値の宣言 (`display: foo`・`color: notacolor`・`margin: foo` など。CSS 2.1 §4.2 で宣言ごと無視する) を、新しい診断 `css/invalid-value` (警告。args は `property`・`value`) で知らせる (前は、警告なしに捨てていた)。作成者のスタイルシートと `style` 属性の宣言だけを、「性質: 値」ごとに数える。`var()`・`attr()` を含む値、接頭辞付きの値 (`-webkit-box` など)、同じ規則 (`style` 属性) に同じプロパティの読める宣言があるもの (ブラウザ向けの予備の値) は数えない。CSS として正しいが Kumiori が読まない値 (`font: caption` などのシステムの書体の名前・`font-size: math`) は `css/unsupported` に、互換の指定 (`--style ah`) のときだけ読む、接頭辞の無い名前に書いた拡張の値 (`border-style: dot-dash` など) は、互換の指定の無いときに `css/unsupported` (「--style ah のときだけ解釈する値」) に出す。画面の変換レポートにも出す。 (2) XSL-FO の読み込みの知らせ (近似や既定値で代用したこと: 大きすぎる列の数を上限にした・`flow-name` に合う領域が無いので本文の領域へ流した・アンテナハウスの説明に無い `axf:document-info name="title"` など) は、画面の変換レポートにだけ出ていたのを、新しい診断 `fo/note` (警告) として、コマンドの診断・API の `diagnostics` にも出す。`fo:page-sequence` の `master-reference` に当たるページのマスターが無いときは、0 ページで何も知らせずに終わっていたのを、新しい診断 `fo/master-reference-not-found` (誤り。args は `name`。その `page-sequence` の中身が出力から欠けるため) で知らせる。 (3) 入力の上限 (`limits`・`--limit`) を下げたときに、診断を出さずに切っていた所 (grid の列の並び `gridTracks`・字を並べるリーダー `leaderRepeats`・入れ子の規則を展開したセレクタ `nestedSelectors`・集める CSS と書体の参照 `styleRefs`・`@import` の段 `importDepth`・`col` の `span` と `colspan` を、HTML の仕様の上限の 1,000 より下げた `tableColumns`・描かなかった PDF の画像の `pdfImage*`) で、新しい診断 `limit/reached` (警告。args は `limit`・`value`) を、上限の名前ごとに 1 回の組版で 1 件出す (結果の `toPdf`・`renderPageToSvg`・`renderPageToPng` の間に当たった上限は、その後の結果の `warnings`・`diagnostics` に足す)。既定の上限で、ふつうの文書には出ない。 (4) 行内の箱 (`fo:inline-container`)・脚注の本体 (`fo:footnote-body`) の中に置いた `overflow="condense"` の `fo:block-container` の警告 (`layout/condense-overflow`・`layout/condense-capped`・`layout/condense-height-unknown`) を出さなかった (中身を測るための組みでは、警告を出さないようにしていたため) のを、ほかの所と同じに 1 件ずつ出す。 (5) 同じ名前の診断の `args` を、出す所によらずそろえる: `font/file-unreadable` は、いつも `file` (読めなかったファイルの名前) を持ち、`@font-face` では書体の名前 `font` も持つ (前は `@font-face` では `font` だけ)。書体の取得の誤り (`KumioriFontError`、`font/load-failed`) は、いつも `font` を持つ。`png/image-not-drawn`・`png/image-limit` は、SVG の中の画像でも、その画像を含む SVG の画像の `src` を持つ (前は `src` が無かった)
35
+ - **コマンドの空の値・`--watch` の直し** (コマンド。組版の結果は変わらない。**互換が変わる**: 空の値の扱い): (1) ファイル・ディレクトリ・プラグインの道をとるオプション (`--font-dir`・`--font-cache`・`--font`・`--css`・`--base`・`--spot-colors`・`--output-profile`・`--drawio-stencils`・`--plugin`) と、名前をとる `--ignore-warning`・`--output-condition` の空の値 (`''`。`,` で区切るものは、項目が 1 つも無い値も) を、値の誤り (終了コード 1) にする。前は、そのまま受けて、今のディレクトリ (`--font-dir ''` は今のディレクトリの書体を読み、`--base ''` は今のディレクトリを基準にした) や、書いていないもの (`--css ''`・`--ignore-warning ''`) として扱っていた (`-o ''` は 0.5.0 で誤りにした)。(2) `--watch` が、エディタの「新しいファイルに書いて名前を変える」保存の 2 回目から、組み直さなかった (Node の Linux の再帰の `fs.watch` が、名前の変更の後のファイルを見張らない) のを直す。Linux では、入力のディレクトリと、その下のディレクトリごとに見張る (後から作ったディレクトリも)。(3) `--ignore-warning` に知らない名前を渡したときの警告 (`api/unknown-diagnostic-code`) の文を、API の名前 (`diagnostics.ignore`) でなく、`--ignore-warning` の名前で書く。(4) 説明書の終了の状態に、`--watch` でも、プラグインを読めないときは見張らずに終了コード 1 で終わることを書く (前は「`--watch` のときは終了コードは変わらない」とだけ書いていた)
36
+ - **Deno・Bun で動くことの確かめ** (文書と開発の道具。組版の結果は変わらない): ライブラリ (`kumiori`・`kumiori/node`・`kumiori/browser`) とコマンドが、Deno 2.9・Bun 1.4 で動くことを確かめ、確かめた範囲を README と説明書の「パッケージの形と動く環境」に書いた。Cloudflare Workers のような Node の API も DOM も無い所では、ブラウザ向けの 1 ファイルを使うことも書いた (Workers そのものでは試していない)。npm pack した包みを Node・Deno・Bun で読んで確かめる `node scripts/check-runtimes.mjs` を足した。
37
+ - **API の安定性の約束** (文書。組版の結果は変わらない): 公開の API を、版をまたいで保つもの (入口の関数・`TypesetResult`・主な選択肢・誤りの型と名前・`kumiori/node`・Area Tree をたどる関数) と、変わりうるもの (組版の結果・Area Tree の欄の細部・文の言い回し・出力の中の作り・新しい選択肢と実験的な選択肢) に分け、`PLUGIN_API_VERSION`・`AREA_TREE_SCHEMA_VERSION` との関係とあわせて、ライブラリの説明書の「API の安定性」に書いた。0.x の間は、安定のものも minor の版で互換を崩すことがあり、そのときは変更の記録に「**互換が変わる**」と書く。
38
+
7
39
  ## 0.5.0 (2026-11-22)
8
40
 
9
41
  - **行内の箱・脚注の本体の中の画像の警告** (HTML・XSL-FO。組版の結果・PDF は変わらない。**互換が変わる**: 診断と終了コード): 0.4.0 は、`inline-block`・`fo:inline-container`・脚注の本体 (HTML の `float: footnote`・`fo:footnote-body`) の中の見つからない画像 (`image/not-found`。重さは誤り)・描けない画像 (`image/unsupported`)・一部を描けない画像 (`image/partial`) と、SVG の中の見つからない参照 (`image/reference-not-found`) に、診断を出さなかった (中身を測るための組みでは、警告を出さないようにしていたため)。いまは、ほかの所と同じに 1 件ずつ出す。`warnings`・`diagnostics` に足され、コマンドの `--fail-on error` (見つからない画像) と `--fail-on warning` の終了コードが変わる
package/README.en.md CHANGED
@@ -63,7 +63,7 @@ The fonts each script needs, the image formats, the details of the PDF/X standar
63
63
  | [Features](docs/en/features.md) | detailed list of features (input, Japanese typesetting, other scripts, pages, output) |
64
64
  | [Using the web app](docs/en/app.md) | opening, saving, settings, warnings |
65
65
  | [Command reference](docs/en/cli.md) | options, examples, environment variables, exit status |
66
- | [Library guide](docs/en/library.md) | `typeset` options; PDF, Canvas, SVG, PNG; Web Worker; Node helpers |
66
+ | [Library guide](docs/en/library.md) | `typeset` options; PDF, Canvas, SVG, PNG; Web Worker; Node helpers; [API stability](docs/en/library.md#api-stability-what-is-kept-across-versions) (what is kept across versions) |
67
67
  | [API reference](https://n-lights-co.github.io/kumiori/api/) | every function, type and option (generated from the type declarations; Japanese only) |
68
68
  | [Conformance Guide](docs/en/conformance.md) | support and handling of each item of the specifications |
69
69
  | [Diagnostics](docs/en/diagnostics.md) | codes and severities of warnings and errors |
@@ -76,6 +76,7 @@ The fonts each script needs, the image formats, the details of the PDF/X standar
76
76
  ## Requirements
77
77
 
78
78
  Node 20.19.0 or later in the 20 line, or 22.12.0 or later (CI tests with 20.19.0 and 22).
79
+ The library and the command also run on Deno (2.x) and Bun (1.x), through their Node compatibility APIs. In browsers, it can also typeset inside a Web Worker. What has been checked is in [Package entry points and requirements](docs/en/library.md#package-entry-points-and-requirements).
79
80
 
80
81
  ## License
81
82
 
package/README.md CHANGED
@@ -63,7 +63,7 @@ PDF/A は、規格の本文ではまだ確かめていないので、保存の
63
63
  | [できること](docs/features.md) | 機能の詳しい一覧 (入力・日本語組版・多言語・ページ・出力) |
64
64
  | [画面の使い方](docs/app.md) | 開く・保存・設定・警告 |
65
65
  | [コマンド](docs/cli.md) | オプションの一覧・例・環境変数・終了の状態 |
66
- | [ライブラリ](docs/library.md) | `typeset` の選択肢、PDF・Canvas・SVG・PNG、Web Worker、Node の部品 |
66
+ | [ライブラリ](docs/library.md) | `typeset` の選択肢、PDF・Canvas・SVG・PNG、Web Worker、Node の部品、[API の安定性](docs/library.md#api-の安定性-版をまたいだ約束) (版をまたいで保つもの) |
67
67
  | [API の説明書](https://n-lights-co.github.io/kumiori/api/) | すべての関数・型・選択肢 (型の宣言から作った一覧) |
68
68
  | [対応仕様説明書](docs/conformance/README.md) | 仕様の項目ごとの対応と扱い |
69
69
  | [診断](docs/diagnostics.md) | 警告と誤りの名前・重さ |
@@ -76,6 +76,7 @@ PDF/A は、規格の本文ではまだ確かめていないので、保存の
76
76
  ## 動く環境
77
77
 
78
78
  Node は 20.19.0 以上の 20 系か、22.12.0 以上です (CI は 20.19.0 と 22 で確かめています)。
79
+ Deno (2.x) と Bun (1.x) でも、ライブラリとコマンドが動きます (Node の互換の API で動きます)。ブラウザでは、Web Worker の中でも組めます。確かめた範囲は [パッケージの形と動く環境](docs/library.md#パッケージの形と動く環境) にあります。
79
80
 
80
81
  ## ライセンス
81
82