Skip to content

Commit 0bfb69c

Browse files
committed
types and nitpicks
1 parent 36c4823 commit 0bfb69c

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

.changeset/six-paws-tie.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"@react-pdf/types": minor
55
---
66

7-
Add support for fontFeatureSettings to customise ligatures, tabular number display, and other font features
7+
Add support for fontFeatureSettings to customize ligatures, tabular number display, and other font features

packages/stylesheet/src/types.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,44 @@ export type TextTransform =
321321

322322
export type VerticalAlign = 'sub' | 'super';
323323

324+
export type FontFeatureSetting =
325+
| 'liga'
326+
| 'dlig'
327+
| 'onum'
328+
| 'lnum'
329+
| 'tnum'
330+
| 'zero'
331+
| 'frac'
332+
| 'sups'
333+
| 'subs'
334+
| 'smcp'
335+
| 'c2sc'
336+
| 'case'
337+
| 'hlig'
338+
| 'calt'
339+
| 'swsh'
340+
| 'hist'
341+
| 'ss**'
342+
| 'kern'
343+
| 'locl'
344+
| 'rlig'
345+
| 'medi'
346+
| 'init'
347+
| 'isol'
348+
| 'fina'
349+
| 'mark'
350+
| 'mkmk';
351+
export type FontFeatureSettings =
352+
| FontFeatureSetting[]
353+
| Record<FontFeatureSetting, number>;
354+
324355
export type TextStyle = {
325356
direction?: 'ltr' | 'rtl';
326357
fontSize?: number | string;
327358
fontFamily?: string | string[];
328359
fontStyle?: FontStyle;
329360
fontWeight?: FontWeight;
330-
fontFeatureSettings?: string[] | Record<string, boolean>;
361+
fontFeatureSettings?: FontFeatureSettings;
331362
letterSpacing?: number | string;
332363
lineHeight?: number | string;
333364
maxLines?: number;
@@ -348,6 +379,7 @@ export type TextSafeStyle = TextExpandedStyle & {
348379
fontWeight?: number;
349380
letterSpacing?: number;
350381
lineHeight?: number;
382+
fontFeatureSettings?: FontFeatureSettings;
351383
};
352384

353385
// Margins

packages/textkit/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Glyph as FontkitGlyph } from 'fontkit';
22
import type { Font } from '@rpdf/font';
3+
import type { FontFeatureSettings } from '@rpdf/stylesheet';
34
import { Factor as JustificationFactor } from './engines/justification/types';
45

56
export type Coordinate = {
@@ -51,7 +52,7 @@ export type Attributes = {
5152
characterSpacing?: number;
5253
color?: string;
5354
direction?: 'rtl' | 'ltr';
54-
features?: string[] | Record<string, number>;
55+
features?: FontFeatureSettings;
5556
fill?: boolean;
5657
font?: Font[];
5758
fontSize?: number;

0 commit comments

Comments
 (0)