@webstudio-is/fonts 0.120.0 → 0.122.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/lib/index.js +4 -3
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var FONT_MIME_TYPES = Array.from(FONT_FORMATS.keys()).map((format) => `.${format
|
|
|
16
16
|
var FONT_STYLES = ["normal", "italic", "oblique"];
|
|
17
17
|
|
|
18
18
|
// src/get-font-faces.ts
|
|
19
|
+
var sanitizeCssUrl = (str) => JSON.stringify(str);
|
|
19
20
|
var formatFace = (asset, format, url) => {
|
|
20
21
|
if ("variationAxes" in asset.meta) {
|
|
21
22
|
const { wght, wdth } = asset.meta?.variationAxes ?? {};
|
|
@@ -23,7 +24,7 @@ var formatFace = (asset, format, url) => {
|
|
|
23
24
|
fontFamily: asset.meta.family,
|
|
24
25
|
fontStyle: "normal",
|
|
25
26
|
fontDisplay: "swap",
|
|
26
|
-
src: `url(
|
|
27
|
+
src: `url(${sanitizeCssUrl(url)}) format("${format}")`,
|
|
27
28
|
fontStretch: wdth ? `${wdth.min}% ${wdth.max}%` : void 0,
|
|
28
29
|
fontWeight: wght ? `${wght.min} ${wght.max}` : void 0
|
|
29
30
|
};
|
|
@@ -33,7 +34,7 @@ var formatFace = (asset, format, url) => {
|
|
|
33
34
|
fontStyle: asset.meta.style,
|
|
34
35
|
fontWeight: asset.meta.weight,
|
|
35
36
|
fontDisplay: "swap",
|
|
36
|
-
src: `url(
|
|
37
|
+
src: `url(${sanitizeCssUrl(url)}) format("${format}")`
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
var getKey = (asset) => {
|
|
@@ -58,7 +59,7 @@ var getFontFaces = (assets, options) => {
|
|
|
58
59
|
faces.set(assetKey, face2);
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
61
|
-
face.src += `, url(
|
|
62
|
+
face.src += `, url(${sanitizeCssUrl(url)}) format("${format}")`;
|
|
62
63
|
}
|
|
63
64
|
return Array.from(faces.values());
|
|
64
65
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/fonts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.122.0",
|
|
4
4
|
"description": "Fonts utils",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"@jest/globals": "^29.7.0",
|
|
10
10
|
"typescript": "5.2.2",
|
|
11
11
|
"zod": "^3.21.4",
|
|
12
|
-
"@webstudio-is/
|
|
13
|
-
"@webstudio-is/
|
|
12
|
+
"@webstudio-is/jest-config": "1.0.7",
|
|
13
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"zod": "^3.19.1"
|