Skip to content

Commit e36d481

Browse files
committed
Document Typr, fix missing optional
1 parent d90e3a2 commit e36d481

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

utils/patch.mjs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function applyPatches() {
102102
replace(
103103
['p5.d.ts', 'global.d.ts'],
104104
/loadFont\((.+), successCallback\?: Function, (.+)\): Promise\<([pP]5)\.Font\>;/g,
105-
'loadFont($1, successCallback: (font: $3.Font) => any, $2): Promise<$3.Font>;'
105+
'loadFont($1, successCallback?: (font: $3.Font) => any, $2): Promise<$3.Font>;'
106106
);
107107

108108
// Type returned objects
@@ -122,6 +122,39 @@ export function applyPatches() {
122122
'textBounds(str: string, x: number, y: number, width?: number, height?: number): { x: number; y: number; w: number; h: number };',
123123
);
124124

125+
// Document Typr
126+
replace(
127+
'p5.d.ts',
128+
'class Font {',
129+
`class Font {
130+
/** The CSS name for the font. */
131+
name: string;
132+
133+
/** The CSS FontFace definition for the font. */
134+
face: FontFace;
135+
136+
/** Typr data for the font. */
137+
data?: {
138+
_data: Uint8Array;
139+
GSUB: Record<string, any>;
140+
'OS/2': Record<string, any>;
141+
cmap: {
142+
ids: Record<string, any>;
143+
tables: Array<Record<string, any>>;
144+
off: number;
145+
};
146+
glyf: Array<any>;
147+
head: Record<string, any>;
148+
hhea: Record<string, any>;
149+
htmx: Record<string, any>;
150+
loca: Array<number>;
151+
maxp: Record<string, any>;
152+
name: Record<string, any>;
153+
post: Record<string, any>;
154+
};
155+
`
156+
);
157+
125158
for (const [path, data] of Object.entries(patched)) {
126159
try {
127160
console.log(`Patched ${path}`);

0 commit comments

Comments
 (0)