diff --git a/types/pdfkit/index.d.ts b/types/pdfkit/index.d.ts index bdd57d1b84..9bc92381a9 100644 --- a/types/pdfkit/index.d.ts +++ b/types/pdfkit/index.d.ts @@ -5,6 +5,7 @@ // Jeroen Vervaeke // Thales Agapito // Evgeny Baram +// BamButz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -69,6 +70,31 @@ declare namespace PDFKit.Mixins { // The winding / filling rule accepted by PDFKit: type RuleValue = 'even-odd' | 'evenodd' | 'non-zero' | 'nonzero'; + // Text option opentype features as listed at https://docs.microsoft.com/en-us/typography/opentype/spec/featurelist + type OpenTypeFeatures = + | 'aalt' | 'abvf' | 'abvm' | 'abvs' | 'afrc' | 'akhn' | 'blwf' | 'blwm' | 'blws' | 'calt' | 'case' + | 'cfar' | 'cjct' | 'clig' | 'cpct' | 'cpsp' | 'cswh' | 'curs' | 'cv01' | 'cv02' | 'cv03' | 'cv04' + | 'cv05' | 'cv06' | 'cv07' | 'cv08' | 'cv09' | 'cv10' | 'cv11' | 'cv12' | 'cv13' | 'cv14' | 'cv15' + | 'cv16' | 'cv17' | 'cv18' | 'cv19' | 'cv20' | 'cv21' | 'cv22' | 'cv23' | 'cv24' | 'cv25' | 'cv26' + | 'cv27' | 'cv28' | 'cv29' | 'cv30' | 'cv31' | 'cv32' | 'cv33' | 'cv34' | 'cv35' | 'cv36' | 'cv37' + | 'cv38' | 'cv39' | 'cv40' | 'cv41' | 'cv42' | 'cv43' | 'cv44' | 'cv45' | 'cv46' | 'cv47' | 'cv48' + | 'cv49' | 'cv50' | 'cv51' | 'cv52' | 'cv53' | 'cv54' | 'cv55' | 'cv56' | 'cv57' | 'cv58' | 'cv59' + | 'cv60' | 'cv61' | 'cv62' | 'cv63' | 'cv64' | 'cv65' | 'cv66' | 'cv67' | 'cv68' | 'cv69' | 'cv70' + | 'cv71' | 'cv72' | 'cv73' | 'cv74' | 'cv75' | 'cv76' | 'cv77' | 'cv78' | 'cv79' | 'cv80' | 'cv81' + | 'cv82' | 'cv83' | 'cv84' | 'cv85' | 'cv86' | 'cv87' | 'cv88' | 'cv89' | 'cv90' | 'cv91' | 'cv92' + | 'cv93' | 'cv94' | 'cv95' | 'cv96' | 'cv97' | 'cv98' | 'cv99' | 'c2pc' | 'c2sc' | 'dist' | 'ccmp' + | 'dlig' | 'dnom' | 'dtls' | 'expt' | 'falt' | 'fin2' | 'fin3' | 'fina' | 'flac' | 'frac' | 'fwid' + | 'half' | 'haln' | 'halt' | 'hist' | 'hkna' | 'hlig' | 'hngl' | 'hojo' | 'hwid' | 'init' | 'isol' + | 'ital' | 'jalt' | 'jp78' | 'jp83' | 'jp90' | 'jp04' | 'kern' | 'lfbd' | 'liga' | 'ljmo' | 'lnum' + | 'locl' | 'ltra' | 'ltrm' | 'mark' | 'med2' | 'medi' | 'mgrk' | 'mkmk' | 'mset' | 'nalt' | 'nlck' + | 'nukt' | 'numr' | 'onum' | 'opbd' | 'ordn' | 'ornm' | 'palt' | 'pcap' | 'pkna' | 'pnum' | 'pref' + | 'pres' | 'pstf' | 'psts' | 'pwid' | 'qwid' | 'rand' | 'rclt' | 'rkrf' | 'rlig' | 'rphf' | 'rtbd' + | 'rtla' | 'rtlm' | 'ruby' | 'rvrn' | 'salt' | 'sinf' | 'size' | 'smcp' | 'smpl' | 'ss01' | 'ss02' + | 'ss03' | 'ss04' | 'ss05' | 'ss06' | 'ss07' | 'ss08' | 'ss09' | 'ss10' | 'ss11' | 'ss12' | 'ss13' + | 'ss14' | 'ss15' | 'ss16' | 'ss17' | 'ss18' | 'ss19' | 'ss20' | 'ssty' | 'stch' | 'subs' | 'sups' + | 'swsh' | 'titl' | 'tjmo' | 'tnam' | 'tnum' | 'trad' | 'twid' | 'unic' | 'valt' | 'vatu' | 'vert' + | 'vhal' | 'vjmo' | 'vkna' | 'vkrn' | 'vpal' | 'vrt2' | 'vrtr' | 'zero'; + interface PDFColor { fillColor(color: ColorValue, opacity?: number): this; strokeColor(color: ColorValue, opacity?: number): this; @@ -152,6 +178,8 @@ declare namespace PDFKit.Mixins { align?: 'center' | 'justify' | 'left' | 'right' | string; /** the vertical alignment of the text with respect to its insertion point */ baseline?: number | 'svg-middle' | 'middle' | 'svg-central' | 'bottom' | 'ideographic' | 'alphabetic' | 'mathematical' | 'hanging' | 'top'; + /** an array of OpenType feature tags to apply. If not provided, a set of defaults is used. */ + features?: OpenTypeFeatures[]; } interface PDFText { diff --git a/types/pdfkit/pdfkit-tests.ts b/types/pdfkit/pdfkit-tests.ts index 7d6d29baa6..47d14da62b 100644 --- a/types/pdfkit/pdfkit-tests.ts +++ b/types/pdfkit/pdfkit-tests.ts @@ -181,6 +181,8 @@ doc.text('Baseline - string literal', { baseline: 'alphabetic' }); doc.text('Baseline - numeric', { baseline: 10 }); +doc.text('Text with features', { features: [ "kern" ] }); + doc.goTo(0, 0, 0, 0, 'lorem'); doc.image('path/to/image.png', { @@ -227,4 +229,4 @@ class SubPDFDocument extends PDFDocument { var subDoc = new SubPDFDocument({}); subDoc.moveTo(subDoc.page.width / 2, subDoc.page.height / 2).text(10); -subDoc.lineWidth(3).segment(10, subDoc.page.width - 10, subDoc.page.height - 10, 10).stroke("#00FFFF"); \ No newline at end of file +subDoc.lineWidth(3).segment(10, subDoc.page.width - 10, subDoc.page.height - 10, 10).stroke("#00FFFF");