@overpunch/vf-clamp 2.2.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -23
- package/dist/index.cjs +427 -160
- package/dist/index.d.ts +34 -4
- package/dist/index.js +531 -388
- package/dist/naming.cjs +1 -0
- package/dist/naming.d.ts +149 -0
- package/dist/naming.js +121 -0
- package/package.json +6 -1
package/dist/index.d.ts
CHANGED
|
@@ -56,8 +56,9 @@ export declare interface ClampOptions {
|
|
|
56
56
|
*/
|
|
57
57
|
format?: OutputFormat;
|
|
58
58
|
/**
|
|
59
|
-
* Refuse any
|
|
60
|
-
* (e.g. Regular + Bold would also hand over Medium and SemiBold).
|
|
59
|
+
* Refuse any output whose range would include a named instance that was not listed
|
|
60
|
+
* (e.g. Regular + Bold would also hand over Medium and SemiBold). Axes-only outputs list none,
|
|
61
|
+
* so they pass only if their range holds no named instance. Throws instead of clamping.
|
|
61
62
|
* Use planOutputs() to split a customer's selection into safe outputs. Defaults to false.
|
|
62
63
|
*/
|
|
63
64
|
strict?: boolean;
|
|
@@ -117,6 +118,10 @@ export declare interface FontInstancesResult {
|
|
|
117
118
|
axes: AxisDefinition[];
|
|
118
119
|
/** All named instances defined in the font */
|
|
119
120
|
instances: FontInstance[];
|
|
121
|
+
/** The font's family name (typographic family, nameID 16, else nameID 1); used to name outputs that set no name */
|
|
122
|
+
family?: string;
|
|
123
|
+
/** STAT names by axis tag and value key (numberKey), e.g. { wdth: { '100': 'Normal' } }; used for default names */
|
|
124
|
+
labels?: Record<string, Record<string, string>>;
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
/**
|
|
@@ -129,6 +134,9 @@ export declare interface FontInstancesResult {
|
|
|
129
134
|
*/
|
|
130
135
|
export declare function getInstances(input: ArrayBuffer | Uint8Array | Buffer): Promise<FontInstancesResult>;
|
|
131
136
|
|
|
137
|
+
/** Stable text key for an axis value, identical to number_key() in Python ('100', '87.5'). */
|
|
138
|
+
export declare function numberKey(value: number): string;
|
|
139
|
+
|
|
132
140
|
/**
|
|
133
141
|
* One output variant to produce from the source variable font.
|
|
134
142
|
* Specify instances, axes, or both — instances set the hull, axes override individual tags.
|
|
@@ -166,17 +174,39 @@ export declare type PinnedAxis = number;
|
|
|
166
174
|
*
|
|
167
175
|
* Selections merge into one output only when their combined range holds no unselected named
|
|
168
176
|
* instance: Regular + Medium + SemiBold + Bold → one output; Regular + Bold alone → two outputs
|
|
169
|
-
* (each pinned to its own instance). Output names come from
|
|
177
|
+
* (each pinned to its own instance). Output names come from rangeName() (one range per axis), optionally prefixed
|
|
170
178
|
* with `family`.
|
|
171
179
|
*
|
|
172
180
|
* @param font - The font's axes and named instances, from getInstances()
|
|
173
181
|
* @param selected - Names of the instances the customer bought (must match exactly)
|
|
174
182
|
* @param family - Optional family name to prefix each output name with, e.g. "Encode Sans"
|
|
175
183
|
* @returns OutputConfig entries ready for clampFont(), sorted along the primary axis
|
|
176
|
-
* @throws If a selected name is not a named instance of the font
|
|
184
|
+
* @throws If a selected name is not a named instance of the font, or names more than one (ambiguous)
|
|
177
185
|
*/
|
|
178
186
|
export declare function planOutputs(font: FontInstancesResult, selected: string[], family?: string): OutputConfig[];
|
|
179
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Default name for a selection of named instances: one range per axis, in the font's own style words
|
|
190
|
+
* ("SemiCondensed-Normal Thin-Light"). TypeScript twin of range_name() in
|
|
191
|
+
* shared/plugin-views/vfclamp_naming.py; both are checked against shared/naming-cases.json, so change
|
|
192
|
+
* them together.
|
|
193
|
+
*
|
|
194
|
+
* Each word is attributed to the one axis that is constant wherever the word appears and varies across
|
|
195
|
+
* the font. An axis that varies in the selection becomes "low-high"; one that doesn't shows its word
|
|
196
|
+
* once, or nothing when that value has no word. A value with no word takes its STAT label, else a
|
|
197
|
+
* default word, else "<tag><value>". Parts follow the order the font's names use; words shared by every
|
|
198
|
+
* selected name and owned by no axis stay before or after them.
|
|
199
|
+
*
|
|
200
|
+
* @param selected - The selected named instances
|
|
201
|
+
* @param instances - Every named instance of the font
|
|
202
|
+
* @param axes - The font's axes (tag and default)
|
|
203
|
+
* @param labels - STAT names by axis tag and numberKey(value), e.g. { wdth: { '100': 'Normal' } }
|
|
204
|
+
*/
|
|
205
|
+
export declare function rangeName(selected: FontInstance[], instances: FontInstance[], axes: Array<{
|
|
206
|
+
tag: string;
|
|
207
|
+
default: number;
|
|
208
|
+
}>, labels?: Record<string, Record<string, string>>): string;
|
|
209
|
+
|
|
180
210
|
/** @deprecated Use OutputConfig instead */
|
|
181
211
|
export declare type SubfamilyConfig = OutputConfig;
|
|
182
212
|
|