@sushichan044/kg-core 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -8
- package/dist/index.d.mts +24503 -20300
- package/dist/index.mjs +627 -155
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,16 +56,25 @@ visible and produces a parser warning.
|
|
|
56
56
|
`composeManuscript` requires a composer. The built-in `novelComposer` produces
|
|
57
57
|
a self-contained snapshot containing the parsed manuscript, accepted settings,
|
|
58
58
|
geometry, statistics, and a page/stage/line hierarchy. Lines contain positioned
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
inline items and annotation fragments. `glyph` items distinguish their typographic
|
|
60
|
+
`layoutSpan` from their visual `renderSpan`; `glue`, `kern`, and `suppressed` items
|
|
61
|
+
preserve every spacing decision. Each line also records its `inlineSizeEm` and
|
|
62
|
+
whether it ended naturally, by shrinking, stretching, hanging, forcing, or reaching
|
|
63
|
+
the paragraph end.
|
|
64
|
+
|
|
65
|
+
The composer classifies the core prose classes from JLReq, resolves pair spacing,
|
|
66
|
+
and selects line breaks over the whole source paragraph. It prefers natural setting,
|
|
67
|
+
then shrinking punctuation space, hanging a comma or full stop, stretching eligible
|
|
68
|
+
space, and finally a forced emergency line. It owns Japanese line-start and line-end
|
|
69
|
+
restrictions, inseparable punctuation, question/exclamation gap suppression, and
|
|
70
|
+
ruby placement.
|
|
62
71
|
|
|
63
72
|
The composer classifies vertical text before measuring and breaking lines. Following
|
|
64
73
|
[JLReq](https://www.w3.org/TR/jlreq/#handling_of_western_text_in_vertical_writing),
|
|
65
74
|
upright Latin initials and abbreviations advance by one em per character, Western
|
|
66
75
|
words remain unbroken and render sideways, and two ASCII digits form one
|
|
67
76
|
tate-chu-yoko unit. The resulting `VerticalTextPresentation` is carried by every
|
|
68
|
-
|
|
77
|
+
glyph item, so renderers do not need to infer orientation independently.
|
|
69
78
|
|
|
70
79
|
The default logical measurer uses East Asian Width in a Japanese context. Upright
|
|
71
80
|
ASCII advances by one em; proportional ASCII and the members of a tate-chu-yoko unit
|
|
@@ -74,18 +83,19 @@ font metrics. Base-text requests also include the selected `presentation`:
|
|
|
74
83
|
|
|
75
84
|
```ts
|
|
76
85
|
const composer = createNovelComposer({
|
|
77
|
-
measurer: (request) =>
|
|
78
|
-
measureWithAvailableFont(request.text, {
|
|
86
|
+
measurer: (request) => ({
|
|
87
|
+
advanceEm: measureWithAvailableFont(request.text, {
|
|
79
88
|
role: request.role,
|
|
80
89
|
fontPreset: request.fontPreset,
|
|
81
90
|
writingMode: request.writingMode,
|
|
82
91
|
...(request.role === "base" ? { presentation: request.presentation } : {}),
|
|
83
92
|
}),
|
|
93
|
+
}),
|
|
84
94
|
});
|
|
85
95
|
```
|
|
86
96
|
|
|
87
|
-
A measurer returns logical em units. Negative or non-finite
|
|
88
|
-
composition instead of producing a partial layout.
|
|
97
|
+
A measurer returns `{ advanceEm }` in logical em units. Negative or non-finite
|
|
98
|
+
results reject the composition instead of producing a partial layout.
|
|
89
99
|
|
|
90
100
|
Ruby annotations retain one of three associations: `group` for one reading over
|
|
91
101
|
the entire base, `mono` for one reading segment per base grapheme, and `jukugo`
|