kumiori 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.en.md +29 -0
  2. package/CHANGELOG.md +29 -0
  3. package/LICENSE +202 -0
  4. package/NOTICE +5 -0
  5. package/README.en.md +278 -0
  6. package/README.md +277 -2
  7. package/THIRD_PARTY_NOTICES.md +1873 -0
  8. package/assets/logo/kumiori-avatar-512.png +0 -0
  9. package/assets/logo/kumiori-logo-1280.png +0 -0
  10. package/assets/logo/kumiori-logo-mono.svg +6 -0
  11. package/assets/logo/kumiori-logo-on-dark.svg +6 -0
  12. package/assets/logo/kumiori-logo-stacked-on-dark.svg +6 -0
  13. package/assets/logo/kumiori-logo-stacked.svg +6 -0
  14. package/assets/logo/kumiori-logo.svg +6 -0
  15. package/assets/logo/kumiori-mark-mono-white.svg +4 -0
  16. package/assets/logo/kumiori-mark-mono.svg +4 -0
  17. package/assets/logo/kumiori-mark-on-dark.svg +4 -0
  18. package/assets/logo/kumiori-mark.svg +4 -0
  19. package/assets/logo/kumiori-wordmark.svg +4 -0
  20. package/dist-browser/LICENSE +202 -0
  21. package/dist-browser/NOTICE +5 -0
  22. package/dist-browser/THIRD_PARTY_NOTICES.md +1873 -0
  23. package/dist-browser/chunks/UTIF-BA_P1T7D.js +1447 -0
  24. package/dist-browser/chunks/en-gb-c-j9Dxjw.js +13008 -0
  25. package/dist-browser/chunks/en-us-FyKZ4pMu.js +9100 -0
  26. package/dist-browser/chunks/export-contract-BUdFW0fL.js +175 -0
  27. package/dist-browser/chunks/la-Cbb7zL-J.js +529 -0
  28. package/dist-browser/chunks/pako-BWg-BM0p.js +1458 -0
  29. package/dist-browser/chunks/rolldown-runtime-DfEuXgQw.js +15 -0
  30. package/dist-browser/kumiori.js +78773 -0
  31. package/dist-cli/LICENSE +202 -0
  32. package/dist-cli/NOTICE +5 -0
  33. package/dist-cli/THIRD_PARTY_NOTICES.md +1873 -0
  34. package/dist-cli/apple-touch-icon.png +0 -0
  35. package/dist-cli/cli.js +60907 -0
  36. package/dist-cli/favicon.ico +0 -0
  37. package/dist-cli/favicon.svg +4 -0
  38. package/dist-cli/kumiori-logo-on-dark.svg +6 -0
  39. package/dist-lib/LICENSE +202 -0
  40. package/dist-lib/NOTICE +5 -0
  41. package/dist-lib/THIRD_PARTY_NOTICES.md +1873 -0
  42. package/dist-lib/index.js +43715 -0
  43. package/dist-lib/index.js.map +1 -0
  44. package/dist-lib/types/api.d.ts +129 -0
  45. package/dist-lib/types/areaResources.d.ts +11 -0
  46. package/dist-lib/types/areaTree.d.ts +54 -0
  47. package/dist-lib/types/assets.d.ts +96 -0
  48. package/dist-lib/types/base64.d.ts +2 -0
  49. package/dist-lib/types/bidi.d.ts +25 -0
  50. package/dist-lib/types/canvasRenderer.d.ts +22 -0
  51. package/dist-lib/types/ccitt.d.ts +20 -0
  52. package/dist-lib/types/cff.d.ts +35 -0
  53. package/dist-lib/types/cgm.d.ts +14 -0
  54. package/dist-lib/types/color.d.ts +40 -0
  55. package/dist-lib/types/compat.d.ts +51 -0
  56. package/dist-lib/types/counterStyle.d.ts +58 -0
  57. package/dist-lib/types/counterStylePredefined.d.ts +12 -0
  58. package/dist-lib/types/cssCascade.d.ts +153 -0
  59. package/dist-lib/types/cssGradient.d.ts +9 -0
  60. package/dist-lib/types/cssSelector.d.ts +63 -0
  61. package/dist-lib/types/cssText.d.ts +43 -0
  62. package/dist-lib/types/cssUnsupported.d.ts +20 -0
  63. package/dist-lib/types/documentResources.d.ts +24 -0
  64. package/dist-lib/types/documentText.d.ts +9 -0
  65. package/dist-lib/types/eps.d.ts +41 -0
  66. package/dist-lib/types/foContext.d.ts +81 -0
  67. package/dist-lib/types/foDom.d.ts +31 -0
  68. package/dist-lib/types/foExpr.d.ts +36 -0
  69. package/dist-lib/types/foMathFallback.d.ts +73 -0
  70. package/dist-lib/types/foPageMaster.d.ts +82 -0
  71. package/dist-lib/types/fontLoader.d.ts +28 -0
  72. package/dist-lib/types/fontManager.d.ts +107 -0
  73. package/dist-lib/types/fontMapping.d.ts +76 -0
  74. package/dist-lib/types/footnotes.d.ts +82 -0
  75. package/dist-lib/types/geometry.d.ts +39 -0
  76. package/dist-lib/types/htmlImport.d.ts +180 -0
  77. package/dist-lib/types/htmlPaged.d.ts +142 -0
  78. package/dist-lib/types/htmlPrepare.d.ts +77 -0
  79. package/dist-lib/types/htmlSvg.d.ts +6 -0
  80. package/dist-lib/types/hyphenation.d.ts +19 -0
  81. package/dist-lib/types/icc.d.ts +15 -0
  82. package/dist-lib/types/imageInfo.d.ts +23 -0
  83. package/dist-lib/types/imageLimits.d.ts +13 -0
  84. package/dist-lib/types/index.d.ts +27 -0
  85. package/dist-lib/types/inlineFlatten.d.ts +37 -0
  86. package/dist-lib/types/inlineLayout.d.ts +259 -0
  87. package/dist-lib/types/jis.d.ts +52 -0
  88. package/dist-lib/types/jpeg.d.ts +40 -0
  89. package/dist-lib/types/jpegTables.d.ts +30 -0
  90. package/dist-lib/types/layoutEngine.d.ts +129 -0
  91. package/dist-lib/types/lineBreak.d.ts +33 -0
  92. package/dist-lib/types/lineMetrics.d.ts +49 -0
  93. package/dist-lib/types/lnode.d.ts +206 -0
  94. package/dist-lib/types/mathContent.d.ts +7 -0
  95. package/dist-lib/types/mathFont.d.ts +87 -0
  96. package/dist-lib/types/mathLayout.d.ts +59 -0
  97. package/dist-lib/types/mathOperators.d.ts +54 -0
  98. package/dist-lib/types/mathVariants.d.ts +10 -0
  99. package/dist-lib/types/matrix.d.ts +45 -0
  100. package/dist-lib/types/measurer.d.ts +135 -0
  101. package/dist-lib/types/messages.d.ts +23 -0
  102. package/dist-lib/types/metafile.d.ts +4 -0
  103. package/dist-lib/types/pageNumber.d.ts +18 -0
  104. package/dist-lib/types/paint.d.ts +79 -0
  105. package/dist-lib/types/pdfLibPatches.d.ts +59 -0
  106. package/dist-lib/types/pdfRenderer.d.ts +59 -0
  107. package/dist-lib/types/pixels.d.ts +29 -0
  108. package/dist-lib/types/psCff.d.ts +35 -0
  109. package/dist-lib/types/psColorSpace.d.ts +23 -0
  110. package/dist-lib/types/psEncodings.d.ts +14 -0
  111. package/dist-lib/types/psFilters.d.ts +34 -0
  112. package/dist-lib/types/psFonts.d.ts +57 -0
  113. package/dist-lib/types/psGraphics.d.ts +155 -0
  114. package/dist-lib/types/psInterp.d.ts +260 -0
  115. package/dist-lib/types/psOpsFont.d.ts +10 -0
  116. package/dist-lib/types/psOpsImage.d.ts +4 -0
  117. package/dist-lib/types/psOpsMatrix.d.ts +12 -0
  118. package/dist-lib/types/psOpsPath.d.ts +6 -0
  119. package/dist-lib/types/psOpsState.d.ts +8 -0
  120. package/dist-lib/types/psResources.d.ts +19 -0
  121. package/dist-lib/types/psShading.d.ts +37 -0
  122. package/dist-lib/types/regionBool.d.ts +22 -0
  123. package/dist-lib/types/sampleData.d.ts +10 -0
  124. package/dist-lib/types/sha256.d.ts +5 -0
  125. package/dist-lib/types/sourceRef.d.ts +15 -0
  126. package/dist-lib/types/svg.d.ts +160 -0
  127. package/dist-lib/types/tableBorders.d.ts +42 -0
  128. package/dist-lib/types/textTransform.d.ts +9 -0
  129. package/dist-lib/types/types.d.ts +1566 -0
  130. package/dist-lib/types/unicodeData.d.ts +40 -0
  131. package/dist-lib/types/units.d.ts +2 -0
  132. package/dist-lib/types/vp8.d.ts +6 -0
  133. package/dist-lib/types/vp8Tables.d.ts +14 -0
  134. package/dist-lib/types/webp.d.ts +12 -0
  135. package/dist-lib/types/xhtml.d.ts +4 -0
  136. package/dist-lib/types/xslfoImport.d.ts +63 -0
  137. package/package.json +91 -4
