@types/opentype.js 1.3.3 → 1.3.5

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.
opentype.js/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for opentype.js (https://github.com/opent
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/opentype.js.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 09 Aug 2021 19:31:27 GMT
11
+ * Last updated: Sun, 03 Sep 2023 22:33:58 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `opentype`
14
14
 
opentype.js/index.d.ts CHANGED
@@ -36,7 +36,7 @@ export class Font {
36
36
  x?: number,
37
37
  y?: number,
38
38
  fontSize?: number,
39
- options?: RenderOptions
39
+ options?: RenderOptions,
40
40
  ): void;
41
41
  drawMetrics(
42
42
  ctx: CanvasRenderingContext2D,
@@ -44,7 +44,7 @@ export class Font {
44
44
  x?: number,
45
45
  y?: number,
46
46
  fontSize?: number,
47
- options?: RenderOptions
47
+ options?: RenderOptions,
48
48
  ): void;
49
49
  drawPoints(
50
50
  ctx: CanvasRenderingContext2D,
@@ -52,7 +52,7 @@ export class Font {
52
52
  x?: number,
53
53
  y?: number,
54
54
  fontSize?: number,
55
- options?: RenderOptions
55
+ options?: RenderOptions,
56
56
  ): void;
57
57
  forEachGlyph(
58
58
  text: string,
@@ -60,38 +60,13 @@ export class Font {
60
60
  y: number | undefined,
61
61
  fontSize: number | undefined,
62
62
  options: RenderOptions | undefined,
63
- callback: (
64
- glyph: Glyph,
65
- x: number,
66
- y: number,
67
- fontSize: number,
68
- options?: RenderOptions
69
- ) => void
70
- ): number;
71
- getAdvanceWidth(
72
- text: string,
73
- fontSize?: number,
74
- options?: RenderOptions
63
+ callback: (glyph: Glyph, x: number, y: number, fontSize: number, options?: RenderOptions) => void,
75
64
  ): number;
65
+ getAdvanceWidth(text: string, fontSize?: number, options?: RenderOptions): number;
76
66
  getEnglishName(name: string): string;
77
- getKerningValue(
78
- leftGlyph: Glyph | number,
79
- rightGlyph: Glyph | number
80
- ): number;
81
- getPath(
82
- text: string,
83
- x: number,
84
- y: number,
85
- fontSize: number,
86
- options?: RenderOptions
87
- ): Path;
88
- getPaths(
89
- text: string,
90
- x: number,
91
- y: number,
92
- fontSize: number,
93
- options?: RenderOptions
94
- ): Path[];
67
+ getKerningValue(leftGlyph: Glyph | number, rightGlyph: Glyph | number): number;
68
+ getPath(text: string, x: number, y: number, fontSize: number, options?: RenderOptions): Path;
69
+ getPaths(text: string, x: number, y: number, fontSize: number, options?: RenderOptions): Path[];
95
70
  glyphIndexToName(gid: number): string;
96
71
  glyphNames: GlyphNames;
97
72
  hasChar(c: string): boolean;
@@ -108,8 +83,10 @@ export class Font {
108
83
  validate(): void;
109
84
  }
110
85
 
111
- export type FontConstructorOptions = FontConstructorOptionsBase &
112
- Partial<FontOptions> & {
86
+ export type FontConstructorOptions =
87
+ & FontConstructorOptionsBase
88
+ & Partial<FontOptions>
89
+ & {
113
90
  glyphs: Glyph[];
114
91
  };
115
92
 
@@ -192,66 +169,48 @@ export interface Field {
192
169
 
193
170
  export class Glyph {
194
171
  index: number;
195
- private xMin;
196
- private xMax;
197
- private yMin;
198
- private yMax;
199
- private points;
200
-
201
- name: string;
202
- path: Path | (() => Path);
203
- unicode: number;
172
+ name: string | null;
173
+ unicode?: number | undefined;
204
174
  unicodes: number[];
205
- advanceWidth: number;
175
+ xMin?: number | undefined;
176
+ xMax?: number | undefined;
177
+ yMin?: number | undefined;
178
+ yMax?: number | undefined;
179
+ advanceWidth?: number | undefined;
180
+ leftSideBearing?: number | undefined;
181
+ path: Path;
206
182
 
183
+ private bindConstructorValues(options: GlyphOptions): void;
207
184
  constructor(options: GlyphOptions);
208
185
 
209
186
  addUnicode(unicode: number): void;
210
- bindConstructorValues(options: GlyphOptions): void;
211
- draw(
212
- ctx: CanvasRenderingContext2D,
213
- x?: number,
214
- y?: number,
215
- fontSize?: number,
216
- options?: RenderOptions
217
- ): void;
218
- drawMetrics(
219
- ctx: CanvasRenderingContext2D,
220
- x?: number,
221
- y?: number,
222
- fontSize?: number,
223
- options?: RenderOptions
224
- ): void;
225
- drawPoints(
226
- ctx: CanvasRenderingContext2D,
227
- x?: number,
228
- y?: number,
229
- fontSize?: number,
230
- options?: RenderOptions
231
- ): void;
232
187
  getBoundingBox(): BoundingBox;
188
+ getPath(x?: number, y?: number, fontSize?: number, options?: RenderOptions, font?: Font): Path;
233
189
  getContours(): Contour;
234
190
  getMetrics(): Metrics;
235
- getPath(
191
+ draw(ctx: CanvasRenderingContext2D, x?: number, y?: number, fontSize?: number, options?: RenderOptions): void;
192
+ drawPoints(ctx: CanvasRenderingContext2D, x?: number, y?: number, fontSize?: number, options?: RenderOptions): void;
193
+ drawMetrics(
194
+ ctx: CanvasRenderingContext2D,
236
195
  x?: number,
237
196
  y?: number,
238
197
  fontSize?: number,
239
198
  options?: RenderOptions,
240
- font?: Font
241
- ): Path;
199
+ ): void;
242
200
  }
201
+
243
202
  export interface GlyphOptions {
244
- advanceWidth?: number | undefined;
245
203
  index?: number | undefined;
246
- font?: Font | undefined;
247
204
  name?: string | undefined;
248
- path?: Path | undefined;
249
205
  unicode?: number | undefined;
250
206
  unicodes?: number[] | undefined;
251
- xMax?: number | undefined;
252
207
  xMin?: number | undefined;
253
- yMax?: number | undefined;
254
208
  yMin?: number | undefined;
209
+ xMax?: number | undefined;
210
+ yMax?: number | undefined;
211
+ advanceWidth?: number | undefined;
212
+ leftSideBearing?: number | undefined;
213
+ path?: Path | (() => Path) | undefined;
255
214
  }
256
215
 
257
216
  export class GlyphNames {
@@ -264,7 +223,7 @@ export class GlyphNames {
264
223
  export class GlyphSet {
265
224
  private font;
266
225
  private glyphs;
267
- constructor(font: Font, glyphs: Glyph[] | Array<(() => Glyph)>);
226
+ constructor(font: Font, glyphs: Glyph[] | Array<() => Glyph>);
268
227
  get(index: number): Glyph;
269
228
  length: number;
270
229
  push(index: number, loader: () => Glyph): void;
@@ -294,9 +253,11 @@ export interface RenderOptions {
294
253
  yScale?: number | undefined;
295
254
  letterSpacing?: number | undefined;
296
255
  tracking?: number | undefined;
297
- features?: {
298
- [key: string]: boolean;
299
- } | undefined;
256
+ features?:
257
+ | {
258
+ [key: string]: boolean;
259
+ }
260
+ | undefined;
300
261
  }
301
262
 
302
263
  export interface Metrics {
@@ -323,25 +284,11 @@ export class Path {
323
284
  stroke: string | null;
324
285
  strokeWidth: number;
325
286
  constructor();
326
- bezierCurveTo(
327
- x1: number,
328
- y1: number,
329
- x2: number,
330
- y2: number,
331
- x: number,
332
- y: number
333
- ): void;
287
+ bezierCurveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): void;
334
288
  close: () => void;
335
289
  closePath(): void;
336
290
  commands: PathCommand[];
337
- curveTo: (
338
- x1: number,
339
- y1: number,
340
- x2: number,
341
- y2: number,
342
- x: number,
343
- y: number
344
- ) => void;
291
+ curveTo: (x1: number, y1: number, x2: number, y2: number, x: number, y: number) => void;
345
292
  draw(ctx: CanvasRenderingContext2D): void;
346
293
  extend(pathOrCommands: Path | PathCommand[] | BoundingBox): void;
347
294
  getBoundingBox(): BoundingBox;
@@ -356,35 +303,35 @@ export class Path {
356
303
  }
357
304
 
358
305
  export type PathCommand =
359
- | {
360
- type: "M";
361
- x: number;
362
- y: number;
363
- }
364
- | {
365
- type: "L";
366
- x: number;
367
- y: number;
368
- }
369
- | {
370
- type: "C";
371
- x1: number;
372
- y1: number;
373
- x2: number;
374
- y2: number;
375
- x: number;
376
- y: number;
377
- }
378
- | {
379
- type: "Q";
380
- x1: number;
381
- y1: number;
382
- x: number;
383
- y: number;
384
- }
385
- | {
386
- type: "Z";
387
- };
306
+ | {
307
+ type: "M";
308
+ x: number;
309
+ y: number;
310
+ }
311
+ | {
312
+ type: "L";
313
+ x: number;
314
+ y: number;
315
+ }
316
+ | {
317
+ type: "C";
318
+ x1: number;
319
+ y1: number;
320
+ x2: number;
321
+ y2: number;
322
+ x: number;
323
+ y: number;
324
+ }
325
+ | {
326
+ type: "Q";
327
+ x1: number;
328
+ y1: number;
329
+ x: number;
330
+ y: number;
331
+ }
332
+ | {
333
+ type: "Z";
334
+ };
388
335
 
389
336
  /******************************************
390
337
  * UTIL CLASSES
@@ -417,16 +364,14 @@ export type Substitution = (font: Font) => any;
417
364
  * STATIC
418
365
  ******************************************/
419
366
 
420
- export function load(
421
- url: string,
422
- callback: (error: any, font?: Font) => void
423
- ): void;
424
- export function load(
425
- url: string,
426
- ): Promise<Font>;
367
+ export function load(url: string, callback: (error: any, font?: Font) => void): void;
368
+ export function load(url: string): Promise<Font>;
427
369
 
428
- export function loadSync(url: string, opt?: {
429
- lowMemory: boolean;
430
- }): Font;
370
+ export function loadSync(
371
+ url: string,
372
+ opt?: {
373
+ lowMemory: boolean;
374
+ },
375
+ ): Font;
431
376
 
432
377
  export function parse(buffer: any): Font;
opentype.js/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/opentype.js",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "TypeScript definitions for opentype.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/opentype.js",
6
6
  "license": "MIT",
@@ -30,6 +30,6 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "54dd6ba58b3c3e225056368a0ca1ecfcbdc73933c6b79eac5f87bea0e4e4fe1c",
34
- "typeScriptVersion": "3.6"
33
+ "typesPublisherContentHash": "687758604d5e2e562476c7ada55fd9962f83c5b70bb08400a09db88be0929a5b",
34
+ "typeScriptVersion": "4.3"
35
35
  }