@cosxai/ui 0.13.1 → 0.13.2
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/package.json
CHANGED
|
@@ -156,14 +156,29 @@ export const SignaturePad = forwardRef<SignaturePadHandle, SignaturePadProps>(
|
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
let cancelled = false;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
159
|
+
// Actively REQUEST the typed font. @font-face registration
|
|
160
|
+
// (fontsource CSS etc.) doesn't fetch the file until some
|
|
161
|
+
// rendered text uses it — and this component's only consumer
|
|
162
|
+
// of the font is the canvas, whose fillText silently falls
|
|
163
|
+
// back to the next family when the face isn't loaded yet.
|
|
164
|
+
// fonts.load() forces the fetch; fonts.ready is the safety
|
|
165
|
+
// net for browsers without it / faces not registered.
|
|
166
|
+
const kick =
|
|
167
|
+
typeof fonts.load === "function"
|
|
168
|
+
? fonts.load(`32px ${typedFontFamily}`).catch(() => [])
|
|
169
|
+
: Promise.resolve([]);
|
|
170
|
+
void kick
|
|
171
|
+
.then(() => fonts.ready)
|
|
172
|
+
.then(() => {
|
|
173
|
+
if (cancelled) return;
|
|
174
|
+
setFontReady(true);
|
|
175
|
+
});
|
|
163
176
|
return () => {
|
|
164
177
|
cancelled = true;
|
|
165
178
|
};
|
|
166
|
-
|
|
179
|
+
// typedFontFamily is config-stable per consumer; re-kicking on
|
|
180
|
+
// change is correct anyway.
|
|
181
|
+
}, [fontReady, typedFontFamily]);
|
|
167
182
|
|
|
168
183
|
// Mode switch — clear the canvas so a stale typed baseline
|
|
169
184
|
// doesn't hang around behind a drawn signature (or vice versa).
|