@@ -0,0 +1,29 @@
1
+ > English translation of [CHANGELOG.md](CHANGELOG.md) (the Japanese text is the original).
2
+
3
+ # Changelog
4
+
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
+
7
+ ## 0.1.1 (2026-11-09)
8
+
9
+ A release that completes the notices for third-party software and documents. Typesetting behaviour and the API are the same as in 0.1.0.
10
+
11
+ - **Third-party notices** (`THIRD_PARTY_NOTICES.md`, also included in the `dist-lib`, `dist-cli` and `dist-browser` distributions):
12
+ - Added the copyright notices and licenses (including the full text of the W3C Document License) for the default style sheet rules copied from W3C documents (CSS Ruby 1 Appendix A.1 and CSS 2.1 Appendix D)
13
+ - Stated that part of the WebP decoding code is derived from libwebp (the libwebp notice has been included since 0.1.0)
14
+ - Added the distribution terms of the Adobe font metrics (AFM) for the standard 14 fonts, included in @pdf-lib/standard-fonts
15
+ - Corrected the description of which distributions bundle the dependencies (`dist-browser` also bundles @xmldom/xmldom; `dist-lib` bundles none)
16
+ - **README**: states that `LICENSE`, `NOTICE` and `THIRD_PARTY_NOTICES.md` are included in the output of all four builds
17
+ - **Documents**: the "Sources" appendix of the Conformance Guides (Japanese and English) now gives the version, copyright notice and full license text of each quoted W3C specification
18
+
19
+ ## 0.1.0 (2026-11-08)
20
+
21
+ The first public release.
22
+
23
+ - **Input**: HTML+CSS (own CSS cascade), XSL-FO 1.1 (supports part of Antenna House's `axf:*` extensions, focusing on the commonly used ones), JSON logical tree
24
+ - **Japanese typesetting**: vertical and horizontal writing, ruby, tate-chu-yoko, emphasis marks (kenten), line-breaking rules (kinsoku), hanging punctuation and pushing out, punctuation compression, spacing between Japanese and Latin text (JLREQ)
25
+ - **Pages**: page masters, running heads and page numbers (folios), footnotes, multi-column layout, floats, tables (splitting, repeated headers, automatic column width), page number references, bookmarks, links, annotations, forms
26
+ - **Output**: Canvas preview, PDF (subset font embedding, trim marks, PDF/X-3 marking)
27
+ - **Other scripts**: right-to-left scripts such as Arabic and Hebrew (UAX #9, joined forms of Arabic letters), Latin hyphenation
28
+ - **Usage**: the browser web app, the Node CLI `kumiori` (`--help`, `--version`, `--lang ja|en` and `KUMIORI_LANG` for English messages, a cache for the default fonts, warnings for unsupported CSS and XSL-FO), the library (`kumiori`: ES module; `kumiori/browser`: a single file for browsers with the dependencies bundled)
29
+ - **Documentation**: the Conformance Guide (HTML and CSS volume, XSL-FO volume; Japanese and English editions), the Area Tree JSON specification, and English versions of the README and docs (README.en.md, docs/en/)
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ > English: [CHANGELOG.en.md](CHANGELOG.en.md)
2
+
3
+ # 変更の記録
4
+
5
+ 版の番号は [セマンティック バージョニング](https://semver.org/lang/ja/) に従います。0.x の間は、互換の無い変更も minor の版 (0.2.0 など) で出すことがあります。
6
+
7
+ ## 0.1.1 (2026-11-09)
8
+
9
+ 第三者のソフトウェアと文書の表示を補った版。組版の動きと API は 0.1.0 と同じです。
10
+
11
+ - **第三者の表示** (`THIRD_PARTY_NOTICES.md`。配布物の `dist-lib`・`dist-cli`・`dist-browser` にも入る):
12
+ - W3C の文書から写した既定のスタイルシートの規則 (CSS Ruby 1 の付録 A.1、CSS 2.1 の付録 D) の著作権表示とライセンス (W3C Document License の本文を含む) を足した
13
+ - WebP の読み込みのコードの一部が libwebp から派生していることを明記した (libwebp の表示は 0.1.0 から載せていたもの)
14
+ - @pdf-lib/standard-fonts に含まれる Adobe の標準 14 書体の寸法 (AFM) の配布条件の本文を足した
15
+ - 依存パッケージを束ねる配布物の説明を直した (`dist-browser` は @xmldom/xmldom も束ね、`dist-lib` は束ねない)
16
+ - **README**: `LICENSE`・`NOTICE`・`THIRD_PARTY_NOTICES.md` が 4 つのビルドの出力すべてに入ることを書いた
17
+ - **文書**: 対応仕様説明書 (日本語版と英語版) の付録「出典」に、引用した W3C の仕様の版・著作権表示・ライセンスの本文を足した
18
+
19
+ ## 0.1.0 (2026-11-08)
20
+
21
+ 最初の公開版。
22
+
23
+ - **入力**: HTML+CSS (自前の CSS カスケード)、XSL-FO 1.1 (アンテナハウスの拡張 `axf:*` のうち、よく使われるものを中心に一部に対応)、JSON の論理ツリー
24
+ - **日本語組版**: 縦書き・横書き、ルビ、縦中横、圏点、禁則、ぶら下げ・追い出し、約物の詰め、和欧間のアキ (JLREQ)
25
+ - **ページ**: ページマスター、柱・ノンブル、脚注、段組、回り込み、表 (分割・ヘッダーの繰り返し・列幅の自動決定)、ページ番号の参照、しおり、リンク、注釈、フォーム
26
+ - **出力**: Canvas のプレビュー、PDF (書体のサブセット埋め込み、トンボ、PDF/X-3 の印)
27
+ - **多言語**: アラビア語・ヘブライ語などの右から左の文字 (UAX #9、アラビア文字の連結形)、欧文のハイフネーション
28
+ - **使い方**: ブラウザの画面、Node のコマンド `kumiori` (`--help`・`--version`、既定の書体のキャッシュ、未対応の CSS・XSL-FO の警告、`--lang ja|en` と `KUMIORI_LANG` で文言を英語にも)、ライブラリ (`kumiori`: ES モジュール、`kumiori/browser`: 依存まで束ねたブラウザ用の 1 ファイル。`lang` オプションで警告を英語にも)
29
+ - **文書**: 対応仕様説明書 (HTML と CSS 編・XSL-FO 編。日本語版と英語版)、Area Tree の JSON の仕様。README と docs の英語版 (README.en.md・docs/en/)
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ Kumiori (組み織り)
2
+ Copyright 2026 Northern Lights Co.
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+ Third-party components and their licenses are listed in THIRD_PARTY_NOTICES.md.
package/README.en.md ADDED
@@ -0,0 +1,278 @@
1
+ <p align="center"><img src="assets/logo/kumiori-logo.svg" alt="Kumiori 組み織り" width="480"></p>
2
+
3
+ > English translation of [README.md](README.md) (the Japanese text is the original).
4
+
5
+ # Kumiori (組み織り)
6
+
7
+ **A library for Japanese typesetting, refined with AI.**
8
+
9
+ A typesetting engine that runs both in the browser and in Node. It reads HTML+CSS and XSL-FO, typesets vertical writing, ruby, line-breaking rules (kinsoku), tables, footnotes and multi-column layouts,
10
+ and outputs a Canvas preview and PDF.
11
+
12
+ ## A typesetting engine refined with AI
13
+
14
+ Kumiori is developed with an AI coding assistant ([Claude Code](https://claude.com/claude-code)) (see "[About the development method](#about-the-development-method)").
15
+
16
+ - **About 54,000 lines of TypeScript, about 1,500 tests**: Each time a feature is added, the AI adds tests, and CI (type checking, unit tests, and 13 browser integration tests) passes
17
+ - **Implemented from the standards and specifications**: Kumiori is implemented by reading the standards and specifications as thoroughly as possible, including XSL-FO 1.1, the CSS modules (Paged Media, GCPM, Writing Modes, Text, Ruby, Fragmentation and others), MathML Core, the Unicode UAX #9 (bidirectional text) and UAX #14 (line breaking), W3C's JLREQ (Requirements for Japanese Text Layout, based on JIS X 4051) and PDF (ISO 32000), and following their definitions. The fine details of Japanese typesetting, such as punctuation compression, hanging punctuation and ruby overhang, are also based on these standards. The support status of each property, with the specification's definition and how Kumiori handles it, is collected in the Conformance Guide ([`docs/en/conformance.md`](docs/en/conformance.md))
18
+ - **Behaviour checked against published PDFs**: The interpretation of the specifications and the finer points of layout are checked by comparing Kumiori's output with sample PDFs that XSL-FO and CSS typesetting tools have published
19
+
20
+ ## Features
21
+
22
+ - **Input**: HTML+CSS (own CSS cascade; no browser needed), XSL-FO (supports part of Antenna House's `axf:*` extensions, focusing on the commonly used ones), JSON logical tree
23
+ - **Japanese typesetting**: vertical and horizontal writing, ruby, tate-chu-yoko, emphasis marks (kenten), line-breaking rules (kinsoku), hanging punctuation and pushing out, punctuation compression, spacing between Japanese and Latin text
24
+ - **Other scripts**: right-to-left scripts such as Arabic and Hebrew (reordered with the Unicode Bidirectional Algorithm, UAX #9; Arabic letters take their joined forms. CSS `direction: rtl`, XSL-FO `writing-mode="rl-tb"`), Latin hyphenation, and mixed Japanese and Latin text. Fonts for Arabic and other scripts are passed with `--font` or `fonts` (the default fonts do not include them)
25
+ - **Pages**: page masters, running heads and page numbers (folios), footnotes, multi-column layout, floats, tables (splitting across rows and pages, repeated headers, automatic column width), page number references
26
+ - **Output**: Canvas preview, PDF (subset font embedding, bookmarks, links, annotations, forms, trim marks, PDF/X-3 marking with conversion of RGB colors and images to CMYK)
27
+ - The PDF/X-3 marking (`pdfx` in the API) has been verified only for the parts defined by the PDF specification ISO 32000-2 (such as the form of the output intent dictionary). It has not been verified against the text of the PDF/X standard ISO 15930, so conformance to that standard is not guaranteed
28
+ - **Environments**: browser (Vite) and the Node CLI (`dist-cli/cli.js`)
29
+
30
+ Internally, every box is computed in pt following the XSL-FO **Area Model**, a **physical tree (Area Tree)** is assembled, and then it is drawn to
31
+ Canvas and **PDF (pdf-lib + fontkit)**.
32
+
33
+ ## Usage
34
+
35
+ Kumiori can be used in three forms.
36
+
37
+ | Form | How to get it | Suited for |
38
+ | --- | --- | --- |
39
+ | **Web app (browser)** | Open the web app hosted on GitHub Pages (<https://n-lights-co.github.io/kumiori/>). Or put the `dist/` from `npm run build` on a static web server | Picking a document and saving a PDF |
40
+ | **Node CLI** | `npm install -g kumiori`, or without installing, `npx kumiori book.html -o book.pdf` | Converting without a browser, or converting in batches |
41
+ | **Library** | `npm install kumiori` (`import { typeset } from 'kumiori'`). In a browser without a bundler, `kumiori/browser` from a CDN | Typesetting from your own program |
42
+
43
+ The default fonts (Noto Serif JP etc.) are not included in the package; they are fetched from Google Fonts on first run (the Node CLI saves them to a local cache and reuses them; see "[Fonts](#fonts)").
44
+
45
+ To run this repository locally:
46
+
47
+ ```bash
48
+ npm install
49
+ npm run dev # http://localhost:5173 (preview + "Save PDF")
50
+ npm run build # type check + production build (dist/; the web app)
51
+ npm run build:dist # build the library (dist-lib), the Node CLI (dist-cli) and the single browser file (dist-browser) together
52
+ ```
53
+
54
+ Node 20 or later is required (CI tests with 22; recursive watching for `--watch` needs Node 20 or later). The release procedure is in [`docs/en/RELEASING.md`](docs/en/RELEASING.md), and the changes in each version are in [`CHANGELOG.en.md`](CHANGELOG.en.md).
55
+
56
+ ### Web app (browser)
57
+
58
+ - "Open" (開く) lets you select HTML, XSL-FO or EPUB files together with the CSS, images and fonts they use (several can be selected). "Open folder" (フォルダを開く) selects a whole folder; you can also open files or folders by dragging and dropping them onto the page. When a folder contains several documents, index.html (or, failing that, the document at the shallowest location) is opened
59
+ - "Save PDF" (PDF を保存) writes out the PDF. On the left are page thumbnails and warnings (collapsible); "Settings" (設定) on the right has the default style, the CSS interpretation, "Typeset with the spec's default values" (the XSL-FO default-value convention; the same as the CLI's `--compat`), trim marks and font loading
60
+ - All typesetting happens inside the browser; documents and fonts are never sent out (the only things fetched from outside are the default fonts and the images the document references via `http(s):`). It also works when the `dist/` from `npm run build` is placed on a static web server
61
+
62
+ ### Node CLI (HTML+CSS and XSL-FO to PDF without a browser)
63
+
64
+ When installed from npm the command is `kumiori` (or `npx kumiori` to use it without installing); when built in this repository, `node dist-cli/cli.js` is the same command.
65
+
66
+ ```bash
67
+ npx kumiori book.html -o book.pdf
68
+ npx kumiori book.fo -o book.pdf
69
+ npx kumiori a.html b.fo c.html -o out
70
+ npx kumiori book.html --watch
71
+ ```
72
+
73
+ ```bash
74
+ npm run build:cli # when building in this repository
75
+ node dist-cli/cli.js book.html -o book.pdf
76
+ ```
77
+
78
+ ```bash
79
+ cat book.html | node dist-cli/cli.js - -o - --base . > book.pdf
80
+ ```
81
+
82
+ - With several inputs, `-o` (`--output`) is the output directory (if omitted, a `.pdf` is written next to each input). If one fails, the others are still produced (the exit code is 1). Even with a single input, if `-o` is an existing directory, `<input name>.pdf` is written inside it
83
+ - `-` reads from standard input (CSS, images and fonts come from the `--base` directory (default: the current directory); whether the input is FO is detected from its content). `-o -` writes the PDF to standard output
84
+ - The character encoding of the input is determined from the BOM, the XML declaration's `encoding` (`Shift_JIS`, `EUC-JP`, etc.) and HTML's `<meta charset>` (UTF-8 if none)
85
+ - Images the document references via `http(s):` are fetched from the network by default. `--no-fetch-images` disables this (e.g. when typesetting documents written by others on a server; they are typeset as unreadable images)
86
+ - `--watch`: re-typesets whenever the HTML, FO, CSS, images or fonts in the input's directory change
87
+ - `--help` (`-h`) prints the usage, `--version` (`-v`) prints the version
88
+ - Unsupported CSS properties and values (listed in chapter 16 of the Conformance Guide), properties unknown to Kumiori (misspelled or unsupported), XSL-FO elements and properties that cannot be read, unreadable images and so on are not silently ignored but reported as `警告:` ("warning:") messages (in the library, `result.warnings`)
89
+
90
+ - CSS, images and fonts in the same directory as the HTML (and in subdirectories) are used (the same as selecting them together in the web app). Only images whose names appear in the document and the CSS are read. `--css a.css,b.css` selects the CSS to use (comma-separated for several; `@import` targets are used too. CSS not referenced from the HTML is added as a user stylesheet)
91
+ - `--style kumiori|browser|browser-margin|ah|vivliostyle|weasyprint`: the default style (the same as "Default style" under "Settings" in the web app; the default is kumiori)
92
+ - `--font-dir <dir>`: the directory from which the default fonts (`NotoSerifJP-Regular.ttf`, `NotoSansJP-Regular.ttf`, `NotoSansJP-Bold.ttf`, `Tinos-*.ttf`, `Arimo-*.ttf`, `Cousine-*.ttf` when monospace is specified, `STIXTwoMath-Regular.ttf` when there is MathML, and `NotoSansSymbols2-Regular.ttf` when there are symbols found in none of the fonts) are read. If absent, the font cache is tried, then Google Fonts
93
+ - `--font-cache <dir>`: the directory in which the default fonts fetched from Google Fonts are saved and reused. The default is the environment variable `KUMIORI_FONT_CACHE`, or else the OS cache (on Linux `kumiori/fonts` under `$XDG_CACHE_HOME` or `~/.cache`, on macOS `~/Library/Caches/kumiori/fonts`, on Windows `%LOCALAPPDATA%\kumiori\fonts`). Fonts are fetched from the network only the first time, with the message `書体 … を取得して … に保存しました` ("fetched font … and saved it to …"). From the second run on, the network is not used. Anything that is not a font file, such as an interrupted download, is not saved, and a corrupt cache is discarded and fetched again. Conversion continues even where the cache cannot be written
94
+ - `--no-font-cache`: neither reads nor writes the font cache (fetches from Google Fonts every time)
95
+ - `--lang ja|en`: language of the usage text, reports, warnings and error messages. Without it, the environment variable `KUMIORI_LANG` is used, then the OS locale (`LC_ALL`, `LC_MESSAGES`, `LANG` starting with `en` means English). The default is Japanese
96
+ - `--font <font file>` (repeatable): adds a font file (TTF, OTF, TTC) (for a TTC, each font inside is added). Fonts are registered by the family name in the font's name table and the weight in its OS/2 table, and used from `font-family` like fonts installed on the system (italic files are not registered). In compatibility styles such as `--style ah`, fonts are also selected by the PostScript name written in SVG's `font-family` (e.g. `'CenturyGothic'`)
97
+ - `--generic-font serif=<font name>`, `--generic-font sans-serif=<font name>`: the font used for Latin text of the generic fonts (serif, sans-serif) (the family name of a font added with `--font`)
98
+ - `--print`: trim marks and bleed (3mm)
99
+ - `--image-max-dpi <dpi>`: JPEG photos finer than this relative to the size they are placed at are downscaled to this resolution and re-encoded (makes the PDF smaller; by default they are left as they are)
100
+ - `--spot-colors <JSON file>`: the names of spot colors and the alternate CMYK at 100% tint (`{"name": "cmyk(20%,40%,60%,80%)"}` or `{"name": [0.2,0.4,0.6,0.8]}`; the array holds numbers from 0 to 1, and a value over 1 is an error). Among `rgb-icc(r,g,b,#Separation,'name',tint)` colors, those whose name is listed here are written as a PDF Separation (the alternate color space is DeviceCMYK, and the tint transform is linear). Those whose name is not listed are written with the alternate RGB as before. Names are written in UTF-8 (ISO 32000-2 §7.3.5). Spot color values (such as those of swatch books) are not included in Kumiori; the user supplies them
101
+ - HTML is read with linkedom, and the CSS computed values come from the own cascade (the same as "CSS interpretation: Kumiori" in the web app)
102
+ - XHTML (`.xhtml`, `.xht`) is read with XML syntax, rewritten according to namespaces, and then typeset the same as HTML (prefixed elements such as `<s:svg xmlns:s="http://www.w3.org/2000/svg">` also become SVG; `src/xhtml.ts`). `.html` is read with HTML syntax, so prefixed elements do not become SVG. With `--xhtml`, XML syntax is used regardless of the extension
103
+ - MathML (`<math>`) is typeset with the math font (`STIXTwoMath-Regular.ttf`) and turned into glyph outline shapes (`src/mathLayout.ts`, shared with XSL-FO). Formulas with `display="block"` are centered on the line
104
+ - XSL-FO (`.fo`, `.xml`, or `--fo`) is typeset the same as XSL-FO import in the web app. `--compat spec|antenna` is the default-value convention (XSL-FO 1.1 initial values (default) / AH Formatter compatible defaults; other values are an error). Font files (TTF, OTF, TTC) in the same directory are used by the name in the FO's `font-family`
105
+ - Images in PNG, JPEG, GIF, BMP, TIFF, WebP, SVG, WMF, EMF, EPS (PostScript) and CGM are placed in the PDF. SVG that cannot be converted to shapes (e.g. filters other than shadows and blur) is drawn as a placeholder frame with a warning (the web app rasterizes and draws it)
106
+
107
+ ### Using as a library (from TypeScript or JavaScript)
108
+
109
+ ```bash
110
+ npm install kumiori
111
+ ```
112
+
113
+ When building in this repository, `npm run build:lib` (dist-lib/; ES modules and type declarations).
114
+
115
+ ```ts
116
+ import { typeset, walkAreaTree } from 'kumiori';
117
+
118
+ // HTML+CSS (XSL-FO is typeset with the same function; the kind is detected from the extension of name or from the content)
119
+ const result = await typeset(html, {
120
+ name: 'book.html',
121
+ files: [
122
+ { name: 'book.css', data: cssText }, // CSS, images and fonts are { name, data }
123
+ { name: 'img/cover.jpg', data: async () => readBytes('img/cover.jpg') }, // a function that reads only when used is fine too
124
+ ],
125
+ loadFont: async (spec) => readLocalFont(spec), // how to load the default fonts (if omitted, fetched from Google Fonts)
126
+ });
127
+ console.log(result.pageCount, result.warnings);
128
+ walkAreaTree(result.areaTree, (area) => { /* walk the typeset result (Area Tree) */ });
129
+ const pdf = await result.toPdf(); // Uint8Array
130
+ result.renderPage(canvas, 0); // draw page 1 onto a canvas (browser)
131
+ ```
132
+
133
+ - `typeset(text, options)` is the entry point (`typesetHtml` and `typesetFo` are variants that fix the kind). It does not touch the file system, and uses the network only to fetch the default fonts (replaceable with `loadFont`) and the images the document references via `http(s):` (can be stopped with `fetchImages`), so it runs both in the browser and in Node
134
+ - `text` is a string. When reading from a file, converting it to a string with `decodeDocumentText(bytes)` decodes it according to the BOM, the XML declaration's `encoding` and `<meta charset>` (reading as fixed UTF-8 garbles Shift_JIS FO and the like)
135
+ - Main `options`: `kind` (`html`, `xhtml`, `fo`; if omitted, determined from `name` and the content), `name` (the input file name), `files` (CSS, images, fonts), `fonts` (fonts to add), `genericFonts` (fonts for Latin text of the generic fonts), `style` (the default style for HTML), `compat` (the XSL-FO default-value convention), `print` (bleed and trim marks), `spotColors` (alternate CMYK for spot colors), `loadFont`, `fetchTimeoutMs` (timeout for fetching fonts and images; default 30 seconds), `fetchImages` (whether to fetch the images the document references via `http(s):`; default `true`; `false`, or a function that takes a URL and returns a boolean; when typesetting others' documents on a server, disable it or allow only certain URLs), `lang` (language of `warnings` and error messages: `ja` or `en`; default Japanese), `deflate` (in Node, passing `zlib.deflateSync` speeds up PDF output)
136
+ - `result.toPdf({ title, pdfx, imageMaxDpi })`: the PDF title, the PDF/X-3 marking (`pdfx`; RGB colors and images are converted to CMYK), the upper limit of JPEG resolution. `result.renderPage(canvas, i, { scale, devicePixelRatio, guides })`: the scale, the device pixel density, and guide lines for the trim box and bleed
137
+ - Internal entities declared in the internal subset of the FO's DOCTYPE (such as `<!ENTITY nbsp "&#160;">`) are expanded before import (external entities are not read)
138
+ - Exceptions: `typeset` throws when the FO's XML cannot be parsed (`XML の解析に失敗しました: …`, "failed to parse XML: …") and when the default fonts cannot be read (`書体を読めません: …`, "cannot read font: …"). A corrupt font file passed in `fonts` does not throw but goes into `warnings`. A nonexistent page number for `renderPage` is a `RangeError`. Typesetting warnings (unreadable images, overflow, etc.) do not throw but go into `result.warnings` (an array of strings)
139
+ - The fonts used by default can be found in `DEFAULT_FONTS` (the `family`, `weight` and `urls` of the `spec` passed to `loadFont`)
140
+ - Only what is exported from `src/index.ts` is public (the functions and types of other modules may change between versions)
141
+ - `kumiori` (`dist-lib/index.js`) is an ES module that does not bundle its dependencies (pdf-lib, fontkit, xmldom, etc.). Use it with a bundler such as Vite or webpack, or load it from Node. Since it is ES module only, loading it with `require()` requires Node 22 or later
142
+ - In a browser without a bundler, use `kumiori/browser`, a single file with the dependencies bundled (`dist-browser/kumiori.js`; about 2.7MB, 0.9MB gzipped; the hyphenation dictionaries and the like are loaded as separate files only when used). The version published on npm can be loaded directly from the jsDelivr or unpkg CDN:
143
+
144
+ ```html
145
+ <script type="module">
146
+ import { typesetHtml } from 'https://cdn.jsdelivr.net/npm/kumiori@0.1.1/dist-browser/kumiori.js';
147
+ const result = await typesetHtml(html, { name: 'a.html' });
148
+ result.renderPage(document.querySelector('canvas'), 0);
149
+ </script>
150
+ ```
151
+
152
+ #### Showing a print preview in the browser (renderPage)
153
+
154
+ `result.renderPage(canvas, pageNumber, { scale })` draws a typeset page onto a canvas (page numbers start at 0). Glyphs are drawn from the outlines in the font files, so the page's CSS and `@font-face` have no effect on them. In the browser, HTML is parsed with the browser's DOMParser (linkedom is used only in Node).
155
+
156
+ Example: typeset the HTML being edited in an editor each time the user pauses, and show it in a preview
157
+
158
+ ```ts
159
+ import { typeset } from 'kumiori';
160
+
161
+ const printCss = '@page { size: A4; margin: 20mm; @bottom-center { content: counter(page) } } body { font-family: serif }';
162
+ const fontCache = new Map<string, Promise<ArrayBuffer>>();
163
+ const loadFont = (spec) => { // fetch the default fonts only once and reuse them
164
+ const key = `${spec.family}|${spec.weight ?? 400}`;
165
+ if (!fontCache.has(key)) fontCache.set(key, fetch(spec.urls.find((u) => u.startsWith('https:'))!).then((r) => r.arrayBuffer()));
166
+ return fontCache.get(key)!;
167
+ };
168
+
169
+ async function showPreview(bodyHtml: string, container: HTMLElement) {
170
+ const r = await typeset(`<!doctype html><html lang="ja"><body>${bodyHtml}</body></html>`, {
171
+ kind: 'html',
172
+ files: [{ name: 'print.css', data: printCss }], // CSS not referenced from the document is added as a user stylesheet
173
+ loadFont,
174
+ });
175
+ container.replaceChildren();
176
+ for (let i = 0; i < r.pageCount; i++) {
177
+ const canvas = document.createElement('canvas');
178
+ r.renderPage(canvas, i, { scale: 1 }); // 1pt = 1 CSS px (actual size is 96 / 72)
179
+ container.append(canvas);
180
+ }
181
+ }
182
+ ```
183
+
184
+ - When typesetting repeatedly (e.g. for an editor preview), create a container with `createTypesetter()` that loads the fonts only once, and typeset with `typesetter.typeset(html, options)`. This is faster because the fonts are not fetched and parsed every time (the math, monospace and symbol fonts are loaded the first time a document that uses them is typeset)
185
+ - Working sample: after `npm run dev`, open http://localhost:5173/examples/preview/ (`examples/preview/`). Edit the editing area on the left, the "HTML" box below it (write headings, ruby, tables and so on directly; it and the editing area mirror each other) or the print CSS, and the right side is re-typeset when you pause. It uses only Kumiori's public API and has no other dependencies. To connect another editor, call the equivalent of the sample's `schedule(editor HTML)` from the notification that the editor's content has changed
186
+
187
+ ## Structure
188
+
189
+ | File | Role |
190
+ | --- | --- |
191
+ | `src/index.ts`, `src/api.ts` | Public API (`typeset`, `createTypesetter`, `DEFAULT_FONTS`, etc. Only what is exported from `src/index.ts` is public) |
192
+ | `src/types.ts` | Types for the logical tree (Input), the physical tree (Area Tree) and page settings |
193
+ | `src/areaTree.ts`, `src/areaResources.ts` | Walking the Area Tree and reading/writing it as JSON ([`docs/en/area-tree.md`](docs/en/area-tree.md)); the list of fonts and images used |
194
+ | `src/fontManager.ts` | Fetches TTF/OTF → `FontFace` (Canvas) + `ArrayBuffer` (PDF) + fontkit (metrics) |
195
+ | `src/measurer.ts`, `src/jis.ts` | Character width measurement (both Canvas and fontkit backends), measurement for vertical writing, ruby and tate-chu-yoko, line-breaking rules (kinsoku) |
196
+ | `src/geometry.ts`, `src/lnode.ts` | Conversion between logical (inline/block) and physical coordinates, intermediate layout tree |
197
+ | `src/inlineLayout.ts`, `src/inlineFlatten.ts`, `src/lineMetrics.ts` | Line breaking (kinsoku, hanging punctuation, pushing out), inline placement, generation of line nodes for ruby/tate-chu-yoko, inline tree → sequence of characters (Atom), line height (three models: CSS, XSL and compatibility) |
198
+ | `src/layoutEngine.ts` | Blocks, pagination, tables, absolute positioning; logical → physical (Area Tree) conversion |
199
+ | `src/footnotes.ts`, `src/tableBorders.ts`, `src/lineBreak.ts`, `src/bidi.ts`, `src/hyphenation.ts`, `src/counterStyle.ts` | Footnotes, collapsing of table borders, line break opportunities (UAX #14), bidirectional text (UAX #9), hyphenation, CSS counter-style |
200
+ | `src/paint.ts` | Area Tree traversal + trim mark geometry (shared by Canvas and PDF) |
201
+ | `src/canvasRenderer.ts`, `src/pdfRenderer.ts`, `src/pdfLibPatches.ts`, `src/matrix.ts` | Canvas / PDF renderers, replacements of pdf-lib internals (gathered in one place), matrices and Seg |
202
+ | `src/sampleData.ts`, `src/main.ts`, `index.html` | The ultimate sample and the preview UI |
203
+ | `src/htmlImport.ts`, `src/htmlPaged.ts`, `src/htmlPrepare.ts`, `src/htmlFrame.ts` | HTML+CSS import (computed values → logical tree, CSS for paged typesetting, collecting the CSS, import in the web app (the own cascade by default, a browser iframe for comparison)) |
204
+ | `src/cssCascade.ts`, `src/cssSelector.ts`, `src/cssText.ts` | CSS interpretation without a browser (cascade, computed values, selectors), CSS lexical helpers (separators, lengths, colors) |
205
+ | `src/xslfoImport.ts`, `src/foExpr.ts`, `src/foDom.ts`, `src/foContext.ts`, `src/foPageMaster.ts`, `src/foMathFallback.ts` | XSL-FO import (attributes → logical tree, expression evaluation, minimal DOM, page masters, MathML typesetting when no math font is available) |
206
+ | `src/svg.ts`, `src/mathLayout.ts` | Converting SVG to shapes, MathML typesetting |
207
+ | `src/jpeg.ts`, `src/webp.ts`, `src/vp8.ts`, `src/pixels.ts`, `src/ccitt.ts`, `src/imageLimits.ts`, `src/metafile.ts`, `src/cgm.ts`, `src/eps.ts`, `src/ps*.ts` (`psInterp`, `psGraphics`, `psOps*` per operator group, `psResources`, `psColorSpace`, `psFonts`, `psCff`, `psImage`, `psFilters`), `src/imageInfo.ts`, `src/base64.ts` | Image decoding (JPEG, WebP, GIF, BMP, TIFF) and limits, conversion of WMF/EMF, CGM and EPS (PostScript interpreter) to shapes, reading image dimensions |
208
+ | `src/epub.ts`, `src/xhtml.ts` | EPUB extraction, XHTML import |
209
+ | `src/fontMapping.ts`, `src/compat.ts`, `src/documentResources.ts`, `src/documentText.ts`, `src/cli.ts` | Font assignment, compatibility mode settings, fetching the math font and images, character encoding detection (shared by the web app and Node); the Node CLI |
210
+
211
+ For details of the typesetting algorithms see [`docs/en/REPORT.md`](docs/en/REPORT.md), for XSL-FO import [`docs/en/xslfo-import.md`](docs/en/xslfo-import.md), and for the plan for HTML+CSS import [`docs/en/html-css-plan.md`](docs/en/html-css-plan.md).
212
+ Per-item descriptions of the supported specifications are in the Conformance Guide ([`docs/conformance/`](docs/en/conformance.md); `npm run docs:conformance` turns it into PDFs), features not yet available and known limitations are in [`docs/en/BACKLOG.md`](docs/en/BACKLOG.md), and the JSON of the typeset result (Area Tree) is described in [`docs/en/area-tree.md`](docs/en/area-tree.md).
213
+
214
+ ## Fonts
215
+
216
+ The fonts for typesetting are not included in this repository. They are fetched at run time from Google Fonts' distribution host (`fonts.gstatic.com`).
217
+
218
+ | Font | Use | License |
219
+ | --- | --- | --- |
220
+ | Noto Serif JP, Noto Sans JP | Japanese (Mincho, Gothic) | SIL Open Font License 1.1 |
221
+ | Tinos, Arimo | Latin (serif, sans-serif) | Apache License 2.0 |
222
+ | Cousine | When monospace is specified | Apache License 2.0 |
223
+ | STIX Two Math | When there are formulas (MathML). MathML is typeset with the values of this font's MATH table | SIL Open Font License 1.1 |
224
+ | Noto Sans Symbols 2 | When the document contains symbols (such as ✈) found in none of the loaded fonts | SIL Open Font License 1.1 |
225
+
226
+ The Node CLI saves the fetched fonts to the OS cache (`~/.cache/kumiori/fonts` etc.; can be changed with `--font-cache`) and does not use the network from the second run on. For offline use, in the web app (browser), TTFs with the same names placed in `public/fonts/` are used as a fallback (not tracked by git). With the Node CLI, either run once online to fill the cache, or specify the directory to read with `--font-dir`. The library's (`typeset`) default fetching tries only `https:` URLs, so pass local fonts via `loadFont`.
227
+ Fonts placed in `public/fonts/` are also copied to the build output (`dist/fonts/`, `dist-cli/fonts/`). If you do not want them in what you distribute, remove them before building. The Node CLI does not read the copied `dist-cli/fonts/` automatically (it looks only at the directory passed, e.g. `--font-dir dist-cli/fonts`).
228
+
229
+ The fonts used are embedded in the PDF. Check the license terms of each font with its distributor.
230
+
231
+ ## Units and coordinates
232
+
233
+ - The internal unit is **pt** (only page settings use mm). An Area's `x,y` are physical coordinates relative to the top left of the parent's content-box (y pointing down).
234
+ - Absolute positioning (`absolutePosition`) is relative to the **top left of the trim box**. To reach into the bleed, specify negative `top/left`.
235
+ - `width/height` default to `content-box`. `boxSizing: 'border-box'` makes them include padding/border.
236
+
237
+ ## License
238
+
239
+ The code is under the [Apache License 2.0](LICENSE) (Copyright 2026 Northern Lights Co.; see [NOTICE](NOTICE)). The fonts for typesetting are not bundled in this repository (for the fonts and their licenses, see the "[Fonts](#fonts)" section).
240
+
241
+ The licenses and copyright notices of the third-party software Kumiori uses (pdf-lib, pako, utif, hyphen, etc.) are collected in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). The output of `npm run build`, `npm run build:cli`, `npm run build:lib` and `npm run build:browser` (`dist/`, `dist-cli/`, `dist-lib/`, `dist-browser/`) also contains `LICENSE`, `NOTICE` and `THIRD_PARTY_NOTICES.md`.
242
+
243
+ ## Relationship to other companies' products
244
+
245
+ Kumiori is an independent project, unrelated to Antenna House's products or to typesetting software such as WeasyPrint and Vivliostyle. It has not received approval or support from these companies or projects.
246
+
247
+ The product and company names appearing in the README and docs are the trademarks or names of their respective owners. Kumiori uses these names to describe its compatibility features (import of the `axf:*` extensions, the default values of `--compat antenna`, etc.).
248
+
249
+ ## About the development method
250
+
251
+ Kumiori is developed with an AI coding assistant (Anthropic's Claude Code).
252
+ Much of the code, tests and documentation is written by the AI. People decide what to build and how to follow each specification,
253
+ check the typesetting results, direct the fixes, and review changes before they are merged.
254
+ Specifications are interpreted by reading them and comparing Kumiori's output with published sample PDFs.
255
+ Third-party code and licenses are checked with tools before each release (see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)).
256
+
257
+ ## Tests
258
+
259
+ ```bash
260
+ npm test # unit tests (Node + fontkit; fetches Noto Serif JP into .cache/fonts)
261
+ npm run e2e # browser integration tests (Playwright; on first run, npx playwright install chromium)
262
+ ```
263
+
264
+ Comparison with sample PDFs (prepare the sample FO and PDF files yourself; they are not in the repository. poppler's pdftoppm is required):
265
+
266
+ ```bash
267
+ node scripts/compare-pdf.mjs --fo <FO directory> --ref <sample PDF directory> --img <image directory> --out compare-pdf-out
268
+ ```
269
+
270
+ Each FO is paired with the PDF of the same name. `compare-pdf-out/report.md` lists the page count of each sample and the difference of each page (largest differences first).
271
+
272
+ To build a page for comparing the samples and Kumiori's output by eye (the sample PDFs and Kumiori's PDFs are paired by the same name):
273
+
274
+ ```bash
275
+ node scripts/compare-view.mjs --ref <sample PDF directory> --pdf <Kumiori PDF directory> --out compare-view-out
276
+ ```
277
+
278
+ Open `compare-view-out/index.html` in a browser. The samples are sorted with the largest differences first, and for each page you can switch between "Side by side", "Overlay" (with adjustable opacity), "Blink" and "Diff" (blue where only the sample has text or lines, red where only Kumiori does). `--inline` produces a single HTML file with the images embedded. `--jpeg` makes the page images JPEG to reduce their size. `--artifact` writes it out in a form for publishing as a claude.ai Artifact (the diff images are drawn in the browser).