@cantoo/fontkit 2.0.6 → 2.0.7

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.
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Public TypeScript API for `@cantoo/fontkit`.
3
+ * Built for consumers; internal checkJs types live in `./fontkit.d.ts`.
4
+ */
5
+
6
+ export type ScriptTag = string;
7
+ export type LanguageTag = string;
8
+ export type TextDirection = 'ltr' | 'rtl';
9
+ export type FeatureValue = boolean | number;
10
+ export type FeatureMap = Record<string, FeatureValue>;
11
+ export type FeatureInput = string[] | FeatureMap;
12
+
13
+ /** Bounding box in font units. */
14
+ export interface BBox {
15
+ minX: number;
16
+ minY: number;
17
+ maxX: number;
18
+ maxY: number;
19
+ readonly width: number;
20
+ readonly height: number;
21
+ addPoint(x: number, y: number): void;
22
+ copy(): BBox;
23
+ }
24
+
25
+ /** Vector path command. */
26
+ export interface PathCommand {
27
+ command: 'moveTo' | 'lineTo' | 'quadraticCurveTo' | 'bezierCurveTo' | 'closePath';
28
+ args: number[];
29
+ }
30
+
31
+ /** Minimal canvas-like context used by Path.toFunction / Glyph.render. */
32
+ export interface PathRenderingContext {
33
+ save(): void;
34
+ restore(): void;
35
+ scale(x: number, y: number): void;
36
+ fill(): void;
37
+ moveTo?(x: number, y: number): void;
38
+ lineTo?(x: number, y: number): void;
39
+ quadraticCurveTo?(cpx: number, cpy: number, x: number, y: number): void;
40
+ bezierCurveTo?(
41
+ cp1x: number,
42
+ cp1y: number,
43
+ cp2x: number,
44
+ cp2y: number,
45
+ x: number,
46
+ y: number
47
+ ): void;
48
+ closePath?(): void;
49
+ [key: string]: unknown;
50
+ }
51
+
52
+ /** Outline path returned by glyphs. */
53
+ export interface Path {
54
+ commands: PathCommand[];
55
+ readonly cbox: BBox;
56
+ readonly bbox: BBox;
57
+ toFunction(): (ctx: PathRenderingContext) => void;
58
+ toSVG(): string;
59
+ mapPoints(fn: (x: number, y: number) => [number, number]): Path;
60
+ transform(m0: number, m1: number, m2: number, m3: number, m4: number, m5: number): Path;
61
+ translate(x: number, y: number): Path;
62
+ rotate(angle: number): Path;
63
+ scale(scaleX: number, scaleY?: number): Path;
64
+ moveTo(x: number, y: number): Path;
65
+ lineTo(x: number, y: number): Path;
66
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Path;
67
+ bezierCurveTo(
68
+ cp1x: number,
69
+ cp1y: number,
70
+ cp2x: number,
71
+ cp2y: number,
72
+ x: number,
73
+ y: number
74
+ ): Path;
75
+ closePath(): Path;
76
+ }
77
+
78
+ /** Per-glyph advance / bearing metrics. */
79
+ export interface GlyphMetrics {
80
+ width: number;
81
+ height: number;
82
+ advanceWidth: number;
83
+ advanceHeight: number;
84
+ leftBearing: number;
85
+ topBearing: number;
86
+ rightBearing: number;
87
+ bottomBearing: number;
88
+ }
89
+
90
+ /** A glyph in a font. */
91
+ export interface Glyph {
92
+ id: number;
93
+ codePoints: number[];
94
+ isMark: boolean;
95
+ isLigature: boolean;
96
+ readonly cbox: BBox;
97
+ readonly bbox: BBox;
98
+ readonly path: Path;
99
+ readonly width: number;
100
+ readonly height: number;
101
+ readonly advanceWidth: number;
102
+ readonly advanceHeight: number;
103
+ readonly leftBearing: number;
104
+ readonly topBearing: number;
105
+ readonly rightBearing: number;
106
+ readonly bottomBearing: number;
107
+ readonly name: string | null;
108
+ getScaledPath(size: number): Path;
109
+ render(ctx: PathRenderingContext, size: number): void;
110
+ }
111
+
112
+ /** Positioning for one glyph in a GlyphRun. */
113
+ export interface GlyphPosition {
114
+ xAdvance: number;
115
+ yAdvance: number;
116
+ xOffset: number;
117
+ yOffset: number;
118
+ }
119
+
120
+ /** Result of Font.layout(). */
121
+ export interface GlyphRun {
122
+ glyphs: Glyph[];
123
+ positions: GlyphPosition[] | null;
124
+ script: ScriptTag | string[] | null | undefined;
125
+ language: LanguageTag | null;
126
+ direction: TextDirection;
127
+ features: FeatureMap;
128
+ readonly advanceWidth: number;
129
+ readonly advanceHeight: number;
130
+ readonly bbox: BBox;
131
+ }
132
+
133
+ /** Variation axis description. */
134
+ export interface VariationAxisInfo {
135
+ name: string | null;
136
+ min: number;
137
+ default: number;
138
+ max: number;
139
+ }
140
+
141
+ /** Font subset writer. */
142
+ export interface Subset {
143
+ includeGlyph(glyph: Glyph | number): number;
144
+ encodeStream(): unknown;
145
+ encode(cb?: (err: Error | null, data?: Uint8Array) => void): Promise<Uint8Array> | void;
146
+ }
147
+
148
+ /**
149
+ * An opened font (or a font selected from a collection).
150
+ * Matches the public surface of TTFFont / WOFF / WOFF2 / etc.
151
+ */
152
+ export interface Font {
153
+ type: string;
154
+ readonly postscriptName: string | null;
155
+ readonly fullName: string | null;
156
+ readonly familyName: string | null;
157
+ readonly subfamilyName: string | null;
158
+ readonly copyright: string | null;
159
+ readonly version: string | null;
160
+ readonly unitsPerEm: number;
161
+ readonly ascent: number;
162
+ readonly descent: number;
163
+ readonly lineGap: number;
164
+ readonly underlinePosition: number;
165
+ readonly underlineThickness: number;
166
+ readonly italicAngle: number;
167
+ readonly capHeight: number;
168
+ readonly xHeight: number;
169
+ readonly bbox: BBox;
170
+ readonly numGlyphs: number;
171
+ readonly characterSet: number[];
172
+ readonly availableFeatures: string[];
173
+ readonly variationAxes: Record<string, VariationAxisInfo>;
174
+ readonly namedVariations: Record<string, Record<string, number>>;
175
+
176
+ setDefaultLanguage(lang?: string | null): void;
177
+ getName(key: string, lang?: string): string | null;
178
+ hasGlyphForCodePoint(codePoint: number): boolean;
179
+ glyphForCodePoint(codePoint: number): Glyph | null;
180
+ glyphsForString(string: string): Glyph[];
181
+ layout(
182
+ string: string,
183
+ userFeatures?: FeatureInput | null,
184
+ script?: ScriptTag | string[] | null,
185
+ language?: LanguageTag | null,
186
+ direction?: TextDirection | null
187
+ ): GlyphRun;
188
+ stringsForGlyph(gid: number): string[];
189
+ getAvailableFeatures(
190
+ script?: ScriptTag | string[] | null,
191
+ language?: LanguageTag | null
192
+ ): string[];
193
+ getGlyph(glyph: number, characters?: number[]): Glyph | null;
194
+ createSubset(): Subset;
195
+ getVariation(variation: string | Record<string, number> | number[]): Font;
196
+ getFont?(
197
+ postscriptName: string | Uint8Array | Record<string, number>
198
+ ): Font | null | undefined;
199
+ }
200
+
201
+ /** Constructible font format registered with registerFormat(). */
202
+ export interface FontFormat {
203
+ new (stream: unknown, variationCoords?: number[] | null): Font;
204
+ probe(buffer: ArrayBufferView): boolean;
205
+ }
206
+
207
+ export declare let logErrors: boolean;
208
+ export declare let defaultLanguage: string;
209
+
210
+ export declare function registerFormat(format: FontFormat): void;
211
+ export declare function create(
212
+ buffer: ArrayBufferView,
213
+ postscriptName?: string | Uint8Array
214
+ ): Font | null | undefined;
215
+ export declare function setDefaultLanguage(lang?: string): void;
216
+
217
+ /** Node-only: open a font file asynchronously. */
218
+ export declare function open(
219
+ filename: string | import('fs').PathLike,
220
+ postscriptName?: string | Uint8Array
221
+ ): Promise<Font | null | undefined>;
222
+
223
+ /** Node-only: open a font file synchronously. */
224
+ export declare function openSync(
225
+ filename: string | import('fs').PathLike,
226
+ postscriptName?: string | Uint8Array
227
+ ): Font | null | undefined;
228
+
229
+ declare const fontkit: {
230
+ logErrors: boolean;
231
+ defaultLanguage: string;
232
+ registerFormat: typeof registerFormat;
233
+ create: typeof create;
234
+ setDefaultLanguage: typeof setDefaultLanguage;
235
+ open: typeof open;
236
+ openSync: typeof openSync;
237
+ };
238
+
239
+ export default fontkit;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Public TypeScript API for `@cantoo/fontkit`.
3
+ * Built for consumers; internal checkJs types live in `./fontkit.d.ts`.
4
+ */
5
+
6
+ export type ScriptTag = string;
7
+ export type LanguageTag = string;
8
+ export type TextDirection = 'ltr' | 'rtl';
9
+ export type FeatureValue = boolean | number;
10
+ export type FeatureMap = Record<string, FeatureValue>;
11
+ export type FeatureInput = string[] | FeatureMap;
12
+
13
+ /** Bounding box in font units. */
14
+ export interface BBox {
15
+ minX: number;
16
+ minY: number;
17
+ maxX: number;
18
+ maxY: number;
19
+ readonly width: number;
20
+ readonly height: number;
21
+ addPoint(x: number, y: number): void;
22
+ copy(): BBox;
23
+ }
24
+
25
+ /** Vector path command. */
26
+ export interface PathCommand {
27
+ command: 'moveTo' | 'lineTo' | 'quadraticCurveTo' | 'bezierCurveTo' | 'closePath';
28
+ args: number[];
29
+ }
30
+
31
+ /** Minimal canvas-like context used by Path.toFunction / Glyph.render. */
32
+ export interface PathRenderingContext {
33
+ save(): void;
34
+ restore(): void;
35
+ scale(x: number, y: number): void;
36
+ fill(): void;
37
+ moveTo?(x: number, y: number): void;
38
+ lineTo?(x: number, y: number): void;
39
+ quadraticCurveTo?(cpx: number, cpy: number, x: number, y: number): void;
40
+ bezierCurveTo?(
41
+ cp1x: number,
42
+ cp1y: number,
43
+ cp2x: number,
44
+ cp2y: number,
45
+ x: number,
46
+ y: number
47
+ ): void;
48
+ closePath?(): void;
49
+ [key: string]: unknown;
50
+ }
51
+
52
+ /** Outline path returned by glyphs. */
53
+ export interface Path {
54
+ commands: PathCommand[];
55
+ readonly cbox: BBox;
56
+ readonly bbox: BBox;
57
+ toFunction(): (ctx: PathRenderingContext) => void;
58
+ toSVG(): string;
59
+ mapPoints(fn: (x: number, y: number) => [number, number]): Path;
60
+ transform(m0: number, m1: number, m2: number, m3: number, m4: number, m5: number): Path;
61
+ translate(x: number, y: number): Path;
62
+ rotate(angle: number): Path;
63
+ scale(scaleX: number, scaleY?: number): Path;
64
+ moveTo(x: number, y: number): Path;
65
+ lineTo(x: number, y: number): Path;
66
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Path;
67
+ bezierCurveTo(
68
+ cp1x: number,
69
+ cp1y: number,
70
+ cp2x: number,
71
+ cp2y: number,
72
+ x: number,
73
+ y: number
74
+ ): Path;
75
+ closePath(): Path;
76
+ }
77
+
78
+ /** Per-glyph advance / bearing metrics. */
79
+ export interface GlyphMetrics {
80
+ width: number;
81
+ height: number;
82
+ advanceWidth: number;
83
+ advanceHeight: number;
84
+ leftBearing: number;
85
+ topBearing: number;
86
+ rightBearing: number;
87
+ bottomBearing: number;
88
+ }
89
+
90
+ /** A glyph in a font. */
91
+ export interface Glyph {
92
+ id: number;
93
+ codePoints: number[];
94
+ isMark: boolean;
95
+ isLigature: boolean;
96
+ readonly cbox: BBox;
97
+ readonly bbox: BBox;
98
+ readonly path: Path;
99
+ readonly width: number;
100
+ readonly height: number;
101
+ readonly advanceWidth: number;
102
+ readonly advanceHeight: number;
103
+ readonly leftBearing: number;
104
+ readonly topBearing: number;
105
+ readonly rightBearing: number;
106
+ readonly bottomBearing: number;
107
+ readonly name: string | null;
108
+ getScaledPath(size: number): Path;
109
+ render(ctx: PathRenderingContext, size: number): void;
110
+ }
111
+
112
+ /** Positioning for one glyph in a GlyphRun. */
113
+ export interface GlyphPosition {
114
+ xAdvance: number;
115
+ yAdvance: number;
116
+ xOffset: number;
117
+ yOffset: number;
118
+ }
119
+
120
+ /** Result of Font.layout(). */
121
+ export interface GlyphRun {
122
+ glyphs: Glyph[];
123
+ positions: GlyphPosition[] | null;
124
+ script: ScriptTag | string[] | null | undefined;
125
+ language: LanguageTag | null;
126
+ direction: TextDirection;
127
+ features: FeatureMap;
128
+ readonly advanceWidth: number;
129
+ readonly advanceHeight: number;
130
+ readonly bbox: BBox;
131
+ }
132
+
133
+ /** Variation axis description. */
134
+ export interface VariationAxisInfo {
135
+ name: string | null;
136
+ min: number;
137
+ default: number;
138
+ max: number;
139
+ }
140
+
141
+ /** Font subset writer. */
142
+ export interface Subset {
143
+ includeGlyph(glyph: Glyph | number): number;
144
+ encodeStream(): unknown;
145
+ encode(cb?: (err: Error | null, data?: Uint8Array) => void): Promise<Uint8Array> | void;
146
+ }
147
+
148
+ /**
149
+ * An opened font (or a font selected from a collection).
150
+ * Matches the public surface of TTFFont / WOFF / WOFF2 / etc.
151
+ */
152
+ export interface Font {
153
+ type: string;
154
+ readonly postscriptName: string | null;
155
+ readonly fullName: string | null;
156
+ readonly familyName: string | null;
157
+ readonly subfamilyName: string | null;
158
+ readonly copyright: string | null;
159
+ readonly version: string | null;
160
+ readonly unitsPerEm: number;
161
+ readonly ascent: number;
162
+ readonly descent: number;
163
+ readonly lineGap: number;
164
+ readonly underlinePosition: number;
165
+ readonly underlineThickness: number;
166
+ readonly italicAngle: number;
167
+ readonly capHeight: number;
168
+ readonly xHeight: number;
169
+ readonly bbox: BBox;
170
+ readonly numGlyphs: number;
171
+ readonly characterSet: number[];
172
+ readonly availableFeatures: string[];
173
+ readonly variationAxes: Record<string, VariationAxisInfo>;
174
+ readonly namedVariations: Record<string, Record<string, number>>;
175
+
176
+ setDefaultLanguage(lang?: string | null): void;
177
+ getName(key: string, lang?: string): string | null;
178
+ hasGlyphForCodePoint(codePoint: number): boolean;
179
+ glyphForCodePoint(codePoint: number): Glyph | null;
180
+ glyphsForString(string: string): Glyph[];
181
+ layout(
182
+ string: string,
183
+ userFeatures?: FeatureInput | null,
184
+ script?: ScriptTag | string[] | null,
185
+ language?: LanguageTag | null,
186
+ direction?: TextDirection | null
187
+ ): GlyphRun;
188
+ stringsForGlyph(gid: number): string[];
189
+ getAvailableFeatures(
190
+ script?: ScriptTag | string[] | null,
191
+ language?: LanguageTag | null
192
+ ): string[];
193
+ getGlyph(glyph: number, characters?: number[]): Glyph | null;
194
+ createSubset(): Subset;
195
+ getVariation(variation: string | Record<string, number> | number[]): Font;
196
+ getFont?(
197
+ postscriptName: string | Uint8Array | Record<string, number>
198
+ ): Font | null | undefined;
199
+ }
200
+
201
+ /** Constructible font format registered with registerFormat(). */
202
+ export interface FontFormat {
203
+ new (stream: unknown, variationCoords?: number[] | null): Font;
204
+ probe(buffer: ArrayBufferView): boolean;
205
+ }
206
+
207
+ export declare let logErrors: boolean;
208
+ export declare let defaultLanguage: string;
209
+
210
+ export declare function registerFormat(format: FontFormat): void;
211
+ export declare function create(
212
+ buffer: ArrayBufferView,
213
+ postscriptName?: string | Uint8Array
214
+ ): Font | null | undefined;
215
+ export declare function setDefaultLanguage(lang?: string): void;
216
+
217
+ /** Node-only: open a font file asynchronously. */
218
+ export declare function open(
219
+ filename: string | import('fs').PathLike,
220
+ postscriptName?: string | Uint8Array
221
+ ): Promise<Font | null | undefined>;
222
+
223
+ /** Node-only: open a font file synchronously. */
224
+ export declare function openSync(
225
+ filename: string | import('fs').PathLike,
226
+ postscriptName?: string | Uint8Array
227
+ ): Font | null | undefined;
228
+
229
+ declare const fontkit: {
230
+ logErrors: boolean;
231
+ defaultLanguage: string;
232
+ registerFormat: typeof registerFormat;
233
+ create: typeof create;
234
+ setDefaultLanguage: typeof setDefaultLanguage;
235
+ open: typeof open;
236
+ openSync: typeof openSync;
237
+ };
238
+
239
+ export default fontkit;
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Public TypeScript API for `@cantoo/fontkit`.
3
+ * Built for consumers; internal checkJs types live in `./fontkit.d.ts`.
4
+ */
5
+
6
+ export type ScriptTag = string;
7
+ export type LanguageTag = string;
8
+ export type TextDirection = 'ltr' | 'rtl';
9
+ export type FeatureValue = boolean | number;
10
+ export type FeatureMap = Record<string, FeatureValue>;
11
+ export type FeatureInput = string[] | FeatureMap;
12
+
13
+ /** Bounding box in font units. */
14
+ export interface BBox {
15
+ minX: number;
16
+ minY: number;
17
+ maxX: number;
18
+ maxY: number;
19
+ readonly width: number;
20
+ readonly height: number;
21
+ addPoint(x: number, y: number): void;
22
+ copy(): BBox;
23
+ }
24
+
25
+ /** Vector path command. */
26
+ export interface PathCommand {
27
+ command: 'moveTo' | 'lineTo' | 'quadraticCurveTo' | 'bezierCurveTo' | 'closePath';
28
+ args: number[];
29
+ }
30
+
31
+ /** Minimal canvas-like context used by Path.toFunction / Glyph.render. */
32
+ export interface PathRenderingContext {
33
+ save(): void;
34
+ restore(): void;
35
+ scale(x: number, y: number): void;
36
+ fill(): void;
37
+ moveTo?(x: number, y: number): void;
38
+ lineTo?(x: number, y: number): void;
39
+ quadraticCurveTo?(cpx: number, cpy: number, x: number, y: number): void;
40
+ bezierCurveTo?(
41
+ cp1x: number,
42
+ cp1y: number,
43
+ cp2x: number,
44
+ cp2y: number,
45
+ x: number,
46
+ y: number
47
+ ): void;
48
+ closePath?(): void;
49
+ [key: string]: unknown;
50
+ }
51
+
52
+ /** Outline path returned by glyphs. */
53
+ export interface Path {
54
+ commands: PathCommand[];
55
+ readonly cbox: BBox;
56
+ readonly bbox: BBox;
57
+ toFunction(): (ctx: PathRenderingContext) => void;
58
+ toSVG(): string;
59
+ mapPoints(fn: (x: number, y: number) => [number, number]): Path;
60
+ transform(m0: number, m1: number, m2: number, m3: number, m4: number, m5: number): Path;
61
+ translate(x: number, y: number): Path;
62
+ rotate(angle: number): Path;
63
+ scale(scaleX: number, scaleY?: number): Path;
64
+ moveTo(x: number, y: number): Path;
65
+ lineTo(x: number, y: number): Path;
66
+ quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): Path;
67
+ bezierCurveTo(
68
+ cp1x: number,
69
+ cp1y: number,
70
+ cp2x: number,
71
+ cp2y: number,
72
+ x: number,
73
+ y: number
74
+ ): Path;
75
+ closePath(): Path;
76
+ }
77
+
78
+ /** Per-glyph advance / bearing metrics. */
79
+ export interface GlyphMetrics {
80
+ width: number;
81
+ height: number;
82
+ advanceWidth: number;
83
+ advanceHeight: number;
84
+ leftBearing: number;
85
+ topBearing: number;
86
+ rightBearing: number;
87
+ bottomBearing: number;
88
+ }
89
+
90
+ /** A glyph in a font. */
91
+ export interface Glyph {
92
+ id: number;
93
+ codePoints: number[];
94
+ isMark: boolean;
95
+ isLigature: boolean;
96
+ readonly cbox: BBox;
97
+ readonly bbox: BBox;
98
+ readonly path: Path;
99
+ readonly width: number;
100
+ readonly height: number;
101
+ readonly advanceWidth: number;
102
+ readonly advanceHeight: number;
103
+ readonly leftBearing: number;
104
+ readonly topBearing: number;
105
+ readonly rightBearing: number;
106
+ readonly bottomBearing: number;
107
+ readonly name: string | null;
108
+ getScaledPath(size: number): Path;
109
+ render(ctx: PathRenderingContext, size: number): void;
110
+ }
111
+
112
+ /** Positioning for one glyph in a GlyphRun. */
113
+ export interface GlyphPosition {
114
+ xAdvance: number;
115
+ yAdvance: number;
116
+ xOffset: number;
117
+ yOffset: number;
118
+ }
119
+
120
+ /** Result of Font.layout(). */
121
+ export interface GlyphRun {
122
+ glyphs: Glyph[];
123
+ positions: GlyphPosition[] | null;
124
+ script: ScriptTag | string[] | null | undefined;
125
+ language: LanguageTag | null;
126
+ direction: TextDirection;
127
+ features: FeatureMap;
128
+ readonly advanceWidth: number;
129
+ readonly advanceHeight: number;
130
+ readonly bbox: BBox;
131
+ }
132
+
133
+ /** Variation axis description. */
134
+ export interface VariationAxisInfo {
135
+ name: string | null;
136
+ min: number;
137
+ default: number;
138
+ max: number;
139
+ }
140
+
141
+ /** Font subset writer. */
142
+ export interface Subset {
143
+ includeGlyph(glyph: Glyph | number): number;
144
+ encodeStream(): unknown;
145
+ encode(cb?: (err: Error | null, data?: Uint8Array) => void): Promise<Uint8Array> | void;
146
+ }
147
+
148
+ /**
149
+ * An opened font (or a font selected from a collection).
150
+ * Matches the public surface of TTFFont / WOFF / WOFF2 / etc.
151
+ */
152
+ export interface Font {
153
+ type: string;
154
+ readonly postscriptName: string | null;
155
+ readonly fullName: string | null;
156
+ readonly familyName: string | null;
157
+ readonly subfamilyName: string | null;
158
+ readonly copyright: string | null;
159
+ readonly version: string | null;
160
+ readonly unitsPerEm: number;
161
+ readonly ascent: number;
162
+ readonly descent: number;
163
+ readonly lineGap: number;
164
+ readonly underlinePosition: number;
165
+ readonly underlineThickness: number;
166
+ readonly italicAngle: number;
167
+ readonly capHeight: number;
168
+ readonly xHeight: number;
169
+ readonly bbox: BBox;
170
+ readonly numGlyphs: number;
171
+ readonly characterSet: number[];
172
+ readonly availableFeatures: string[];
173
+ readonly variationAxes: Record<string, VariationAxisInfo>;
174
+ readonly namedVariations: Record<string, Record<string, number>>;
175
+
176
+ setDefaultLanguage(lang?: string | null): void;
177
+ getName(key: string, lang?: string): string | null;
178
+ hasGlyphForCodePoint(codePoint: number): boolean;
179
+ glyphForCodePoint(codePoint: number): Glyph | null;
180
+ glyphsForString(string: string): Glyph[];
181
+ layout(
182
+ string: string,
183
+ userFeatures?: FeatureInput | null,
184
+ script?: ScriptTag | string[] | null,
185
+ language?: LanguageTag | null,
186
+ direction?: TextDirection | null
187
+ ): GlyphRun;
188
+ stringsForGlyph(gid: number): string[];
189
+ getAvailableFeatures(
190
+ script?: ScriptTag | string[] | null,
191
+ language?: LanguageTag | null
192
+ ): string[];
193
+ getGlyph(glyph: number, characters?: number[]): Glyph | null;
194
+ createSubset(): Subset;
195
+ getVariation(variation: string | Record<string, number> | number[]): Font;
196
+ getFont?(
197
+ postscriptName: string | Uint8Array | Record<string, number>
198
+ ): Font | null | undefined;
199
+ }
200
+
201
+ /** Constructible font format registered with registerFormat(). */
202
+ export interface FontFormat {
203
+ new (stream: unknown, variationCoords?: number[] | null): Font;
204
+ probe(buffer: ArrayBufferView): boolean;
205
+ }
206
+
207
+ export declare let logErrors: boolean;
208
+ export declare let defaultLanguage: string;
209
+
210
+ export declare function registerFormat(format: FontFormat): void;
211
+ export declare function create(
212
+ buffer: ArrayBufferView,
213
+ postscriptName?: string | Uint8Array
214
+ ): Font | null | undefined;
215
+ export declare function setDefaultLanguage(lang?: string): void;
216
+
217
+ /** Node-only: open a font file asynchronously. */
218
+ export declare function open(
219
+ filename: string | import('fs').PathLike,
220
+ postscriptName?: string | Uint8Array
221
+ ): Promise<Font | null | undefined>;
222
+
223
+ /** Node-only: open a font file synchronously. */
224
+ export declare function openSync(
225
+ filename: string | import('fs').PathLike,
226
+ postscriptName?: string | Uint8Array
227
+ ): Font | null | undefined;
228
+
229
+ declare const fontkit: {
230
+ logErrors: boolean;
231
+ defaultLanguage: string;
232
+ registerFormat: typeof registerFormat;
233
+ create: typeof create;
234
+ setDefaultLanguage: typeof setDefaultLanguage;
235
+ open: typeof open;
236
+ openSync: typeof openSync;
237
+ };
238
+
239
+ export default fontkit;