text-shaper 0.1.1 → 0.1.3
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 +1 -0
- package/dist/aat/state-machine.d.ts +18 -6
- package/dist/buffer/glyph-buffer.d.ts +35 -1
- package/dist/buffer/unicode-buffer.d.ts +2 -0
- package/dist/fluent/bitmap-builder.d.ts +146 -0
- package/dist/fluent/index.d.ts +102 -0
- package/dist/fluent/path-builder.d.ts +230 -0
- package/dist/fluent/pipe.d.ts +200 -0
- package/dist/fluent/types.d.ts +93 -0
- package/dist/font/face.d.ts +2 -0
- package/dist/font/font.d.ts +14 -0
- package/dist/font/tables/cff.d.ts +3 -1
- package/dist/font/tables/colr.d.ts +4 -1
- package/dist/font/tables/fvar.d.ts +3 -1
- package/dist/font/tables/glyf.d.ts +13 -0
- package/dist/font/tables/gpos.d.ts +9 -1
- package/dist/font/tables/gsub.d.ts +11 -0
- package/dist/font/tables/gvar.d.ts +10 -1
- package/dist/font/tables/head.d.ts +5 -0
- package/dist/font/tables/hhea.d.ts +5 -0
- package/dist/font/tables/loca.d.ts +3 -0
- package/dist/font/tables/maxp.d.ts +5 -0
- package/dist/font/tables/name.d.ts +5 -0
- package/dist/font/tables/os2.d.ts +5 -0
- package/dist/font/tables/post.d.ts +5 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +12 -10
- package/dist/index.js.map +104 -93
- package/dist/layout/justify.d.ts +15 -2
- package/dist/layout/structures/class-def.d.ts +61 -8
- package/dist/layout/structures/coverage.d.ts +57 -10
- package/dist/layout/structures/device.d.ts +26 -5
- package/dist/layout/structures/layout-common.d.ts +18 -3
- package/dist/layout/structures/set-digest.d.ts +59 -0
- package/dist/perf/benchmark-runner-eksh2b26.js +0 -0
- package/dist/perf/benchmark-runner.html +517 -0
- package/dist/perf/comparison-tests.js +22676 -0
- package/dist/perf/comparison-tests.js.map +111 -0
- package/dist/perf/cpu/cpu-perf.js +21920 -0
- package/dist/perf/cpu/cpu-perf.js.map +108 -0
- package/dist/perf/gpu/webgl-perf.js +470 -0
- package/dist/perf/gpu/webgl-perf.js.map +11 -0
- package/dist/perf/gpu/webgpu-perf.js +442 -0
- package/dist/perf/gpu/webgpu-perf.js.map +11 -0
- package/dist/perf/index.html +258 -0
- package/dist/perf/module-loader.js +18 -0
- package/dist/perf/utils/perf-utils.js +170 -0
- package/dist/perf/utils/perf-utils.js.map +10 -0
- package/dist/raster/asymmetric-stroke.d.ts +61 -0
- package/dist/raster/bitmap-utils.d.ts +124 -0
- package/dist/raster/blur.d.ts +11 -0
- package/dist/raster/cascade-blur.d.ts +44 -0
- package/dist/raster/cell.d.ts +24 -0
- package/dist/raster/fixed-point.d.ts +1 -1
- package/dist/raster/gradient.d.ts +15 -0
- package/dist/raster/gray-raster.d.ts +7 -1
- package/dist/raster/lcd-filter.d.ts +15 -0
- package/dist/raster/msdf.d.ts +135 -0
- package/dist/raster/outline-decompose.d.ts +16 -17
- package/dist/raster/rasterize.d.ts +19 -2
- package/dist/raster/sdf.d.ts +3 -0
- package/dist/raster/stroker.d.ts +3 -0
- package/dist/raster/types.d.ts +24 -0
- package/dist/render/outline-transform.d.ts +169 -0
- package/dist/render/path.d.ts +56 -1
- package/dist/shaper/complex/arabic.d.ts +1 -0
- package/dist/shaper/shape-plan.d.ts +11 -8
- package/dist/shaper/shaper.d.ts +61 -3
- package/dist/unicode/bidi/brackets.d.ts +15 -0
- package/dist/unicode/bidi/char-types.d.ts +4 -0
- package/dist/unicode/bidi/embedding-levels.d.ts +3 -0
- package/dist/unicode/bidi/mirroring.d.ts +10 -0
- package/dist/unicode/bidi/reordering.d.ts +15 -0
- package/dist/unicode/normalize.d.ts +23 -0
- package/dist/unicode/script.d.ts +17 -0
- package/dist/unicode/segmentation.d.ts +18 -0
- package/package.json +12 -3
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipe-style functional utilities for composing transforms and rendering
|
|
3
|
+
*
|
|
4
|
+
* Provides an alternative to the builder pattern for users who prefer
|
|
5
|
+
* functional composition.
|
|
6
|
+
*/
|
|
7
|
+
import type { Font } from "../font/font.ts";
|
|
8
|
+
import { type AsymmetricStrokeOptions } from "../raster/asymmetric-stroke.ts";
|
|
9
|
+
import type { Gradient } from "../raster/gradient.ts";
|
|
10
|
+
import { type MsdfOptions } from "../raster/msdf.ts";
|
|
11
|
+
import { type SdfOptions } from "../raster/sdf.ts";
|
|
12
|
+
import type { LineCap, LineJoin, StrokerOptions } from "../raster/stroker.ts";
|
|
13
|
+
import type { Bitmap, PixelMode, RasterizeOptions } from "../raster/types.ts";
|
|
14
|
+
import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts";
|
|
15
|
+
import type { GlyphPath } from "../render/path.ts";
|
|
16
|
+
import type { GlyphId } from "../types.ts";
|
|
17
|
+
/**
|
|
18
|
+
* Compose functions left-to-right
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = pipe(
|
|
23
|
+
* getGlyphPath(font, glyphId),
|
|
24
|
+
* scale(2, 2),
|
|
25
|
+
* rotate(Math.PI / 4),
|
|
26
|
+
* rasterize({ width: 100, height: 100 }),
|
|
27
|
+
* blur(5),
|
|
28
|
+
* toRGBA
|
|
29
|
+
* );
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function pipe<A>(a: A): A;
|
|
33
|
+
export declare function pipe<A, B>(a: A, ab: (a: A) => B): B;
|
|
34
|
+
export declare function pipe<A, B, C>(a: A, ab: (a: A) => B, bc: (b: B) => C): C;
|
|
35
|
+
export declare function pipe<A, B, C, D>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D): D;
|
|
36
|
+
export declare function pipe<A, B, C, D, E>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E): E;
|
|
37
|
+
export declare function pipe<A, B, C, D, E, F>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F): F;
|
|
38
|
+
export declare function pipe<A, B, C, D, E, F, G>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G): G;
|
|
39
|
+
export declare function pipe<A, B, C, D, E, F, G, H>(a: A, ab: (a: A) => B, bc: (b: B) => C, cd: (c: C) => D, de: (d: D) => E, ef: (e: E) => F, fg: (f: F) => G, gh: (g: G) => H): H;
|
|
40
|
+
/**
|
|
41
|
+
* Get glyph path from font (for use with pipe)
|
|
42
|
+
*/
|
|
43
|
+
export declare function fromGlyph(font: Font, glyphId: GlyphId): GlyphPath | null;
|
|
44
|
+
/**
|
|
45
|
+
* Scale path uniformly or non-uniformly
|
|
46
|
+
*/
|
|
47
|
+
export declare function scale(sx: number, sy?: number): (path: GlyphPath) => GlyphPath;
|
|
48
|
+
/**
|
|
49
|
+
* Translate path by offset
|
|
50
|
+
*/
|
|
51
|
+
export declare function translate(dx: number, dy: number): (path: GlyphPath) => GlyphPath;
|
|
52
|
+
/**
|
|
53
|
+
* Rotate path by angle in radians
|
|
54
|
+
*/
|
|
55
|
+
export declare function rotate(angle: number): (path: GlyphPath) => GlyphPath;
|
|
56
|
+
/**
|
|
57
|
+
* Rotate path by angle in degrees
|
|
58
|
+
*/
|
|
59
|
+
export declare function rotateDeg(angleDeg: number): (path: GlyphPath) => GlyphPath;
|
|
60
|
+
/**
|
|
61
|
+
* Shear/skew path
|
|
62
|
+
*/
|
|
63
|
+
export declare function shear(shearX: number, shearY: number): (path: GlyphPath) => GlyphPath;
|
|
64
|
+
/**
|
|
65
|
+
* Apply italic slant (angle in degrees)
|
|
66
|
+
*/
|
|
67
|
+
export declare function italic(angleDeg: number): (path: GlyphPath) => GlyphPath;
|
|
68
|
+
/**
|
|
69
|
+
* Apply custom 2D affine matrix
|
|
70
|
+
*/
|
|
71
|
+
export declare function matrix(m: Matrix2D): (path: GlyphPath) => GlyphPath;
|
|
72
|
+
/**
|
|
73
|
+
* Apply 3D perspective matrix
|
|
74
|
+
*/
|
|
75
|
+
export declare function perspective(m: Matrix3x3): (path: GlyphPath) => GlyphPath;
|
|
76
|
+
/**
|
|
77
|
+
* Embolden path
|
|
78
|
+
*/
|
|
79
|
+
export declare function emboldenPath(strength: number): (path: GlyphPath) => GlyphPath;
|
|
80
|
+
/**
|
|
81
|
+
* Condense/expand path horizontally
|
|
82
|
+
*/
|
|
83
|
+
export declare function condensePath(factor: number): (path: GlyphPath) => GlyphPath;
|
|
84
|
+
/**
|
|
85
|
+
* Apply oblique/slant to path
|
|
86
|
+
*/
|
|
87
|
+
export declare function obliquePath(slant: number): (path: GlyphPath) => GlyphPath;
|
|
88
|
+
/**
|
|
89
|
+
* Stroke path to create outline
|
|
90
|
+
*/
|
|
91
|
+
export declare function strokePath(options: StrokerOptions): (path: GlyphPath) => GlyphPath;
|
|
92
|
+
export declare function strokePath(width: number, cap?: LineCap, join?: LineJoin): (path: GlyphPath) => GlyphPath;
|
|
93
|
+
/**
|
|
94
|
+
* Clone path
|
|
95
|
+
*/
|
|
96
|
+
export declare function clone(): (path: GlyphPath) => GlyphPath;
|
|
97
|
+
/**
|
|
98
|
+
* Combine multiple paths
|
|
99
|
+
*/
|
|
100
|
+
export declare function combinePaths(paths: GlyphPath[]): GlyphPath;
|
|
101
|
+
/**
|
|
102
|
+
* Asymmetric stroke with independent X/Y border widths
|
|
103
|
+
*/
|
|
104
|
+
export declare function strokeAsymmetric(options: AsymmetricStrokeOptions): (path: GlyphPath) => {
|
|
105
|
+
outer: GlyphPath;
|
|
106
|
+
inner: GlyphPath;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Asymmetric stroke combined (both inner and outer as single fillable path)
|
|
110
|
+
*/
|
|
111
|
+
export declare function strokeAsymmetricCombined(options: AsymmetricStrokeOptions): (path: GlyphPath) => GlyphPath;
|
|
112
|
+
/**
|
|
113
|
+
* Rasterize path to bitmap
|
|
114
|
+
*/
|
|
115
|
+
export declare function rasterize(options: RasterizeOptions): (path: GlyphPath) => Bitmap;
|
|
116
|
+
/**
|
|
117
|
+
* Rasterize with auto-computed size from bounds
|
|
118
|
+
*/
|
|
119
|
+
export declare function rasterizeAuto(options?: {
|
|
120
|
+
padding?: number;
|
|
121
|
+
scale?: number;
|
|
122
|
+
pixelMode?: PixelMode;
|
|
123
|
+
}): (path: GlyphPath) => Bitmap;
|
|
124
|
+
/**
|
|
125
|
+
* Rasterize with gradient fill
|
|
126
|
+
*/
|
|
127
|
+
export declare function rasterizeWithGradient(gradient: Gradient, options: RasterizeOptions): (path: GlyphPath) => Bitmap;
|
|
128
|
+
/**
|
|
129
|
+
* Render path as Signed Distance Field
|
|
130
|
+
*/
|
|
131
|
+
export declare function renderSdf(options: SdfOptions): (path: GlyphPath) => Bitmap;
|
|
132
|
+
/**
|
|
133
|
+
* Render path as Multi-channel Signed Distance Field
|
|
134
|
+
*/
|
|
135
|
+
export declare function renderMsdf(options: MsdfOptions): (path: GlyphPath) => Bitmap;
|
|
136
|
+
/**
|
|
137
|
+
* Gaussian blur bitmap
|
|
138
|
+
*/
|
|
139
|
+
export declare function blur(radius: number): (bitmap: Bitmap) => Bitmap;
|
|
140
|
+
/**
|
|
141
|
+
* Box blur bitmap
|
|
142
|
+
*/
|
|
143
|
+
export declare function boxBlur(radius: number): (bitmap: Bitmap) => Bitmap;
|
|
144
|
+
/**
|
|
145
|
+
* Cascade blur (fast for large radii)
|
|
146
|
+
*/
|
|
147
|
+
export declare function cascadeBlur(radiusX: number, radiusY?: number): (bitmap: Bitmap) => Bitmap;
|
|
148
|
+
/**
|
|
149
|
+
* Adaptive blur (auto-selects best algorithm)
|
|
150
|
+
*/
|
|
151
|
+
export declare function adaptiveBlur(radiusX: number, radiusY?: number): (bitmap: Bitmap) => Bitmap;
|
|
152
|
+
/**
|
|
153
|
+
* Fast Gaussian blur using cascade algorithm
|
|
154
|
+
* Recommended for large radii (> 3 pixels)
|
|
155
|
+
*/
|
|
156
|
+
export declare function fastBlur(radius: number): (bitmap: Bitmap) => Bitmap;
|
|
157
|
+
/**
|
|
158
|
+
* Embolden bitmap operator
|
|
159
|
+
*/
|
|
160
|
+
export declare function embolden(xStrength: number, yStrength?: number): (bitmap: Bitmap) => Bitmap;
|
|
161
|
+
/**
|
|
162
|
+
* Shift bitmap position
|
|
163
|
+
*/
|
|
164
|
+
export declare function shift(dx: number, dy: number): (bitmap: Bitmap) => Bitmap;
|
|
165
|
+
/**
|
|
166
|
+
* Resize bitmap with nearest-neighbor
|
|
167
|
+
*/
|
|
168
|
+
export declare function resize(width: number, height: number): (bitmap: Bitmap) => Bitmap;
|
|
169
|
+
/**
|
|
170
|
+
* Resize bitmap with bilinear interpolation
|
|
171
|
+
*/
|
|
172
|
+
export declare function resizeBilinear(width: number, height: number): (bitmap: Bitmap) => Bitmap;
|
|
173
|
+
/**
|
|
174
|
+
* Pad bitmap
|
|
175
|
+
*/
|
|
176
|
+
export declare function pad(left: number, top: number, right: number, bottom: number): (bitmap: Bitmap) => Bitmap;
|
|
177
|
+
export declare function pad(all: number): (bitmap: Bitmap) => Bitmap;
|
|
178
|
+
/**
|
|
179
|
+
* Convert bitmap to different pixel mode
|
|
180
|
+
*/
|
|
181
|
+
export declare function convert(targetMode: PixelMode): (bitmap: Bitmap) => Bitmap;
|
|
182
|
+
/**
|
|
183
|
+
* Convert bitmap to RGBA array
|
|
184
|
+
*/
|
|
185
|
+
export declare function toRGBA(bitmap: Bitmap): Uint8Array;
|
|
186
|
+
/**
|
|
187
|
+
* Convert bitmap to grayscale array
|
|
188
|
+
*/
|
|
189
|
+
export declare function toGray(bitmap: Bitmap): Uint8Array;
|
|
190
|
+
/**
|
|
191
|
+
* Convert path to SVG string
|
|
192
|
+
*/
|
|
193
|
+
export declare function toSVG(options?: {
|
|
194
|
+
flipY?: boolean;
|
|
195
|
+
scale?: number;
|
|
196
|
+
}): (path: GlyphPath) => string;
|
|
197
|
+
/**
|
|
198
|
+
* Copy bitmap
|
|
199
|
+
*/
|
|
200
|
+
export declare function copy(bitmap: Bitmap): Bitmap;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the fluent API
|
|
3
|
+
*/
|
|
4
|
+
import type { FillRule, PixelMode } from "../raster/types.ts";
|
|
5
|
+
import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts";
|
|
6
|
+
/**
|
|
7
|
+
* Accumulated transform state for lazy evaluation
|
|
8
|
+
*/
|
|
9
|
+
export interface TransformState {
|
|
10
|
+
/** 2D affine transform matrix */
|
|
11
|
+
matrix2D: Matrix2D;
|
|
12
|
+
/** 3D perspective matrix (takes precedence over matrix2D if set) */
|
|
13
|
+
matrix3D: Matrix3x3 | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for rasterization
|
|
17
|
+
*/
|
|
18
|
+
export interface RasterOptions {
|
|
19
|
+
/** Bitmap width in pixels */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** Bitmap height in pixels */
|
|
22
|
+
height?: number;
|
|
23
|
+
/** Scale factor applied during rasterization */
|
|
24
|
+
scale?: number;
|
|
25
|
+
/** X offset for rasterization */
|
|
26
|
+
offsetX?: number;
|
|
27
|
+
/** Y offset for rasterization */
|
|
28
|
+
offsetY?: number;
|
|
29
|
+
/** Padding around the glyph */
|
|
30
|
+
padding?: number;
|
|
31
|
+
/** Pixel mode (Gray, Mono, LCD, etc.) */
|
|
32
|
+
pixelMode?: PixelMode;
|
|
33
|
+
/** Fill rule for path filling */
|
|
34
|
+
fillRule?: FillRule;
|
|
35
|
+
/** Flip Y axis (default true for screen coordinates) */
|
|
36
|
+
flipY?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Options for auto-sized rasterization
|
|
40
|
+
*/
|
|
41
|
+
export interface AutoRasterOptions {
|
|
42
|
+
/** Padding around the glyph (default: 1) */
|
|
43
|
+
padding?: number;
|
|
44
|
+
/** Scale factor (default: 1) */
|
|
45
|
+
scale?: number;
|
|
46
|
+
/** Pixel mode (default: Gray) */
|
|
47
|
+
pixelMode?: PixelMode;
|
|
48
|
+
/** Fill rule (default: NonZero) */
|
|
49
|
+
fillRule?: FillRule;
|
|
50
|
+
/** Flip Y axis (default: true) */
|
|
51
|
+
flipY?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for SVG output
|
|
55
|
+
*/
|
|
56
|
+
export interface SVGOptions {
|
|
57
|
+
/** Flip Y axis (default: true) */
|
|
58
|
+
flipY?: boolean;
|
|
59
|
+
/** Scale factor */
|
|
60
|
+
scale?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Options for SVG element output
|
|
64
|
+
*/
|
|
65
|
+
export interface SVGElementOptions {
|
|
66
|
+
/** Font size for scaling */
|
|
67
|
+
fontSize?: number;
|
|
68
|
+
/** Fill color */
|
|
69
|
+
fill?: string;
|
|
70
|
+
/** Stroke color */
|
|
71
|
+
stroke?: string;
|
|
72
|
+
/** Stroke width */
|
|
73
|
+
strokeWidth?: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Options for canvas rendering
|
|
77
|
+
*/
|
|
78
|
+
export interface CanvasOptions {
|
|
79
|
+
/** Flip Y axis (default: true) */
|
|
80
|
+
flipY?: boolean;
|
|
81
|
+
/** Scale factor */
|
|
82
|
+
scale?: number;
|
|
83
|
+
/** X offset */
|
|
84
|
+
offsetX?: number;
|
|
85
|
+
/** Y offset */
|
|
86
|
+
offsetY?: number;
|
|
87
|
+
/** Fill color (set to "none" to skip fill) */
|
|
88
|
+
fill?: string;
|
|
89
|
+
/** Stroke color */
|
|
90
|
+
stroke?: string;
|
|
91
|
+
/** Stroke width */
|
|
92
|
+
strokeWidth?: number;
|
|
93
|
+
}
|
package/dist/font/face.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare class Face {
|
|
|
11
11
|
private _coords;
|
|
12
12
|
/** User-space axis values */
|
|
13
13
|
private _variations;
|
|
14
|
+
/** Cached advance width deltas for variable fonts (glyphId -> delta) */
|
|
15
|
+
private _advanceDeltas;
|
|
14
16
|
constructor(font: Font, variations?: Record<string, number> | Variation[]);
|
|
15
17
|
/**
|
|
16
18
|
* Set variation axis values
|
package/dist/font/font.d.ts
CHANGED
|
@@ -198,6 +198,20 @@ export declare class Font {
|
|
|
198
198
|
xMax: number;
|
|
199
199
|
yMax: number;
|
|
200
200
|
} | null;
|
|
201
|
+
/**
|
|
202
|
+
* Get contours and bounds for a glyph in a single operation.
|
|
203
|
+
* More efficient than calling getGlyphContours + getGlyphBounds separately
|
|
204
|
+
* as it only parses the glyph once.
|
|
205
|
+
*/
|
|
206
|
+
getGlyphContoursAndBounds(glyphId: GlyphId): {
|
|
207
|
+
contours: Contour[];
|
|
208
|
+
bounds: {
|
|
209
|
+
xMin: number;
|
|
210
|
+
yMin: number;
|
|
211
|
+
xMax: number;
|
|
212
|
+
yMax: number;
|
|
213
|
+
} | null;
|
|
214
|
+
} | null;
|
|
201
215
|
/** Get contours for a glyph with variation applied */
|
|
202
216
|
getGlyphContoursWithVariation(glyphId: GlyphId, axisCoords: number[]): Contour[] | null;
|
|
203
217
|
}
|
|
@@ -88,7 +88,9 @@ export interface FDSelect {
|
|
|
88
88
|
select: (glyphId: number) => number;
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
|
-
* Parse CFF table
|
|
91
|
+
* Parse CFF table - Compact Font Format for PostScript outlines
|
|
92
|
+
* @param reader - Reader positioned at start of CFF table
|
|
93
|
+
* @returns Parsed CFF table with CharStrings, DICTs, and subroutines
|
|
92
94
|
*/
|
|
93
95
|
export declare function parseCff(reader: Reader): CffTable;
|
|
94
96
|
/**
|
|
@@ -245,7 +245,10 @@ export interface VarColorStop extends ColorStop {
|
|
|
245
245
|
varIndexBase?: number;
|
|
246
246
|
}
|
|
247
247
|
/**
|
|
248
|
-
* Parse COLR table
|
|
248
|
+
* Parse COLR table - color glyph definitions with layered or gradient fills
|
|
249
|
+
* Supports both v0 (simple layers) and v1 (advanced paint operations)
|
|
250
|
+
* @param reader - Reader positioned at start of COLR table
|
|
251
|
+
* @returns Parsed COLR table with color layer and paint definitions
|
|
249
252
|
*/
|
|
250
253
|
export declare function parseColr(reader: Reader): ColrTable;
|
|
251
254
|
/**
|
|
@@ -56,7 +56,9 @@ export declare const AxisTags: {
|
|
|
56
56
|
readonly opsz: 1869640570;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
* Parse fvar table
|
|
59
|
+
* Parse fvar table - font variations defining axes and named instances
|
|
60
|
+
* @param reader - Reader positioned at start of fvar table
|
|
61
|
+
* @returns Parsed fvar table with variation axes and instances
|
|
60
62
|
*/
|
|
61
63
|
export declare function parseFvar(reader: Reader): FvarTable;
|
|
62
64
|
/**
|
|
@@ -97,6 +97,19 @@ export declare function flattenCompositeGlyph(glyf: GlyfTable, loca: LocaTable,
|
|
|
97
97
|
* Get all contours for a glyph, flattening composites
|
|
98
98
|
*/
|
|
99
99
|
export declare function getGlyphContours(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): Contour[];
|
|
100
|
+
/**
|
|
101
|
+
* Get contours and bounds for a glyph in one parse operation.
|
|
102
|
+
* More efficient than calling getGlyphContours + getGlyphBounds separately.
|
|
103
|
+
*/
|
|
104
|
+
export declare function getGlyphContoursAndBounds(glyf: GlyfTable, loca: LocaTable, glyphId: GlyphId): {
|
|
105
|
+
contours: Contour[];
|
|
106
|
+
bounds: {
|
|
107
|
+
xMin: number;
|
|
108
|
+
yMin: number;
|
|
109
|
+
xMax: number;
|
|
110
|
+
yMax: number;
|
|
111
|
+
} | null;
|
|
112
|
+
};
|
|
100
113
|
/**
|
|
101
114
|
* Get bounding box for a glyph
|
|
102
115
|
*/
|
|
@@ -2,7 +2,8 @@ import { type ClassDef } from "../../layout/structures/class-def.ts";
|
|
|
2
2
|
import { type Coverage } from "../../layout/structures/coverage.ts";
|
|
3
3
|
import { type DeviceOrVariationIndex } from "../../layout/structures/device.ts";
|
|
4
4
|
import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
|
|
5
|
-
import
|
|
5
|
+
import { SetDigest } from "../../layout/structures/set-digest.ts";
|
|
6
|
+
import type { GlyphId, GlyphPosition, int16, uint16 } from "../../types.ts";
|
|
6
7
|
import type { Reader } from "../binary/reader.ts";
|
|
7
8
|
import { type ChainingContextPosLookup, type ContextPosLookup } from "./gpos-contextual.ts";
|
|
8
9
|
import { type CursivePosSubtable, type MarkBasePosSubtable, type MarkLigaturePosSubtable, type MarkMarkPosSubtable } from "./gpos-mark.ts";
|
|
@@ -45,6 +46,8 @@ export interface GposLookup {
|
|
|
45
46
|
type: GposLookupType;
|
|
46
47
|
flag: uint16;
|
|
47
48
|
markFilteringSet?: uint16;
|
|
49
|
+
/** Bloom filter for fast O(1) glyph rejection */
|
|
50
|
+
digest: SetDigest;
|
|
48
51
|
}
|
|
49
52
|
/** Single adjustment lookup (Type 1) */
|
|
50
53
|
export interface SinglePosLookup extends GposLookup {
|
|
@@ -135,3 +138,8 @@ export declare function getKerning(lookup: PairPosLookup, firstGlyph: GlyphId, s
|
|
|
135
138
|
xAdvance1: number;
|
|
136
139
|
xAdvance2: number;
|
|
137
140
|
} | null;
|
|
141
|
+
/**
|
|
142
|
+
* Apply kerning directly to positions, avoiding object allocation.
|
|
143
|
+
* Returns true if kerning was applied, false otherwise.
|
|
144
|
+
*/
|
|
145
|
+
export declare function applyKerningDirect(lookup: PairPosLookup, firstGlyph: GlyphId, secondGlyph: GlyphId, pos1: GlyphPosition, pos2: GlyphPosition): boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Coverage } from "../../layout/structures/coverage.ts";
|
|
2
2
|
import { type FeatureList, type ScriptList } from "../../layout/structures/layout-common.ts";
|
|
3
|
+
import { SetDigest } from "../../layout/structures/set-digest.ts";
|
|
3
4
|
import type { GlyphId, uint16 } from "../../types.ts";
|
|
4
5
|
import type { Reader } from "../binary/reader.ts";
|
|
5
6
|
import { type ChainingContextSubstSubtable, type ContextSubstSubtable } from "./gsub-contextual.ts";
|
|
@@ -19,6 +20,8 @@ export interface GsubLookup {
|
|
|
19
20
|
type: GsubLookupType;
|
|
20
21
|
flag: uint16;
|
|
21
22
|
markFilteringSet?: uint16;
|
|
23
|
+
/** Bloom filter for fast O(1) glyph rejection */
|
|
24
|
+
digest: SetDigest;
|
|
22
25
|
}
|
|
23
26
|
/** Single substitution lookup (Type 1) */
|
|
24
27
|
export interface SingleSubstLookup extends GsubLookup {
|
|
@@ -105,3 +108,11 @@ export declare function applyLigatureSubst(lookup: LigatureSubstLookup, glyphIds
|
|
|
105
108
|
ligatureGlyph: GlyphId;
|
|
106
109
|
consumed: number;
|
|
107
110
|
} | null;
|
|
111
|
+
/**
|
|
112
|
+
* Apply ligature substitution using a Uint16Array directly (avoids Array.from allocation).
|
|
113
|
+
* glyphIds is a pre-allocated typed array, matchLen is the valid length to consider.
|
|
114
|
+
*/
|
|
115
|
+
export declare function applyLigatureSubstDirect(lookup: LigatureSubstLookup, glyphIds: Uint16Array, matchLen: number, startIndex: number): {
|
|
116
|
+
ligatureGlyph: GlyphId;
|
|
117
|
+
consumed: number;
|
|
118
|
+
} | null;
|
|
@@ -39,7 +39,10 @@ export interface PointDelta {
|
|
|
39
39
|
y: int16;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Parse gvar table
|
|
42
|
+
* Parse gvar table - glyph variations for TrueType outlines in variable fonts
|
|
43
|
+
* @param reader - Reader positioned at start of gvar table
|
|
44
|
+
* @param _numGlyphs - Number of glyphs (currently unused)
|
|
45
|
+
* @returns Parsed gvar table with per-glyph variation data
|
|
43
46
|
*/
|
|
44
47
|
export declare function parseGvar(reader: Reader, _numGlyphs: number): GvarTable;
|
|
45
48
|
/**
|
|
@@ -48,6 +51,12 @@ export declare function parseGvar(reader: Reader, _numGlyphs: number): GvarTable
|
|
|
48
51
|
export declare function parsePackedDeltas(reader: Reader, count: number): number[];
|
|
49
52
|
/**
|
|
50
53
|
* Calculate the scalar for a tuple given axis coordinates
|
|
54
|
+
* Determines how much a variation tuple contributes based on current axis values
|
|
55
|
+
* @param peakTuple - Peak coordinates for each axis where variation is at maximum
|
|
56
|
+
* @param axisCoords - Current normalized axis coordinates
|
|
57
|
+
* @param intermediateStart - Start of intermediate region (null if not used)
|
|
58
|
+
* @param intermediateEnd - End of intermediate region (null if not used)
|
|
59
|
+
* @returns Scalar value between 0 and 1 indicating variation contribution
|
|
51
60
|
*/
|
|
52
61
|
export declare function calculateTupleScalar(peakTuple: number[], axisCoords: number[], intermediateStart: number[] | null, intermediateEnd: number[] | null): number;
|
|
53
62
|
/**
|
|
@@ -44,4 +44,9 @@ export declare const MacStyle: {
|
|
|
44
44
|
readonly Condensed: 32;
|
|
45
45
|
readonly Extended: 64;
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* Parse head table - font header with global metrics
|
|
49
|
+
* @param reader - Reader positioned at start of head table
|
|
50
|
+
* @returns Parsed head table
|
|
51
|
+
*/
|
|
47
52
|
export declare function parseHead(reader: Reader): HeadTable;
|
|
@@ -21,4 +21,9 @@ export interface HheaTable {
|
|
|
21
21
|
metricDataFormat: int16;
|
|
22
22
|
numberOfHMetrics: uint16;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Parse hhea table - horizontal header with metrics for horizontal layout
|
|
26
|
+
* @param reader - Reader positioned at start of hhea table
|
|
27
|
+
* @returns Parsed hhea table
|
|
28
|
+
*/
|
|
24
29
|
export declare function parseHhea(reader: Reader): HheaTable;
|
|
@@ -20,6 +20,9 @@ export declare function parseLoca(reader: Reader, numGlyphs: number, indexToLocF
|
|
|
20
20
|
/**
|
|
21
21
|
* Get byte offset and length for a glyph in the glyf table
|
|
22
22
|
* Returns null if glyph has no outline (empty glyph)
|
|
23
|
+
* @param loca - Parsed loca table
|
|
24
|
+
* @param glyphId - Glyph ID to look up
|
|
25
|
+
* @returns Object with offset and length, or null if glyph has no outline
|
|
23
26
|
*/
|
|
24
27
|
export declare function getGlyphLocation(loca: LocaTable, glyphId: GlyphId): {
|
|
25
28
|
offset: uint32;
|
|
@@ -24,4 +24,9 @@ export interface MaxpTable10 {
|
|
|
24
24
|
maxComponentDepth: uint16;
|
|
25
25
|
}
|
|
26
26
|
export type MaxpTable = MaxpTable05 | MaxpTable10;
|
|
27
|
+
/**
|
|
28
|
+
* Parse maxp table - maximum profile with glyph count and limits
|
|
29
|
+
* @param reader - Reader positioned at start of maxp table
|
|
30
|
+
* @returns Parsed maxp table (version 0.5 for CFF or 1.0 for TrueType)
|
|
31
|
+
*/
|
|
27
32
|
export declare function parseMaxp(reader: Reader): MaxpTable;
|
|
@@ -60,6 +60,11 @@ export interface NameTable {
|
|
|
60
60
|
format: uint16;
|
|
61
61
|
records: NameRecord[];
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse name table - font naming information in multiple languages
|
|
65
|
+
* @param reader - Reader positioned at start of name table
|
|
66
|
+
* @returns Parsed name table with decoded name records
|
|
67
|
+
*/
|
|
63
68
|
export declare function parseName(reader: Reader): NameTable;
|
|
64
69
|
/** Get a specific name by ID, preferring Windows Unicode */
|
|
65
70
|
export declare function getNameById(table: NameTable, nameId: number, languageId?: number): string | null;
|
|
@@ -91,6 +91,11 @@ export declare const FsType: {
|
|
|
91
91
|
readonly NoSubsetting: 256;
|
|
92
92
|
readonly BitmapOnly: 512;
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* Parse OS/2 table - Windows-specific metrics, weight, width, and classification
|
|
96
|
+
* @param reader - Reader positioned at start of OS/2 table
|
|
97
|
+
* @returns Parsed OS/2 table
|
|
98
|
+
*/
|
|
94
99
|
export declare function parseOs2(reader: Reader): Os2Table;
|
|
95
100
|
/** Check if font is italic */
|
|
96
101
|
export declare function isItalic(os2: Os2Table): boolean;
|
|
@@ -18,6 +18,11 @@ export interface PostTable {
|
|
|
18
18
|
glyphNameIndex?: uint16[];
|
|
19
19
|
names?: string[];
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse post table - PostScript information including glyph names
|
|
23
|
+
* @param reader - Reader positioned at start of post table
|
|
24
|
+
* @returns Parsed post table
|
|
25
|
+
*/
|
|
21
26
|
export declare function parsePost(reader: Reader): PostTable;
|
|
22
27
|
/** Get glyph name by glyph ID */
|
|
23
28
|
export declare function getGlyphName(post: PostTable, glyphId: number): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { processContextual, processInsertion, processLigature, processRearrangement, } from "./aat/state-machine.ts";
|
|
2
2
|
export { GlyphBuffer } from "./buffer/glyph-buffer.ts";
|
|
3
3
|
export { UnicodeBuffer } from "./buffer/unicode-buffer.ts";
|
|
4
|
+
export { adaptiveBlur as $adaptiveBlur, BitmapBuilder, bitmap, blur as $blur, boxBlur as $boxBlur, cascadeBlur as $cascadeBlur, char, clone as $clone, combine, combinePaths as $combinePaths, condensePath as $condensePath, convert as $convert, copy as $copy, embolden as $embolden, emboldenPath as $emboldenPath, fastBlur as $fastBlur, fromGlyph as $fromGlyph, glyph, glyphVar, italic as $italic, matrix as $matrix, obliquePath as $obliquePath, PathBuilder, pad as $pad, path, perspective as $perspective, pipe, rasterize as $rasterize, rasterizeAuto as $rasterizeAuto, rasterizeWithGradient as $rasterizeWithGradient, renderMsdf as $renderMsdf, renderSdf as $renderSdf, resize as $resize, resizeBilinear as $resizeBilinear, rotate as $rotate, rotateDeg as $rotateDeg, scale as $scale, shear as $shear, shift as $shift, strokeAsymmetric as $strokeAsymmetric, strokeAsymmetricCombined as $strokeAsymmetricCombined, strokePath as $strokePath, toGray as $toGray, toRGBA as $toRGBA, toSVG as $toSVG, translate as $translate, } from "./fluent/index.ts";
|
|
5
|
+
export type { AutoRasterOptions, CanvasOptions, RasterOptions, SVGElementOptions, SVGOptions, TransformState, } from "./fluent/types.ts";
|
|
4
6
|
export { Reader } from "./font/binary/reader.ts";
|
|
5
7
|
export { createFace, Face } from "./font/face.ts";
|
|
6
8
|
export { Font, type FontLoadOptions } from "./font/font.ts";
|
|
@@ -63,22 +65,27 @@ export type { DeviceOrVariationIndex, DeviceTable, VariationIndexTable, } from "
|
|
|
63
65
|
export { applyDeviceAdjustment, getDeviceDelta, isVariationIndexTable, } from "./layout/structures/device.ts";
|
|
64
66
|
export type { Condition, ConditionSet, FeatureVariationRecord, FeatureVariations, } from "./layout/structures/feature-variations.ts";
|
|
65
67
|
export { applyFeatureVariations, evaluateConditionSet, findMatchingFeatureVariation, getSubstitutedLookups, } from "./layout/structures/feature-variations.ts";
|
|
68
|
+
export { type AsymmetricStrokeOptions, strokeAsymmetric, strokeAsymmetricCombined, strokeUniform, } from "./raster/asymmetric-stroke.ts";
|
|
69
|
+
export { atlasToAlpha, atlasToRGBA, buildAsciiAtlas, buildAtlas, buildStringAtlas, getGlyphUV, } from "./raster/atlas.ts";
|
|
66
70
|
export { getExactBounds } from "./raster/bbox.ts";
|
|
67
|
-
export { blendBitmap, convertBitmap, copyBitmap, emboldenBitmap, resizeBitmap, } from "./raster/bitmap-utils.ts";
|
|
71
|
+
export { addBitmaps, blendBitmap, compositeBitmaps, convertBitmap, copyBitmap, emboldenBitmap, expandToFit, fixOutline, maxBitmaps, mulBitmaps, padBitmap, resizeBitmap, resizeBitmapBilinear, shiftBitmap, subBitmaps, } from "./raster/bitmap-utils.ts";
|
|
68
72
|
export { blurBitmap, boxBlur, createGaussianKernel, gaussianBlur, } from "./raster/blur.ts";
|
|
73
|
+
export { adaptiveBlur, cascadeBlur, fastGaussianBlur, } from "./raster/cascade-blur.ts";
|
|
69
74
|
export { type ColorStop as GradientColorStop, createGradientBitmap, type Gradient, interpolateGradient, type LinearGradient, type RadialGradient, rasterizePathWithGradient, } from "./raster/gradient.ts";
|
|
75
|
+
export { assignEdgeColors, buildMsdfAsciiAtlas, buildMsdfAtlas, buildMsdfStringAtlas, type MsdfEdge, type MsdfOptions, median, msdfAtlasToRGB, msdfAtlasToRGBA, type Point as MsdfPoint, renderMsdf, type SignedDistanceResult, signedDistanceToCubic, signedDistanceToLine, signedDistanceToQuadratic, } from "./raster/msdf.ts";
|
|
70
76
|
export { bitmapToGray, bitmapToRGBA, rasterizeGlyph, rasterizePath, rasterizeText, } from "./raster/rasterize.ts";
|
|
71
77
|
export { renderSdf, type SdfOptions } from "./raster/sdf.ts";
|
|
72
78
|
export { type LineCap, type LineJoin, type StrokerOptions, strokePath, } from "./raster/stroker.ts";
|
|
73
|
-
export { condensePath, emboldenPath, obliquePath
|
|
74
|
-
export type { Bitmap, RasterizedGlyph, RasterizeOptions, Span, } from "./raster/types.ts";
|
|
79
|
+
export { condensePath, emboldenPath, obliquePath } from "./raster/synth.ts";
|
|
80
|
+
export type { Bitmap, GlyphAtlas, GlyphMetrics, MsdfAtlasOptions, RasterizedGlyph, RasterizeOptions, Span, } from "./raster/types.ts";
|
|
75
81
|
export { clearBitmap, createBitmap, FillRule, PixelMode, } from "./raster/types.ts";
|
|
82
|
+
export { type BoundingBox, type ControlBox, clonePath, combinePaths, computeControlBox, computeTightBounds, identity2D, identity3x3, italicizeOutline, type Matrix2D, type Matrix3x3, multiply2D, multiply3x3, perspectiveMatrix, rotate2D, rotateOutline, rotateOutline90, scale2D, scaleOutline, scaleOutlinePow2, shear2D, transformOutline2D, transformOutline3D, transformPoint2D, transformPoint3x3, translate2D, translateOutline, updateMinTransformedX, } from "./render/outline-transform.ts";
|
|
76
83
|
export type { GlyphPath, PathCommand, ShapedGlyph } from "./render/path.ts";
|
|
77
|
-
export { contourToPath, createPath2D, getGlyphPath, getGlyphPathWithVariation, getTextWidth, glyphBufferToShapedGlyphs, glyphToSVG, pathToCanvas, pathToSVG, renderShapedText, renderShapedTextWithVariation, shapedTextToSVG, shapedTextToSVGWithVariation, } from "./render/path.ts";
|
|
84
|
+
export { applyMatrixToContext, contourToPath, createPath2D, getGlyphPath, getGlyphPathWithVariation, getTextWidth, glyphBufferToShapedGlyphs, glyphToSVG, matrixToSVGTransform, pathToCanvas, pathToCanvasWithMatrix, pathToCanvasWithMatrix3D, pathToSVG, pathToSVGWithMatrix, pathToSVGWithMatrix3D, renderShapedText, renderShapedTextWithVariation, shapedTextToSVG, shapedTextToSVGWithVariation, } from "./render/path.ts";
|
|
78
85
|
export { applyFallbackKerning, applyFallbackMarkPositioning, } from "./shaper/fallback.ts";
|
|
79
86
|
export { allSmallCaps, capitalSpacing, capsToSmallCaps, caseSensitiveForms, characterVariant, characterVariants, combineFeatures, contextualAlternates, discretionaryLigatures, feature, features, fractions, fullWidthForms, halfWidthForms, historicalLigatures, jis78Forms, jis83Forms, jis90Forms, jis2004Forms, kerning, liningFigures, oldstyleFigures, ordinals, petiteCaps, proportionalFigures, proportionalWidthForms, quarterWidthForms, ruby, scientificInferiors, simplifiedForms, slashedZero, smallCaps, standardLigatures, stylisticAlternates, stylisticSet, stylisticSets, subscript, superscript, swash, tabularFigures, thirdWidthForms, traditionalForms, verticalAlternatesRotation, verticalForms, verticalKanaAlternates, verticalLayoutFeatures, } from "./shaper/features.ts";
|
|
80
87
|
export { createShapePlan, getOrCreateShapePlan, type ShapeFeature, type ShapePlan, } from "./shaper/shape-plan.ts";
|
|
81
|
-
export { type FontLike, type ShapeOptions, shape } from "./shaper/shaper.ts";
|
|
88
|
+
export { type FontLike, type ShapeOptions, shape, shapeInto, } from "./shaper/shaper.ts";
|
|
82
89
|
export * from "./types.ts";
|
|
83
90
|
export { applyMirroring, type BidiParagraph, type BidiResult, BidiType, detectDirection, getCharType, getEmbeddings, getMirror, getVisualOrder, isLTR, isRTL, processBidi, reorderGlyphs, } from "./unicode/bidi.ts";
|
|
84
91
|
export type { LineBreakAnalysis } from "./unicode/line-break.ts";
|