mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[pdfmake][pdfkit] a font can also be a Buffer (#45377)
* [pdfmake] a font can also be a Buffer ref: https://github.com/foliojs/pdfkit/blob/master/lib/font_factory.js#L9-L22 * [pdfkit] the source of a font can be a Buffer ref: https://github.com/foliojs/pdfkit/blob/master/lib/font_factory.js#L9-L22 * fix lint * fix lint * fix lint * add some tests to register a font with a buffer * use pdfkit font type definition
This commit is contained in:
parent
755394db83
commit
cbb7dee568
4
types/pdfkit/index.d.ts
vendored
4
types/pdfkit/index.d.ts
vendored
@ -105,12 +105,14 @@ declare namespace PDFKit.Mixins {
|
||||
radialGradient(x1: number, y1: number, r1: number, x2: number, y2: number, r2: number): PDFRadialGradient;
|
||||
}
|
||||
|
||||
type PDFFontSource = string | Buffer | Uint8Array | ArrayBuffer;
|
||||
|
||||
interface PDFFont {
|
||||
font(buffer: Buffer): this;
|
||||
font(src: string, family?: string, size?: number): this;
|
||||
fontSize(size: number): this;
|
||||
currentLineHeight(includeGap?: boolean): number;
|
||||
registerFont(name: string, src?: string, family?: string): this;
|
||||
registerFont(name: string, src?: PDFFontSource, family?: string): this;
|
||||
}
|
||||
|
||||
interface ImageOption {
|
||||
|
||||
@ -12,6 +12,8 @@ import pdfData = require('pdfkit/js/data');
|
||||
import text = require('pdfkit/js/mixins/text');
|
||||
|
||||
font.registerFont('Arial');
|
||||
font.registerFont('CustomFont', 'path/to/font.ttf');
|
||||
font.registerFont('CustomFontWithBuffer', Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]));
|
||||
text.widthOfString('Kila', { ellipsis: true });
|
||||
|
||||
var doc = new PDFDocument({
|
||||
|
||||
8
types/pdfmake/interfaces.d.ts
vendored
8
types/pdfmake/interfaces.d.ts
vendored
@ -32,10 +32,10 @@ export interface TFontDictionary {
|
||||
}
|
||||
|
||||
export interface TFontFamilyTypes {
|
||||
normal?: string;
|
||||
bold?: string;
|
||||
italics?: string;
|
||||
bolditalics?: string;
|
||||
normal?: PDFKit.Mixins.PDFFontSource;
|
||||
bold?: PDFKit.Mixins.PDFFontSource;
|
||||
italics?: PDFKit.Mixins.PDFFontSource;
|
||||
bolditalics?: PDFKit.Mixins.PDFFontSource;
|
||||
}
|
||||
|
||||
export interface TDocumentInformation {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user