@kurot/core 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +37 -2
- package/dist/kurot/display/DisplayObject.d.ts +2 -1
- package/dist/kurot/display/DisplayObject.d.ts.map +1 -1
- package/dist/kurot/display/DisplayObject.js.map +1 -1
- package/dist/kurot/player/canvas/CanvasRenderer.d.ts +2 -0
- package/dist/kurot/player/canvas/CanvasRenderer.d.ts.map +1 -1
- package/dist/kurot/player/canvas/CanvasRenderer.js +37 -1
- package/dist/kurot/player/canvas/CanvasRenderer.js.map +1 -1
- package/dist/kurot/player/pipes/BitmapTextPipe.d.ts +20 -0
- package/dist/kurot/player/pipes/BitmapTextPipe.d.ts.map +1 -0
- package/dist/kurot/player/pipes/BitmapTextPipe.js +27 -0
- package/dist/kurot/player/pipes/BitmapTextPipe.js.map +1 -0
- package/dist/kurot/player/pipes/index.d.ts +2 -0
- package/dist/kurot/player/pipes/index.d.ts.map +1 -1
- package/dist/kurot/player/pipes/index.js +1 -0
- package/dist/kurot/player/pipes/index.js.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderer.d.ts +1 -0
- package/dist/kurot/player/webgl/WebGLRenderer.d.ts.map +1 -1
- package/dist/kurot/player/webgl/WebGLRenderer.js +8 -0
- package/dist/kurot/player/webgl/WebGLRenderer.js.map +1 -1
- package/dist/kurot/resource/Resource.d.ts.map +1 -1
- package/dist/kurot/resource/Resource.js +4 -0
- package/dist/kurot/resource/Resource.js.map +1 -1
- package/dist/kurot/resource/ResourceItem.d.ts +1 -0
- package/dist/kurot/resource/ResourceItem.d.ts.map +1 -1
- package/dist/kurot/resource/ResourceItem.js +1 -0
- package/dist/kurot/resource/ResourceItem.js.map +1 -1
- package/dist/kurot/resource/analyzers/FontAnalyzer.d.ts +16 -0
- package/dist/kurot/resource/analyzers/FontAnalyzer.d.ts.map +1 -0
- package/dist/kurot/resource/analyzers/FontAnalyzer.js +75 -0
- package/dist/kurot/resource/analyzers/FontAnalyzer.js.map +1 -0
- package/dist/kurot/resource/analyzers/index.d.ts +1 -0
- package/dist/kurot/resource/analyzers/index.d.ts.map +1 -1
- package/dist/kurot/resource/analyzers/index.js +1 -0
- package/dist/kurot/resource/analyzers/index.js.map +1 -1
- package/dist/kurot/resource/index.d.ts +1 -0
- package/dist/kurot/resource/index.d.ts.map +1 -1
- package/dist/kurot/resource/index.js +1 -0
- package/dist/kurot/resource/index.js.map +1 -1
- package/dist/kurot/text/BitmapFont.d.ts +15 -21
- package/dist/kurot/text/BitmapFont.d.ts.map +1 -1
- package/dist/kurot/text/BitmapFont.js +59 -66
- package/dist/kurot/text/BitmapFont.js.map +1 -1
- package/dist/kurot/text/BitmapText.d.ts +29 -19
- package/dist/kurot/text/BitmapText.d.ts.map +1 -1
- package/dist/kurot/text/BitmapText.js +93 -141
- package/dist/kurot/text/BitmapText.js.map +1 -1
- package/dist/kurot/text/index.d.ts +1 -0
- package/dist/kurot/text/index.d.ts.map +1 -1
- package/dist/kurot/text/index.js.map +1 -1
- package/docs/ai-context.md +22 -7
- package/docs/architecture.md +322 -276
- package/docs/bitmap-fonts.md +85 -0
- package/docs/resource.md +185 -156
- package/docs/text-layout.md +8 -6
- package/package.json +3 -2
|
@@ -1,48 +1,62 @@
|
|
|
1
|
+
import { layoutBitmapText } from '@kurot/bitmap-font';
|
|
1
2
|
import { DisplayObject } from '../display/DisplayObject.js';
|
|
2
|
-
import { HorizontalAlign } from './enums/HorizontalAlign.js';
|
|
3
|
-
import { VerticalAlign } from './enums/VerticalAlign.js';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* Draws atlas glyphs directly through WebGL batching or Canvas 2D.
|
|
5
|
+
* Width wraps by code point; use multiline=false for one unwrapped line.
|
|
6
|
+
* Fonts are borrowed. Missing glyphs are skipped; U+0020 has a fallback advance.
|
|
6
7
|
*/
|
|
7
8
|
export class BitmapText extends DisplayObject {
|
|
9
|
+
// ── Static fields ─────────────────────────────────────────────────────────
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Font layout uses its explicit spaceAdvance metric.
|
|
12
|
+
* Set that metric in font data before constructing a font.
|
|
13
|
+
*/
|
|
8
14
|
static EMPTY_FACTOR = 0.33;
|
|
15
|
+
// ── Instance fields ──────────────────────────────────────────────────────
|
|
9
16
|
_text = '';
|
|
10
17
|
_font;
|
|
11
18
|
_lineSpacing = 0;
|
|
12
19
|
_letterSpacing = 0;
|
|
13
|
-
_textAlign =
|
|
14
|
-
_verticalAlign =
|
|
20
|
+
_textAlign = 'left';
|
|
21
|
+
_verticalAlign = 'top';
|
|
22
|
+
_smoothing = true;
|
|
23
|
+
_multiline = true;
|
|
24
|
+
_layout;
|
|
25
|
+
// ── Constructor ──────────────────────────────────────────────────────────
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.$renderObjectType = 7 /* RenderObjectType.BITMAP_TEXT */;
|
|
29
|
+
}
|
|
30
|
+
// ── Getters / Setters ─────────────────────────────────────────────────────
|
|
31
|
+
get width() {
|
|
32
|
+
return super.width;
|
|
33
|
+
}
|
|
15
34
|
set width(value) {
|
|
16
|
-
|
|
17
|
-
if (this.$explicitWidth === v)
|
|
35
|
+
if (Object.is(this.$explicitWidth, value))
|
|
18
36
|
return;
|
|
19
|
-
|
|
37
|
+
if (!Number.isNaN(value) && (!Number.isFinite(value) || value < 0))
|
|
38
|
+
throw new RangeError('BitmapText.width must be nonnegative or NaN.');
|
|
39
|
+
this.$explicitWidth = value;
|
|
20
40
|
this._invalidate();
|
|
21
41
|
}
|
|
42
|
+
get height() {
|
|
43
|
+
return super.height;
|
|
44
|
+
}
|
|
22
45
|
set height(value) {
|
|
23
|
-
|
|
24
|
-
if (this.$explicitHeight === v)
|
|
46
|
+
if (Object.is(this.$explicitHeight, value))
|
|
25
47
|
return;
|
|
26
|
-
|
|
48
|
+
if (!Number.isNaN(value) && (!Number.isFinite(value) || value < 0))
|
|
49
|
+
throw new RangeError('BitmapText.height must be nonnegative or NaN.');
|
|
50
|
+
this.$explicitHeight = value;
|
|
27
51
|
this._invalidate();
|
|
28
52
|
}
|
|
29
|
-
_smoothing = true;
|
|
30
|
-
_textLinesChanged = false;
|
|
31
|
-
_textLines = [];
|
|
32
|
-
_textLinesWidth = [];
|
|
33
|
-
_lineHeights = [];
|
|
34
|
-
_textWidth = 0;
|
|
35
|
-
_textHeight = 0;
|
|
36
|
-
_textStartX = 0;
|
|
37
|
-
_textStartY = 0;
|
|
38
53
|
get text() {
|
|
39
54
|
return this._text;
|
|
40
55
|
}
|
|
41
56
|
set text(value) {
|
|
42
|
-
|
|
43
|
-
if (this._text === v)
|
|
57
|
+
if (this._text === value)
|
|
44
58
|
return;
|
|
45
|
-
this._text =
|
|
59
|
+
this._text = value;
|
|
46
60
|
this._invalidate();
|
|
47
61
|
}
|
|
48
62
|
get font() {
|
|
@@ -60,6 +74,8 @@ export class BitmapText extends DisplayObject {
|
|
|
60
74
|
set lineSpacing(value) {
|
|
61
75
|
if (this._lineSpacing === value)
|
|
62
76
|
return;
|
|
77
|
+
if (!Number.isFinite(value) || value < 0)
|
|
78
|
+
throw new RangeError('BitmapText.lineSpacing must be finite and nonnegative.');
|
|
63
79
|
this._lineSpacing = value;
|
|
64
80
|
this._invalidate();
|
|
65
81
|
}
|
|
@@ -69,6 +85,8 @@ export class BitmapText extends DisplayObject {
|
|
|
69
85
|
set letterSpacing(value) {
|
|
70
86
|
if (this._letterSpacing === value)
|
|
71
87
|
return;
|
|
88
|
+
if (!Number.isFinite(value))
|
|
89
|
+
throw new RangeError('BitmapText.letterSpacing must be finite.');
|
|
72
90
|
this._letterSpacing = value;
|
|
73
91
|
this._invalidate();
|
|
74
92
|
}
|
|
@@ -78,6 +96,8 @@ export class BitmapText extends DisplayObject {
|
|
|
78
96
|
set textAlign(value) {
|
|
79
97
|
if (this._textAlign === value)
|
|
80
98
|
return;
|
|
99
|
+
if (!['left', 'center', 'right'].includes(value))
|
|
100
|
+
throw new RangeError('Invalid bitmap text alignment.');
|
|
81
101
|
this._textAlign = value;
|
|
82
102
|
this._invalidate();
|
|
83
103
|
}
|
|
@@ -87,6 +107,8 @@ export class BitmapText extends DisplayObject {
|
|
|
87
107
|
set verticalAlign(value) {
|
|
88
108
|
if (this._verticalAlign === value)
|
|
89
109
|
return;
|
|
110
|
+
if (!['top', 'middle', 'bottom'].includes(value))
|
|
111
|
+
throw new RangeError('Invalid bitmap text vertical alignment.');
|
|
90
112
|
this._verticalAlign = value;
|
|
91
113
|
this._invalidate();
|
|
92
114
|
}
|
|
@@ -99,141 +121,71 @@ export class BitmapText extends DisplayObject {
|
|
|
99
121
|
this._smoothing = value;
|
|
100
122
|
this.$markDirty();
|
|
101
123
|
}
|
|
124
|
+
get multiline() {
|
|
125
|
+
return this._multiline;
|
|
126
|
+
}
|
|
127
|
+
set multiline(value) {
|
|
128
|
+
if (this._multiline === value)
|
|
129
|
+
return;
|
|
130
|
+
this._multiline = value;
|
|
131
|
+
this._invalidate();
|
|
132
|
+
}
|
|
102
133
|
get textWidth() {
|
|
103
|
-
this.
|
|
104
|
-
return this._textWidth;
|
|
134
|
+
return this.getLayout().width;
|
|
105
135
|
}
|
|
106
136
|
get textHeight() {
|
|
107
|
-
this.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
137
|
+
return this.getLayout().height;
|
|
138
|
+
}
|
|
139
|
+
// ── Public methods ───────────────────────────────────────────────────────
|
|
140
|
+
getLayout() {
|
|
141
|
+
this._layout ??= this.measureText(this.$explicitWidth, this.$explicitHeight);
|
|
142
|
+
return this._layout;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Measures with independent constraints without changing the rendered field.
|
|
146
|
+
* NaN means unconstrained; font, spacing, alignment and multiline are retained.
|
|
147
|
+
*/
|
|
148
|
+
measureText(width = NaN, height = NaN) {
|
|
149
|
+
return this._font
|
|
150
|
+
? layoutBitmapText(this._font.data, this._text, {
|
|
151
|
+
width: Number.isNaN(width) ? undefined : width,
|
|
152
|
+
height: Number.isNaN(height) ? undefined : height,
|
|
153
|
+
lineSpacing: this._lineSpacing,
|
|
154
|
+
letterSpacing: this._letterSpacing,
|
|
155
|
+
textAlign: this._textAlign,
|
|
156
|
+
verticalAlign: this._verticalAlign,
|
|
157
|
+
multiline: this._multiline,
|
|
158
|
+
})
|
|
159
|
+
: { glyphs: [], lines: [], width: 0, height: 0, startX: 0, startY: 0, bounds: { x: 0, y: 0, width: 0, height: 0 } };
|
|
160
|
+
}
|
|
161
|
+
getGlyphs() {
|
|
162
|
+
return this.getLayout().glyphs;
|
|
118
163
|
}
|
|
119
164
|
getTextLines() {
|
|
120
|
-
return this.
|
|
165
|
+
return this.getLayout().lines.map(line => line.text);
|
|
121
166
|
}
|
|
122
167
|
getTextLinesWidth() {
|
|
123
|
-
this.
|
|
124
|
-
return this._textLinesWidth;
|
|
168
|
+
return this.getLayout().lines.map(line => line.width);
|
|
125
169
|
}
|
|
126
170
|
getLineHeights() {
|
|
127
|
-
this.
|
|
128
|
-
return this._lineHeights;
|
|
171
|
+
return this.getLayout().lines.map(line => line.height);
|
|
129
172
|
}
|
|
130
173
|
getTextStartX() {
|
|
131
|
-
this.
|
|
132
|
-
return this._textStartX;
|
|
174
|
+
return this.getLayout().startX;
|
|
133
175
|
}
|
|
134
176
|
getTextStartY() {
|
|
135
|
-
this.
|
|
136
|
-
return this._textStartY;
|
|
177
|
+
return this.getLayout().startY;
|
|
137
178
|
}
|
|
179
|
+
// ── Override methods ─────────────────────────────────────────────────────
|
|
180
|
+
$measureContentBounds(bounds) {
|
|
181
|
+
const measured = this.getLayout().bounds;
|
|
182
|
+
bounds.setTo(measured.x, measured.y, measured.width, measured.height);
|
|
183
|
+
}
|
|
184
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
138
185
|
_invalidate() {
|
|
139
|
-
this.
|
|
186
|
+
this._layout = undefined;
|
|
140
187
|
this.$renderDirty = true;
|
|
141
188
|
this.$markDirty();
|
|
142
189
|
}
|
|
143
|
-
_ensureLines() {
|
|
144
|
-
if (!this._textLinesChanged)
|
|
145
|
-
return this._textLines;
|
|
146
|
-
this._textLinesChanged = false;
|
|
147
|
-
this._textLines = [];
|
|
148
|
-
this._textLinesWidth = [];
|
|
149
|
-
this._lineHeights = [];
|
|
150
|
-
this._textWidth = 0;
|
|
151
|
-
this._textHeight = 0;
|
|
152
|
-
const font = this._font;
|
|
153
|
-
if (!this._text || !font)
|
|
154
|
-
return this._textLines;
|
|
155
|
-
const hasWidthSet = !isNaN(this.$explicitWidth);
|
|
156
|
-
const fieldWidth = this.$explicitWidth;
|
|
157
|
-
const fieldHeight = this.$explicitHeight;
|
|
158
|
-
const emptyHeight = font.getFirstCharHeight();
|
|
159
|
-
const emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR);
|
|
160
|
-
const textArr = this._text.split(/(?:\r\n|\r|\n)/);
|
|
161
|
-
let totalWidth = 0;
|
|
162
|
-
let totalHeight = 0;
|
|
163
|
-
const pushLine = (str, lh, lw) => {
|
|
164
|
-
if (!isNaN(fieldHeight) && this._textLines.length > 0 && totalHeight > fieldHeight)
|
|
165
|
-
return false;
|
|
166
|
-
totalHeight += lh + this._lineSpacing;
|
|
167
|
-
this._textLines.push(str);
|
|
168
|
-
this._lineHeights.push(lh);
|
|
169
|
-
this._textLinesWidth.push(lw);
|
|
170
|
-
totalWidth = Math.max(lw, totalWidth);
|
|
171
|
-
return true;
|
|
172
|
-
};
|
|
173
|
-
for (let i = 0; i < textArr.length; i++) {
|
|
174
|
-
let line = textArr[i];
|
|
175
|
-
let len = line.length;
|
|
176
|
-
let lineHeight = 0;
|
|
177
|
-
let xPos = 0;
|
|
178
|
-
let isFirstChar = true;
|
|
179
|
-
for (let j = 0; j < len; j++) {
|
|
180
|
-
if (!isFirstChar)
|
|
181
|
-
xPos += this._letterSpacing;
|
|
182
|
-
const ch = line.charAt(j);
|
|
183
|
-
const texture = font.getTexture(ch);
|
|
184
|
-
let texW;
|
|
185
|
-
let texH;
|
|
186
|
-
if (!texture) {
|
|
187
|
-
if (ch === ' ') {
|
|
188
|
-
texW = emptyWidth;
|
|
189
|
-
texH = emptyHeight;
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
if (isFirstChar)
|
|
193
|
-
isFirstChar = false;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
texW = texture.textureWidth;
|
|
199
|
-
texH = texture.textureHeight;
|
|
200
|
-
}
|
|
201
|
-
if (isFirstChar)
|
|
202
|
-
isFirstChar = false;
|
|
203
|
-
if (hasWidthSet && j > 0 && xPos + texW > fieldWidth) {
|
|
204
|
-
if (!pushLine(line.substring(0, j), lineHeight, xPos))
|
|
205
|
-
break;
|
|
206
|
-
line = line.substring(j);
|
|
207
|
-
len = line.length;
|
|
208
|
-
j = 0;
|
|
209
|
-
xPos = len === 1 ? texW : font.getConfig(ch, 'xadvance') || texW;
|
|
210
|
-
lineHeight = texH;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
xPos += j === len - 1 ? texW : font.getConfig(ch, 'xadvance') || texW;
|
|
214
|
-
lineHeight = Math.max(texH, lineHeight);
|
|
215
|
-
}
|
|
216
|
-
if (!isNaN(fieldHeight) && i > 0 && totalHeight > fieldHeight)
|
|
217
|
-
break;
|
|
218
|
-
pushLine(line, lineHeight, xPos);
|
|
219
|
-
}
|
|
220
|
-
this._textWidth = totalWidth;
|
|
221
|
-
this._textHeight = Math.max(0, totalHeight - this._lineSpacing);
|
|
222
|
-
this._textStartX = 0;
|
|
223
|
-
this._textStartY = 0;
|
|
224
|
-
if (hasWidthSet && fieldWidth > totalWidth) {
|
|
225
|
-
if (this._textAlign === HorizontalAlign.RIGHT)
|
|
226
|
-
this._textStartX = fieldWidth - totalWidth;
|
|
227
|
-
else if (this._textAlign === HorizontalAlign.CENTER)
|
|
228
|
-
this._textStartX = Math.floor((fieldWidth - totalWidth) / 2);
|
|
229
|
-
}
|
|
230
|
-
if (!isNaN(fieldHeight) && fieldHeight > this._textHeight) {
|
|
231
|
-
if (this._verticalAlign === VerticalAlign.BOTTOM)
|
|
232
|
-
this._textStartY = fieldHeight - this._textHeight;
|
|
233
|
-
else if (this._verticalAlign === VerticalAlign.MIDDLE)
|
|
234
|
-
this._textStartY = Math.floor((fieldHeight - this._textHeight) / 2);
|
|
235
|
-
}
|
|
236
|
-
return this._textLines;
|
|
237
|
-
}
|
|
238
190
|
}
|
|
239
191
|
//# sourceMappingURL=BitmapText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitmapText.js","sourceRoot":"","sources":["../../../src/kurot/text/BitmapText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BitmapText.js","sourceRoot":"","sources":["../../../src/kurot/text/BitmapText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAoB,MAAM,6BAA6B,CAAC;AAI9E;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;IAC5C,6EAA6E;IAC7E;;;OAGG;IACI,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAElC,4EAA4E;IACpE,KAAK,GAAG,EAAE,CAAC;IACX,KAAK,CAAc;IACnB,YAAY,GAAG,CAAC,CAAC;IACjB,cAAc,GAAG,CAAC,CAAC;IACnB,UAAU,GAAgC,MAAM,CAAC;IACjD,cAAc,GAAgC,KAAK,CAAC;IACpD,UAAU,GAAG,IAAI,CAAC;IAClB,UAAU,GAAG,IAAI,CAAC;IAClB,OAAO,CAAoB;IAEnC,4EAA4E;IAC5E;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,iBAAiB,uCA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,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IACM,cAAc;QACpB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IACM,aAAa;QACnB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IAChC,CAAC;IACM,aAAa;QACnB,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,4EAA4E;IAC5D,qBAAqB,CAAC,MAAiB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;IAED,4EAA4E;IACpE,WAAW;QAClB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,EAAE,CAAC;IACnB,CAAC"}
|
|
@@ -4,6 +4,7 @@ export { TextFieldType } from './enums/TextFieldType.js';
|
|
|
4
4
|
export { TextFieldInputType } from './enums/TextFieldInputType.js';
|
|
5
5
|
export type { ITextStyle, ITextElement, IWTextElement, ILineElement, IHitTextElement } from './types/ITextElement.js';
|
|
6
6
|
export { HtmlTextParser } from './HtmlTextParser.js';
|
|
7
|
+
export type { BitmapFontOptions } from './BitmapFont.js';
|
|
7
8
|
export { BitmapFont } from './BitmapFont.js';
|
|
8
9
|
export { BitmapText } from './BitmapText.js';
|
|
9
10
|
export { measureText, getFontString } from './TextMeasurer.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kurot/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/kurot/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACtH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/kurot/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/kurot/text/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/docs/ai-context.md
CHANGED
|
@@ -5,7 +5,7 @@ agent unfamiliar with Kurot does not need to re-derive the architecture from
|
|
|
5
5
|
scratch on every session. Treat the package source and its `src/index.ts`
|
|
6
6
|
barrel as the authority for current behavior and exports.
|
|
7
7
|
|
|
8
|
-
Package identity: `@kurot/core@2.
|
|
8
|
+
Package identity: `@kurot/core@2.2.0`. It provides Kurot's scene graph,
|
|
9
9
|
events, rendering, text, resource, network and media runtime. Rendering uses a
|
|
10
10
|
flat `InstructionSet + RenderPipe` pipeline. ES2022 / evergreen browsers only
|
|
11
11
|
with `strict: true`. Two
|
|
@@ -28,7 +28,7 @@ src/kurot/
|
|
|
28
28
|
├── player/ Game loop + both render backends. Player, createPlayer(), SystemTicker/
|
|
29
29
|
│ ticker singleton, ScreenAdapter, TouchHandler. Backend-neutral abstractions
|
|
30
30
|
│ live here: RenderPipe / RenderContext / RenderBuffer interfaces (the latter
|
|
31
|
-
│ two are internal), InstructionSet, and pipes/ (Bitmap/Graphics/Mesh/Text/
|
|
31
|
+
│ two are internal), InstructionSet, and pipes/ (Bitmap/BitmapText/Graphics/Mesh/Text/
|
|
32
32
|
│ Filter/Mask/Particle). The WebGL instruction renderer consumes the pipes.
|
|
33
33
|
│ ├── webgl/ WebGLRenderer, WebGLRenderContext, WebGLRenderBuffer/Target,
|
|
34
34
|
│ │ WebGLVertexArrayObject, WebGLDrawCmdManager, MultiTextureBatcher,
|
|
@@ -44,7 +44,7 @@ src/kurot/
|
|
|
44
44
|
├── text/ TextField, BitmapText/BitmapFont, StageText (DOM overlay, INPUT mode only),
|
|
45
45
|
│ HtmlTextParser, InputController, TextMeasurer, LineBreaks, TextLineLayout, WordWrap.
|
|
46
46
|
├── resource/ Resource class + `resource` singleton, ResourceLoader, analyzers/
|
|
47
|
-
│ (Image/Json/Text/Sound/Sheet). Async, resource.json-driven (RES-compatible).
|
|
47
|
+
│ (Image/Json/Text/Sound/Sheet/Font). Async, resource.json-driven (RES-compatible).
|
|
48
48
|
├── net/ HttpRequest, ImageLoader. Low-level; resource/analyzers build on these.
|
|
49
49
|
├── media/ Sound (+SoundChannel), Video. Web Audio + HTMLAudioElement fallback.
|
|
50
50
|
├── system/ Capabilities (static). Must be _init()'d — createPlayer() does this for you.
|
|
@@ -116,8 +116,11 @@ colocated under `examples/benchmark/`; none are exported from `index.ts`.
|
|
|
116
116
|
- `BlurFilter.quality` controls pass pairs (1–16); large radii downsample to
|
|
117
117
|
stay within the existing 32-physical-pixel shader tier. Glow/DropShadow keep
|
|
118
118
|
their existing fixed-sample shader and do not use their quality metadata.
|
|
119
|
-
-
|
|
120
|
-
cacheAsTexture and RenderTexture.
|
|
119
|
+
- Canvas 2D skips CustomFilter, MultiPassFilter and BloomFilter, including the
|
|
120
|
+
Canvas capture used by cacheAsTexture and RenderTexture. Built-in Blur, Glow
|
|
121
|
+
and DropShadow use CSS approximations; ColorMatrix uses CPU pixels. These
|
|
122
|
+
fallbacks are not pixel-equivalent to WebGL. Do not cache GPU shader effects
|
|
123
|
+
through those capture APIs. See docs/filters.md.
|
|
121
124
|
- Filter setters invalidate weakly attached users. Direct uniform/binding edits
|
|
122
125
|
need `filter.invalidate()`. Auxiliary canvas/video edits additionally need
|
|
123
126
|
`BitmapData.invalidate(source)` for upload refresh.
|
|
@@ -162,11 +165,11 @@ Re-export order: `events`, `geom`, `utils`, `display`, `net`, `filters`,
|
|
|
162
165
|
- **Media**: `Sound`/`SoundType`/`SoundEvents`, `SoundChannel`, `Video`.
|
|
163
166
|
- **Player**: `Player`, `createPlayer`/`KurotApp`/`KurotOptions`; ticker: `SystemTicker`, `ticker`, `getTimer`, `setupLifecycle`, `START_TIME`, `invalidateRenderFlag`/`setInvalidateRenderFlag`, `requestRenderingFlag`/`setRequestRenderingFlag`, `Renderable`; rendering: `InstructionSet`/`Instruction`, `RenderPipe` (type), `CanvasBuffer`, `hitTestBuffer`, `CanvasRenderer`, `DisplayList`; input/layout: `TouchHandler`, `ScreenAdapter`/`StageDisplaySize`; WebGL: `WebGLRenderer`, `WebGLRenderContext`, `WebGLRenderBuffer`, `WebGLRenderTarget`, `WebGLVertexArrayObject`, `WebGLDrawCmdManager`, `WebGLProgram`, `ShaderLib`, `checkWebGLSupport`, `MultiTextureBatcher`.
|
|
164
167
|
- `RenderContext` / `RenderBuffer` (`player/RenderContext.ts`, `player/RenderBuffer.ts`) are internal backend-neutral contracts and are not re-exported.
|
|
165
|
-
- **Text**: `HorizontalAlign`, `VerticalAlign`, `TextFieldType`, `TextFieldInputType`; types `ITextStyle`, `ITextElement`, `IWTextElement`, `ILineElement`, `IHitTextElement`; `HtmlTextParser`, `BitmapFont`, `BitmapText`, `measureText`/`getFontString`, `TextField`, `StageText`, `InputController`, `tokenize`/`splitGraphemes`.
|
|
168
|
+
- **Text**: `HorizontalAlign`, `VerticalAlign`, `TextFieldType`, `TextFieldInputType`; types `ITextStyle`, `ITextElement`, `IWTextElement`, `ILineElement`, `IHitTextElement`, `BitmapFontOptions`; `HtmlTextParser`, `BitmapFont`, `BitmapText`, `measureText`/`getFontString`, `TextField`, `StageText`, `InputController`, `tokenize`/`splitGraphemes`.
|
|
166
169
|
- **System**: `Capabilities`.
|
|
167
170
|
- **localStorage**: namespace object — `import { localStorage } from '@kurot/core'`, then `localStorage.getItem(...)`.
|
|
168
171
|
- **External**: `ExternalInterface` (named, not namespaced).
|
|
169
|
-
- **Resource**: `Resource`/`resource` (shared instance), `ProgressCallback`, `ResourceEventListener`, `ResourceItem`, `ResourceType`, `ResourceConfig`/`ResourceConfigData`/`ResourceConfigEntry`, `ResourceLoader`, `ResourceEventType`/`ResourceEvent`, `AnalyzerBase`, `ImageAnalyzer`, `JsonAnalyzer`, `TextAnalyzer`, `SoundAnalyzer`, `SheetAnalyzer`.
|
|
172
|
+
- **Resource**: `Resource`/`resource` (shared instance), `ProgressCallback`, `ResourceEventListener`, `ResourceItem`, `ResourceType`, `ResourceConfig`/`ResourceConfigData`/`ResourceConfigEntry`, `ResourceLoader`, `ResourceEventType`/`ResourceEvent`, `AnalyzerBase`, `ImageAnalyzer`, `JsonAnalyzer`, `TextAnalyzer`, `SoundAnalyzer`, `SheetAnalyzer`, `FontAnalyzer`.
|
|
170
173
|
|
|
171
174
|
`examples/benchmark/` is dev-only tooling and is **not** exported from `index.ts`.
|
|
172
175
|
|
|
@@ -240,3 +243,15 @@ separate UI capability requiring Core 2.1.0 or later.
|
|
|
240
243
|
See [text layout](text-layout.md) for the Core contract and
|
|
241
244
|
[Label text layout](../../ui/docs/label-text-layout.md) for fit bounds, state
|
|
242
245
|
restoration and shared-schema boundaries.
|
|
246
|
+
|
|
247
|
+
## Bitmap fonts in 2.2.0
|
|
248
|
+
|
|
249
|
+
[bitmap-fonts.md](bitmap-fonts.md) documents the headless bitmap-font dependency,
|
|
250
|
+
FontAnalyzer and BitmapTextPipe. ResourceType.Font is built in; BitmapText
|
|
251
|
+
now draws via WebGL/Canvas. BitmapFontOptions controls page ownership. Native
|
|
252
|
+
font data comes from @kurot/bitmap-font; do not reimplement parsing/layout here.
|
|
253
|
+
The dependency is published @kurot/bitmap-font ^0.1.0, with no local override.
|
|
254
|
+
BitmapText.measureText() leaves rendered constraints and layout caches unchanged;
|
|
255
|
+
text borrows the font and the resource/caller retains ownership. Font pages are
|
|
256
|
+
full, unrotated textures at scale factor 1. Core 2.1.1 does not include these
|
|
257
|
+
changes. Source versions alone do not confirm Core publication.
|