@flighthq/bitmaptext 0.2.0 → 0.2.1-next.423.3350e53
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/package.json +10 -9
- package/src/updateBitmapText.test.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/bitmaptext",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-next.423.3350e53",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/flighthq/flight.git",
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@flighthq/adjustments": "0.2.
|
|
36
|
-
"@flighthq/displayobject": "0.2.
|
|
37
|
-
"@flighthq/geometry": "0.2.
|
|
38
|
-
"@flighthq/materials": "0.2.
|
|
39
|
-
"@flighthq/node": "0.2.
|
|
40
|
-
"@flighthq/sprite": "0.2.
|
|
41
|
-
"@flighthq/textureatlas": "0.2.
|
|
42
|
-
"@flighthq/types": "0.2.
|
|
35
|
+
"@flighthq/adjustments": "0.2.1-next.423.3350e53",
|
|
36
|
+
"@flighthq/displayobject": "0.2.1-next.423.3350e53",
|
|
37
|
+
"@flighthq/geometry": "0.2.1-next.423.3350e53",
|
|
38
|
+
"@flighthq/materials": "0.2.1-next.423.3350e53",
|
|
39
|
+
"@flighthq/node": "0.2.1-next.423.3350e53",
|
|
40
|
+
"@flighthq/sprite": "0.2.1-next.423.3350e53",
|
|
41
|
+
"@flighthq/textureatlas": "0.2.1-next.423.3350e53",
|
|
42
|
+
"@flighthq/types": "0.2.1-next.423.3350e53"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
+
"@flighthq/glyphatlas": "*",
|
|
45
46
|
"typescript": "^5.3.0"
|
|
46
47
|
},
|
|
47
48
|
"description": "QuadBatch-backed bitmap text display node laying out glyphs from a GlyphSource",
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { getDisplayObjectColorAdjustments } from '@flighthq/displayobject';
|
|
2
|
+
import {
|
|
3
|
+
createGlyphAtlas,
|
|
4
|
+
createGlyphSourceFromGlyphAtlas,
|
|
5
|
+
createStubGlyphRasterizerBackend,
|
|
6
|
+
setGlyphRasterizerBackend,
|
|
7
|
+
} from '@flighthq/glyphatlas';
|
|
2
8
|
import type { ColorTransformAdjustment, GlyphEntry, GlyphSource, ImageResource } from '@flighthq/types';
|
|
3
9
|
import { describe, expect, it } from 'vitest';
|
|
4
10
|
|
|
@@ -44,6 +50,23 @@ function createTwoPageGlyphSource(): { source: GlyphSource; page0Image: ImageRes
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
describe('updateBitmapText', () => {
|
|
53
|
+
it('emits non-empty glyph quads end-to-end from a stub-fed glyph atlas (headless, issue #8)', () => {
|
|
54
|
+
// The real headless path: glyphatlas → GlyphSource → bitmaptext, with the deterministic stub
|
|
55
|
+
// rasterizer standing in for a web font that is unavailable in jsdom/CI. Proves BitmapText renders
|
|
56
|
+
// non-blank without a loaded FontFace.
|
|
57
|
+
setGlyphRasterizerBackend(createStubGlyphRasterizerBackend());
|
|
58
|
+
try {
|
|
59
|
+
const atlas = createGlyphAtlas({ fontFamily: 'unavailable', fontSize: 24, height: 256, width: 256 });
|
|
60
|
+
const text = createBitmapText(createGlyphSourceFromGlyphAtlas(atlas), { text: 'Hi' });
|
|
61
|
+
updateBitmapText(text);
|
|
62
|
+
const batches = getBitmapTextQuadBatches(text);
|
|
63
|
+
expect(batches.length).toBeGreaterThan(0);
|
|
64
|
+
expect(batches[0]!.data.instanceCount).toBe(2);
|
|
65
|
+
} finally {
|
|
66
|
+
setGlyphRasterizerBackend(null);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
47
70
|
it('places each glyph at its cumulative advance, applying kerning', () => {
|
|
48
71
|
const text = createBitmapText(createTestGlyphSource(), { text: 'AB' });
|
|
49
72
|
updateBitmapText(text);
|