Skip to content

Commit 96b6411

Browse files
committed
choreL update packing
1 parent 370a639 commit 96b6411

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

src/packing.ts

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,44 @@ type FontBox = {
1717
y?: number;
1818
fontName: string;
1919
fileName: string;
20-
styles: string[];
20+
styles: {
21+
variants: string[];
22+
axes?: string[];
23+
};
2124
buffer?: Buffer;
2225
noPreview?: boolean;
2326
};
2427

2528
type FontMetadata = {
29+
/**
30+
* x position of the font preview in the chunk image
31+
*/
2632
x: number;
33+
/**
34+
* y position of the font preview in the chunk image
35+
*/
2736
y: number;
37+
/**
38+
* width of the font preview in the chunk image
39+
*/
2840
w: number;
41+
/**
42+
* chunk index where the font preview is located
43+
*/
2944
ch: number;
30-
s: string[];
45+
/**
46+
* styles available for the font
47+
*/
48+
s: {
49+
/**
50+
* variants available for the font
51+
*/
52+
v: string[];
53+
/**
54+
* axes (tags) available for the font
55+
*/
56+
a?: string[];
57+
};
3158
noPreview?: boolean;
3259
};
3360

@@ -68,7 +95,7 @@ const createFontChunks = async () => {
6895
h: 0,
6996
fontName,
7097
fileName,
71-
styles: styles as string[],
98+
styles: styles as FontBox['styles'],
7299
noPreview: true,
73100
});
74101
continue;
@@ -84,7 +111,7 @@ const createFontChunks = async () => {
84111
h: 0,
85112
fontName,
86113
fileName,
87-
styles: styles as string[],
114+
styles: styles as FontBox['styles'],
88115
noPreview: true,
89116
});
90117
continue;
@@ -110,7 +137,7 @@ const createFontChunks = async () => {
110137
h: newHeight,
111138
fontName,
112139
fileName,
113-
styles: styles as string[],
140+
styles: styles as FontBox['styles'],
114141
buffer: resizedBuffer,
115142
});
116143
} else {
@@ -123,7 +150,7 @@ const createFontChunks = async () => {
123150
h: 0,
124151
fontName,
125152
fileName,
126-
styles: styles as string[],
153+
styles: styles as FontBox['styles'],
127154
noPreview: true,
128155
});
129156
}
@@ -139,7 +166,7 @@ const createFontChunks = async () => {
139166
h: 0,
140167
fontName,
141168
fileName,
142-
styles: styles as string[],
169+
styles: styles as FontBox['styles'],
143170
noPreview: true,
144171
});
145172
}
@@ -220,7 +247,10 @@ const createFontChunks = async () => {
220247
y: box.y!,
221248
w: box.w,
222249
ch: chunkIndex,
223-
s: box.styles,
250+
s: {
251+
v: box.styles.variants,
252+
a: box.styles.axes,
253+
},
224254
};
225255
});
226256

@@ -241,7 +271,10 @@ const createFontChunks = async () => {
241271
y: 0,
242272
w: 0,
243273
ch: 0,
244-
s: box.styles,
274+
s: {
275+
v: box.styles.variants,
276+
a: box.styles.axes,
277+
},
245278
noPreview: true,
246279
};
247280
});

0 commit comments

Comments
 (0)