msdfgen-ts 0.1.0 → 0.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.
@@ -10,23 +10,29 @@
10
10
  * `screenPxRange = atlas.pxrangeEm × pixelPerEm` uniform, no per-instance
11
11
  * range varying and no per-glyph reasoning about crispness.
12
12
  *
13
- * The MSDF pipeline (normalize → colour → generate → sign-correct →
14
- * error-correct → byte-quantise → y-flip) is byte-for-byte identical to
15
- * the C++ msdfgen reference — see test/msdf/msdf.test.ts for the direct
16
- * pipeline golden. The atlas layout on top (crop + shelf-pack) is our own.
13
+ * Overlapping contours are first merged into their union (src/shape/union.ts,
14
+ * msdfgen's Skia step done without Skia). From there the MSDF pipeline
15
+ * (normalize → colour → generate → sign-correct → error-correct →
16
+ * byte-quantise → y-flip) is byte-for-byte identical to the C++ msdfgen
17
+ * reference — see test/msdf/msdf.test.ts for the direct pipeline golden.
18
+ * The atlas layout on top (crop + shelf-pack) is our own.
17
19
  *
18
20
  * msdfgen is MIT © Viktor Chlumský; this file is original.
19
21
  */
20
22
  import { type Font } from "./font/font.js";
23
+ import { type Shape } from "./shape/shape.js";
21
24
  /** Converts a msdfgen float channel value to a byte, matching C++
22
25
  * `pixelFloatToByte` exactly. */
23
26
  export declare function pixelFloatToByte(x: number): number;
24
27
  /** Options for constructing an {@link Atlas}. */
25
28
  export interface AtlasOptions {
26
- /** Uniform texel-per-em generation scale. Default 40. */
29
+ /** Uniform texel-per-em generation scale. For `parseSvg` shapes, 1 em is the
30
+ * viewBox height, so this is texels per icon height. Default 40. */
27
31
  pixelsPerEm?: number;
28
32
  /** MSDF distance range in texels (msdfgen `-pxrange`). Default 4. */
29
33
  pxrange?: number;
34
+ /** Also keep {@link Atlas.floatTexture}. Default false. */
35
+ float?: boolean;
30
36
  }
31
37
  /** Cached layout + metrics for one atlas-resident glyph. */
32
38
  export interface AtlasGlyph {
@@ -54,7 +60,8 @@ export interface LaidOutGlyph {
54
60
  penY: number;
55
61
  }
56
62
  /**
57
- * Runtime MSDF glyph atlas backed by a single `Font`.
63
+ * Runtime MSDF glyph atlas backed by a single `Font` (or none, for an atlas
64
+ * of arbitrary shapes such as SVG icons — see {@link Atlas.shapes}).
58
65
  *
59
66
  * Prefer {@link Atlas.glyphs} (batched — one potpack for the whole set) over
60
67
  * calling {@link Atlas.glyph} in a loop (one potpack per insert).
@@ -71,22 +78,30 @@ export declare class Atlas {
71
78
  private _width;
72
79
  private _height;
73
80
  private _pixels;
74
- /** Cached glyph + retained float MSDF (for repacking on new inserts).
75
- * Keyed by Unicode codepoint — see {@link Atlas.glyphs}. */
81
+ private _floats;
82
+ /** Cached glyph + retained float MSDF (for repacking on new inserts), keyed
83
+ * by glyph index: codepoints sharing a glyph (every character missing from
84
+ * the font maps to .notdef) share one atlas cell. */
76
85
  private readonly _cache;
77
- /** Same shape as {@link Atlas._cache}, keyed by raw glyph index instead —
78
- * see {@link Atlas.glyphsByIndex}. Separate map: a codepoint and a glyph
79
- * index are different numbers in the same integer space. */
80
- private readonly _cacheByGid;
86
+ /** Same shape as {@link Atlas._cache}, keyed by caller-chosen string — see
87
+ * {@link Atlas.shapes}. */
88
+ private readonly _cacheByKey;
81
89
  /** SDF distance range in em — UNIFORM across all glyphs (that's the point). */
82
90
  readonly pxrangeEm: number;
83
- constructor(font: Font, opts?: AtlasOptions);
91
+ /**
92
+ * @param font Font for the glyph/layout methods; `null` for a shapes-only atlas.
93
+ * @param opts Generation scale and distance range.
94
+ */
95
+ constructor(font: Font | null, opts?: AtlasOptions);
84
96
  /** Packed atlas texture width in texels (chosen by potpack). */
85
97
  get width(): number;
86
98
  /** Packed atlas texture height in texels (chosen by potpack). */
87
99
  get height(): number;
88
100
  /** Packed atlas texture, flat RGBA8 bytes, row-major, y-down. */
89
101
  get texture(): Uint8Array;
102
+ /** {@link Atlas.texture} as raw float RGB, not clamped to [0, 1], for zoom that
103
+ * outruns 8 bits; `null` without the `float` option. */
104
+ get floatTexture(): Float32Array | null;
90
105
  /**
91
106
  * Batched generate + pack. Generates MSDFs for any codepoints not
92
107
  * already cached, then runs potpack **once** over the whole cache.
@@ -104,11 +119,8 @@ export declare class Atlas {
104
119
  * Unicode codepoint — the {@link Atlas.glyphs} twin for glyphs with no
105
120
  * reachable cmap entry. Icon fonts (e.g. Lucide) commonly have far more
106
121
  * glyphs than mapped codepoints; this is how the rest of the set gets
107
- * generated. Shares one packed atlas texture with the codepoint-addressed
108
- * cache — {@link Atlas.texture} always reflects everything requested
109
- * through either method. Cached separately from {@link Atlas.glyphs} (a
110
- * codepoint and a glyph index are different numbers in the same integer
111
- * space — sharing one cache would collide them).
122
+ * generated. Shares one cache and one packed atlas texture with
123
+ * {@link Atlas.glyphs}, which maps codepoints to glyph indices first.
112
124
  */
113
125
  glyphsByIndex(glyphIds: Iterable<number>): AtlasGlyph[];
114
126
  /** Single-glyph convenience for {@link Atlas.glyphsByIndex} — see its
@@ -116,11 +128,20 @@ export declare class Atlas {
116
128
  * (one potpack for the whole batch instead of one per insert). */
117
129
  glyphByIndex(glyphId: number): AtlasGlyph;
118
130
  /**
119
- * Generates the MSDF for `glyphId`. Does not cache and does not pack —
120
- * callers own the cache key (a codepoint for {@link Atlas.glyphs}, the
121
- * glyph ID itself for {@link Atlas.glyphsByIndex}) and the repack.
131
+ * Batched generate + pack for arbitrary shapes (e.g. from `parseSvg`),
132
+ * keyed by a caller-chosen string — the {@link Atlas.glyphs} twin for
133
+ * non-font input. Shapes must be y-up, in the units `pixelsPerEm` scales
134
+ * (`parseSvg` makes 1 unit = the viewBox height). A new shape is mutated
135
+ * (overlaps merged, normalized + coloured); a cached key ignores the shape
136
+ * passed. `advance` is 0. Shares the one packed texture with the glyph cache.
122
137
  */
138
+ shapes(entries: Iterable<readonly [key: string, shape: Shape]>): AtlasGlyph[];
139
+ /** The font, or a clear error for glyph/layout calls on a shapes-only atlas. */
140
+ private _requireFont;
141
+ /** Generates the MSDF for `glyphId`. Does not cache and does not pack. */
123
142
  private _generateForGlyphId;
143
+ /** Generates one entry from an em-unit shape. Does not cache or pack. */
144
+ private _generate;
124
145
  /**
125
146
  * Lays out `text` left-to-right on a single line, applying kerning.
126
147
  * Generates any missing glyphs and packs the atlas **once** for the
@@ -152,10 +173,15 @@ export declare class Atlas {
152
173
  widthEm: number;
153
174
  heightEm: number;
154
175
  };
155
- /** Repacks every cached glyph (both the codepoint- and glyph-index-keyed
156
- * caches — one shared texture) with potpack, reallocates the texture,
157
- * and re-blits each MSDF at its assigned rect. Called by `glyphs()`/
158
- * `glyphsByIndex()` after any batch of new inserts — once per batch. */
176
+ /** Repacks every cached entry (glyph-index- and string-keyed caches — one
177
+ * shared texture) with potpack, reallocates the texture, and re-blits each
178
+ * MSDF at its assigned rect. Called by `glyphsByIndex()`/`shapes()` after
179
+ * any batch of new inserts — once per batch.
180
+ *
181
+ * Each cell gets a 1-texel gutter of zeros on its right and bottom, so a
182
+ * quad covering the whole cell can sample its full rect: linear filtering
183
+ * at the edge blends with zeros (further outside the glyph), never with a
184
+ * neighbouring glyph's texels. */
159
185
  private _repack;
160
186
  /**
161
187
  * Quantise `msdf` (float, y-up, row 0 = bottom, w×h×3) into `_pixels` at
@@ -15,9 +15,11 @@
15
15
  * Composite transforms supported:
16
16
  * ARG_1_AND_2_ARE_WORDS, ARGS_ARE_XY_VALUES,
17
17
  * WE_HAVE_A_SCALE, WE_HAVE_AN_X_AND_Y_SCALE, WE_HAVE_A_TWO_BY_TWO,
18
- * USE_MY_METRICS, MORE_COMPONENTS.
18
+ * MORE_COMPONENTS.
19
19
  *
20
20
  * Not supported (silently ignored / treated as identity):
21
+ * USE_MY_METRICS — advance widths come from `hmtx`, which already holds the
22
+ * composite's own metrics.
21
23
  * ARGS_ARE_XY_VALUES not set (anchor point alignment) — returns origin offset
22
24
  * of 0 for that component.
23
25
  */
@@ -4,5 +4,9 @@ export { EdgeSegment, LINEAR, QUADRATIC, CUBIC } from "./shape/segments.js";
4
4
  export type { SegmentType } from "./shape/segments.js";
5
5
  export { Font } from "./font/font.js";
6
6
  export type { FontMetrics } from "./font/font.js";
7
+ export { parseSvg, parseSvgLayers } from "./svg/svg.js";
8
+ export type { SvgLayer, SvgGradient } from "./svg/svg.js";
9
+ export { generateShapeMSDF } from "./msdf/shape-msdf.js";
10
+ export type { ShapeMSDF } from "./msdf/shape-msdf.js";
7
11
  export { Atlas, pixelFloatToByte } from "./atlas-gen.js";
8
12
  export type { AtlasOptions, AtlasGlyph, LaidOutGlyph } from "./atlas-gen.js";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The whole MSDF pipeline for one shape, from any source (font glyph, SVG):
3
+ * merge overlaps → normalize → colour → generate → sign-correct →
4
+ * error-correct, into a bitmap cropped to the shape's bounds plus `pxrange`
5
+ * texels of padding.
6
+ *
7
+ * Byte-for-byte the msdfgen `msdf -scanline` pipeline after the merge (see
8
+ * test/msdf/msdf.test.ts); the merge and the bounds/cropping are original.
9
+ * msdfgen is MIT © Viktor Chlumský.
10
+ */
11
+ import { type Shape } from "../shape/shape.js";
12
+ /** A shape's MSDF bitmap and where it sits in shape space. */
13
+ export interface ShapeMSDF {
14
+ /** Float MSDF, `w × h × 3`, row-major, y-up (row 0 = bottom). */
15
+ msdf: Float32Array;
16
+ w: number;
17
+ h: number;
18
+ /** Bitmap rect in shape units (y-up). */
19
+ planeLeft: number;
20
+ planeBottom: number;
21
+ planeRight: number;
22
+ planeTop: number;
23
+ }
24
+ /**
25
+ * Generates the MSDF of `shape` at `pixelsPerUnit` texels per shape unit.
26
+ * Mutates `shape` (overlaps merged, normalized + edge-coloured). Returns
27
+ * `null` for a shape with no contours.
28
+ *
29
+ * @param shape Closed contours, y-up, in the units `pixelsPerUnit` scales.
30
+ * @param pixelsPerUnit Texels per shape unit (an atlas's `pixelsPerEm`).
31
+ * @param pxrange Distance range in texels (msdfgen `-pxrange`).
32
+ * @param union Merge overlapping contours first (assumes em-sized units).
33
+ * `false` matches msdfgen without Skia, which draws overlaps as cracks.
34
+ * @returns The bitmap and its plane bounds, or `null` if `shape` is empty.
35
+ */
36
+ export declare function generateShapeMSDF(shape: Shape, pixelsPerUnit: number, pxrange: number, union?: boolean): ShapeMSDF | null;
37
+ /**
38
+ * Axis-aligned bounds of a shape, sampled at `BOUNDS_SAMPLES` t-values per
39
+ * segment. Not mathematically tight, but well under a texel of slop at any
40
+ * realistic `pixelsPerUnit` — good enough for cropping (and for SVG
41
+ * `objectBoundingBox` gradients).
42
+ *
43
+ * @param shape Shape to measure.
44
+ * @returns Its axis-aligned bounds, in shape units.
45
+ */
46
+ export declare function shapeBounds(shape: Shape): {
47
+ minX: number;
48
+ minY: number;
49
+ maxX: number;
50
+ maxY: number;
51
+ };
@@ -9,13 +9,15 @@
9
9
  * core/convergent-curve-ordering.cpp: convergentCurveOrdering().
10
10
  * msdfgen © Viktor Chlumský — MIT licence.
11
11
  */
12
+ import { type Contour } from "./contour.js";
12
13
  import { type Shape } from "./shape.js";
13
14
  /**
14
15
  * Divides all control-point coordinates by `unitsPerEm`, converting font
15
16
  * units to the normalised em-square coordinate system used by msdfgen.
16
17
  *
17
18
  * This is the **single named em-normalisation step** (FONT_SCALING_EM_NORMALIZED).
18
- * No other file may perform this division by unitsPerEm.
19
+ * No other file may perform this division by unitsPerEm. SVG input goes
20
+ * through here too, with the viewBox height as its "unitsPerEm".
19
21
  *
20
22
  * @param shape Shape in raw font units (mutated in-place).
21
23
  * @param unitsPerEm Design units per em (from Font.metrics.unitsPerEm).
@@ -36,3 +38,12 @@ export declare function emNormalizeShape(shape: Shape, unitsPerEm: number): void
36
38
  * @param shape Shape to normalize (mutated in-place).
37
39
  */
38
40
  export declare function normalizeShape(shape: Shape): void;
41
+ /**
42
+ * Reverses contours so the nonzero fill of the result equals the even-odd
43
+ * fill of the input (holes wound against their parent). Used for SVG
44
+ * `fill-rule="evenodd"` paths, so the rest of the pipeline stays nonzero.
45
+ * port of core/Shape.cpp: Shape::orientContours
46
+ *
47
+ * @param contours Contours of one even-odd path (mutated in place).
48
+ */
49
+ export declare function orientContours(contours: Contour[]): void;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Boolean ops on nonzero fills. unionShape removes overlaps: it rewrites a
3
+ * shape as the boundary of its nonzero fill, so overlapping contours
4
+ * (variable fonts, composite glyphs) no longer leave holes where msdfgen's
5
+ * overlapping-contour combiner gets their interior edges wrong. msdfgen
6
+ * itself does this step with Skia path ops (MSDFGEN_USE_SKIA:
7
+ * resolveShapeGeometry). clipShape intersects a shape with a clip region
8
+ * (SVG clip paths, the viewport), and subtractShape cuts other shapes out of
9
+ * one (SVG group opacity). This file is original.
10
+ *
11
+ * Every edge is split where it crosses another, each piece is kept iff the
12
+ * result's fill differs on its two sides, and the kept pieces are relinked
13
+ * into contours. Shapes the op doesn't change are returned untouched, and
14
+ * anything ambiguous (coincident curves, pieces that don't link up) also
15
+ * leaves the shape as it was — never worse than no preprocessing.
16
+ *
17
+ * unionShape runs on every shape generateShapeMSDF sees, overlapping or not,
18
+ * so the crossing search skips what can't matter: edge pairs whose bounds
19
+ * don't overlap (sweep over sorted bounds), and the endpoint consecutive
20
+ * edges share (see corner()). Module-scope scratch below is safe because the
21
+ * library is synchronous and single-threaded per worker.
22
+ */
23
+ import { type Contour } from "./contour.js";
24
+ import { type Shape } from "./shape.js";
25
+ /**
26
+ * Replaces `shape`'s contours with the boundary of their union (nonzero
27
+ * fill), in place. Leaves the shape untouched when it has no overlaps or
28
+ * when they can't be resolved cleanly. Expects em-normalized geometry,
29
+ * before `normalizeShape`.
30
+ *
31
+ * @param shape Shape to resolve (mutated in place).
32
+ */
33
+ export declare function unionShape(shape: Shape): void;
34
+ /**
35
+ * Clips `shape` in place to the union of the `clip` groups: what remains is
36
+ * the part of its nonzero fill that lies inside the nonzero fill of at least
37
+ * one group, as the boundary of that region (overlaps merged). Groups are
38
+ * unioned by fill, so their contours' orientations don't have to agree.
39
+ * Leaves the shape untouched when it already lies inside the clip, or when
40
+ * the intersection can't be resolved cleanly; an empty `clip` clips
41
+ * everything away. Expects em-normalized geometry, like unionShape. The
42
+ * clip's contours are only read.
43
+ *
44
+ * @param shape Shape to clip (mutated in place).
45
+ * @param clip Clip region: groups of closed contours, in `shape`'s space.
46
+ */
47
+ export declare function clipShape(shape: Shape, clip: Contour[][]): void;
48
+ /**
49
+ * Cuts the union of the `cut` groups out of `shape`, in place: what remains
50
+ * is the part of its nonzero fill outside every group's nonzero fill, as the
51
+ * boundary of that region (overlaps merged). Leaves the shape untouched when
52
+ * that boundary is its own, or when the difference can't be resolved cleanly. Expects em-normalized geometry, like unionShape. The
53
+ * cut's contours are only read.
54
+ *
55
+ * @param shape Shape to cut (mutated in place).
56
+ * @param cut Region to remove: groups of closed contours, in `shape`'s space.
57
+ */
58
+ export declare function subtractShape(shape: Shape, cut: Contour[][]): void;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Minimal SVG → Shape parser: the `svg/` twin of `font/`. No DOM.
3
+ *
4
+ * Supported: `<path>` (all commands, arcs converted to cubics) and the basic
5
+ * shapes (`<rect>` incl. rounded, `<circle>`, `<ellipse>`, `<polygon>`,
6
+ * `<polyline>`); `transform` on any element, composed through `<g>`; `fill`,
7
+ * `fill-rule`, `fill-opacity` (inherited) and `opacity` from attributes, CSS
8
+ * class rules in `<style>` (`.name` selectors only, later rules win) or inline
9
+ * `style`; group `opacity` applied to the group's composite (exact when its
10
+ * content is opaque, see parseSvgLayers); percentage lengths; linear/
11
+ * radial gradient fills (`gradientUnits`, `gradientTransform`; attributes and
12
+ * stops a gradient doesn't set come from the one its `href` links to; pad only,
13
+ * focal point ignored); `clip-path` on any element, composed through `<g>`
14
+ * (`<clipPath>` children: basic shapes, or `<use>` of one, with `clip-rule`;
15
+ * user space only), applied as geometry: each shape is intersected with its
16
+ * clip (clipShape); the root `viewBox` (or `width`/`height`), which also clips
17
+ * like a browser's viewport. `fill-rule="evenodd"` shapes are re-oriented so
18
+ * nonzero gives the same fill (msdfgen's orientContours; self-intersecting
19
+ * even-odd paths are approximate, as in msdfgen without Skia).
20
+ * Not supported: strokes, masks, filters, blend modes, `<use>` outside
21
+ * `<clipPath>`, `<text>`, nested `<svg>`, `clipPathUnits="objectBoundingBox"`
22
+ * (the clip is ignored). `<defs>`, `<clipPath>`, `<mask>`, `<symbol>`,
23
+ * `<pattern>` and `<marker>` contents are not drawn.
24
+ */
25
+ import { type Shape } from "../shape/shape.js";
26
+ /** A gradient fill, ready for a shader. Colours are raw CSS strings. */
27
+ export interface SvgGradient {
28
+ /** Linear: t = x'. Radial: t = length(x', y'). Clamped to [0, 1] (pad). */
29
+ radial: boolean;
30
+ /** Affine `[a, b, c, d, e, f]` (SVG `matrix()` order) from shape space
31
+ * to gradient space: x' = a·x + c·y + e, y' = b·x + d·y + f. */
32
+ matrix: number[];
33
+ stops: {
34
+ offset: number;
35
+ color: string;
36
+ opacity: number;
37
+ }[];
38
+ }
39
+ /** One filled `<path>`: its own shape (same space as {@link parseSvg}) and paint. */
40
+ export interface SvgLayer {
41
+ shape: Shape;
42
+ /** CSS colour of `fill`; unused when `gradient` is set. */
43
+ color: string;
44
+ /** `opacity × fill-opacity`. */
45
+ opacity: number;
46
+ gradient: SvgGradient | null;
47
+ }
48
+ /**
49
+ * Parses an SVG document into one filled {@link Shape}: y-up, origin at the
50
+ * viewBox's bottom-left, 1 unit = the viewBox height, clipped to the viewBox.
51
+ * All paths are unioned. The single-colour twin of {@link parseSvgLayers}.
52
+ *
53
+ * @param svg SVG source text.
54
+ * @returns The shape, ready for `Atlas.shapes` or `generateShapeMSDF`, plus
55
+ * the viewBox width (shape units; height is 1) for placing the icon.
56
+ */
57
+ export declare function parseSvg(svg: string): {
58
+ shape: Shape;
59
+ width: number;
60
+ };
61
+ /**
62
+ * Parses an SVG document into one {@link SvgLayer} per filled path, in paint
63
+ * order (back to front), for drawing with real colours and gradients. Each
64
+ * layer's shape is already clipped (clip paths, viewBox); a path clipped away
65
+ * entirely has no layer. A group's `opacity` applies to its composite, which
66
+ * layers drawn one by one can't do directly; when everything in the group is
67
+ * opaque, each member is cut down to the part no later member covers, so
68
+ * drawing the members with the group's opacity is exact. A group holding
69
+ * translucent content keeps that opacity multiplied into its members, an
70
+ * approximation where they overlap.
71
+ *
72
+ * @param svg SVG source text.
73
+ * @returns The layers, plus the viewBox width (shape units; height is 1).
74
+ */
75
+ export declare function parseSvgLayers(svg: string): {
76
+ layers: SvgLayer[];
77
+ width: number;
78
+ };
package/package.json CHANGED
@@ -1,31 +1,34 @@
1
1
  {
2
2
  "name": "msdfgen-ts",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Runtime MSDF font atlases for WebGL/WebGPU: a TypeScript port of msdfgen with a built-in TrueType parser. No WASM.",
5
5
  "keywords": [
6
+ "atlas",
7
+ "font",
6
8
  "msdf",
7
9
  "msdfgen",
8
10
  "sdf",
9
11
  "signed-distance-field",
10
- "font",
11
12
  "text",
12
13
  "truetype",
13
- "atlas",
14
14
  "webgl",
15
15
  "webgpu"
16
16
  ],
17
17
  "homepage": "https://github.com/w8r/msdfgen-ts#readme",
18
18
  "bugs": "https://github.com/w8r/msdfgen-ts/issues",
19
+ "license": "MIT",
20
+ "author": "Alexander Milevski",
19
21
  "repository": {
20
22
  "type": "git",
21
23
  "url": "git+https://github.com/w8r/msdfgen-ts.git"
22
24
  },
23
- "license": "MIT",
24
- "author": "Alexander Milevski",
25
- "type": "module",
26
25
  "files": [
27
26
  "dist"
28
27
  ],
28
+ "type": "module",
29
+ "sideEffects": [
30
+ "./dist/atlas-worker.js"
31
+ ],
29
32
  "main": "./dist/msdfgen-ts.js",
30
33
  "module": "./dist/msdfgen-ts.js",
31
34
  "types": "./dist/types/index.d.ts",
@@ -43,9 +46,6 @@
43
46
  "default": "./dist/atlas-worker.js"
44
47
  }
45
48
  },
46
- "sideEffects": [
47
- "./dist/atlas-worker.js"
48
- ],
49
49
  "scripts": {
50
50
  "gate:m0": "vitest run test/diff.test.ts",
51
51
  "gate:m1": "vitest run test/parser/",
@@ -55,43 +55,63 @@
55
55
  "gate:m3": "vitest run test/msdf/msdf.test.ts",
56
56
  "gate:m4": "vitest run test/atlas/",
57
57
  "gate:m5": "vitest run test/e2e.test.ts",
58
- "gate:m6": "vitest run test/size.test.ts && tsx --expose-gc tools/bench.mjs",
59
- "gate:all": "vitest run test/diff.test.ts test/parser/ test/shape/normalize.test.ts test/msdf/ test/atlas/ test/e2e.test.ts",
58
+ "gate:m6": "vitest run test/size.test.ts && tsx --expose-gc tools/bench.ts",
59
+ "gate:all": "vitest run test/diff.test.ts test/parser/ test/shape/normalize.test.ts test/msdf/ test/svg/ test/atlas/ test/e2e.test.ts",
60
60
  "bench:vitest": "vitest bench test/bench/",
61
- "gen-golden": "node tools/gen-golden.mjs",
61
+ "gen-golden": "tsx tools/gen-golden.ts",
62
62
  "setup-reference": "bash tools/setup-reference.sh",
63
- "atlas-preview": "tsx tools/atlas-preview.mjs",
64
- "screenshot": "node tools/screenshot.mjs",
63
+ "atlas-preview": "tsx tools/atlas-preview.ts",
64
+ "screenshot": "tsx tools/screenshot.ts",
65
65
  "screenshot:setup": "playwright install chromium",
66
- "dev": "vite --open /demo/canvas/index.html",
66
+ "dev": "vite --open /demo/index.html",
67
67
  "dev:webgpu": "vite --open /demo/webgpu/index.html",
68
68
  "dev:webgl": "vite --open /demo/webgl/index.html",
69
69
  "dev:webgl-zoom": "vite --open /demo/webgl-zoom/index.html",
70
70
  "dev:webgpu-zoom": "vite --open /demo/webgpu-zoom/index.html",
71
71
  "dev:lucide": "vite --open /demo/lucide/index.html",
72
+ "dev:svg": "vite --open /demo/svg/index.html",
73
+ "dev:svg-bounce": "vite --open /demo/svg-bounce/index.html",
72
74
  "dev:bench": "vite --open /demo/bench/index.html",
73
75
  "build": "vite build && vite build --config vite.worker.config.ts && tsc -p tsconfig.build.json && tsx tools/fix-dts-extensions.ts",
74
76
  "build:demo": "vite build --config vite.demo.config.ts",
75
77
  "predeploy": "npm run build:demo",
76
78
  "deploy": "gh-pages -d demo-dist --nojekyll",
77
79
  "size": "vite build && gzip -c dist/msdfgen-ts.iife.js | wc -c | awk '{printf \"%.1f KB (iife, gzip)\\n\", $1/1024}'",
78
- "lint": "oxlint src/ test/",
80
+ "lint": "oxlint --deny-warnings .",
79
81
  "typecheck": "tsc --noEmit",
80
82
  "dev:hello-webgl": "vite --open /demo/hello-webgl/index.html",
83
+ "dev:hello-svg": "vite --open /demo/hello-svg/index.html",
81
84
  "dev:hello-webgpu": "vite --open /demo/hello-webgpu/index.html",
82
- "prepublishOnly": "npm run build"
85
+ "dev:three": "vite --open /demo/three/index.html",
86
+ "dev:r3f": "vite --open /demo/r3f/index.html",
87
+ "dev:pixi": "vite --open /demo/pixi/index.html",
88
+ "prepublishOnly": "npm run build",
89
+ "format": "oxfmt .",
90
+ "format:check": "oxfmt --check ."
83
91
  },
84
92
  "dependencies": {
85
93
  "potpack": "2.1.0"
86
94
  },
87
95
  "devDependencies": {
88
- "@types/node": "22.0.0",
96
+ "@chenglou/pretext": "1.0.0",
97
+ "@react-three/drei": "10.7.9",
98
+ "@react-three/fiber": "9.8.1",
99
+ "@types/node": "22.20.5",
89
100
  "@types/opentype.js": "1.3.10",
101
+ "@types/react": "19.3.0",
102
+ "@types/react-dom": "19.3.0",
103
+ "@types/three": "0.186.0",
90
104
  "@webgpu/types": "0.1.71",
91
105
  "gh-pages": "6.3.0",
92
106
  "opentype.js": "1.3.4",
107
+ "oxfmt": "0.71.0",
93
108
  "oxlint": "1.0.0",
109
+ "pixi.js": "8.22.0",
94
110
  "playwright": "1.62.1",
111
+ "react": "19.3.0",
112
+ "react-dom": "19.3.0",
113
+ "suspend-react": "0.1.3",
114
+ "three": "0.186.1",
95
115
  "tsx": "4.23.12",
96
116
  "typescript": "7.0.2",
97
117
  "vite": "6.3.0",