Skip to content

Commit eba1e4a

Browse files
authored
Adds deregisterAllFonts to the typescript declaration file (#2096)
* Adds deregisterAllFonts to the typescript declaration file * updates changelog with deregisterAllFonts type fix
1 parent 10b208e commit eba1e4a

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
1616
* `createPattern()` always used "repeat" mode; now supports "repeat-x" and "repeat-y". ([#2066](https://github.com/Automattic/node-canvas/issues/2066))
1717
* Crashes and hangs when using non-finite values in `context.arc()`. ([#2055](https://github.com/Automattic/node-canvas/issues/2055))
1818
* Incorrect `context.arc()` geometry logic for full ellipses. ([#1808](https://github.com/Automattic/node-canvas/issues/1808), ([#1736](https://github.com/Automattic/node-canvas/issues/1736)))
19+
* Added missing `deregisterAllFonts` to the Typescript declaration file ([#2096](https://github.com/Automattic/node-canvas/pull/2096))
1920

2021
2.9.3
2122
==================

types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ export function loadImage(src: string|Buffer, options?: any): Promise<Image>
300300
*/
301301
export function registerFont(path: string, fontFace: {family: string, weight?: string, style?: string}): void
302302

303+
/**
304+
* Unloads all fonts
305+
*/
306+
export function deregisterAllFonts(): void;
307+
303308
/** This class must not be constructed directly; use `canvas.createPNGStream()`. */
304309
export class PNGStream extends Readable {}
305310
/** This class must not be constructed directly; use `canvas.createJPEGStream()`. */

types/test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import * as Canvas from 'canvas'
2+
import * as path from "path";
3+
4+
Canvas.registerFont(path.join(__dirname, '../pfennigFont/Pfennig.ttf'), {family: 'pfennigFont'})
25

36
Canvas.createCanvas(5, 10)
47
Canvas.createCanvas(200, 200, 'pdf')
@@ -39,3 +42,5 @@ img.onload = null;
3942
const id2: Canvas.ImageData = Canvas.createImageData(new Uint16Array(4), 1)
4043

4144
ctx.drawImage(canv, 0, 0)
45+
46+
Canvas.deregisterAllFonts();

0 commit comments

Comments
 (0)