embroidery-qc-image 1.0.33 → 1.0.34
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/dist/components/EmbroideryQCImage.d.ts.map +1 -1
- package/dist/index.esm.js +24 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -143,18 +143,30 @@ const loadFont = (fontName) => {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
return new Promise((resolve) => {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
const fontFormats = ['woff2', 'ttf', 'otf'];
|
|
147
|
+
let currentFormatIndex = 0;
|
|
148
|
+
const tryLoadFont = () => {
|
|
149
|
+
if (currentFormatIndex >= fontFormats.length) {
|
|
150
|
+
console.warn(`Could not load font ${fontName} from CDN (tried all formats)`);
|
|
151
|
+
resolve();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const format = fontFormats[currentFormatIndex];
|
|
155
|
+
const fontUrl = `${BASE_URLS.FONT}/${encodeURIComponent(fontName)}.${format}`;
|
|
156
|
+
const fontFace = new FontFace(fontName, `url(${fontUrl})`);
|
|
157
|
+
fontFace
|
|
158
|
+
.load()
|
|
159
|
+
.then((loadedFont) => {
|
|
160
|
+
document.fonts.add(loadedFont);
|
|
161
|
+
resolve();
|
|
162
|
+
})
|
|
163
|
+
.catch(() => {
|
|
164
|
+
// Try next format
|
|
165
|
+
currentFormatIndex++;
|
|
166
|
+
tryLoadFont();
|
|
167
|
+
});
|
|
168
|
+
};
|
|
169
|
+
tryLoadFont();
|
|
158
170
|
});
|
|
159
171
|
};
|
|
160
172
|
const getImageUrl = (type, value) => {
|