@webstudio-is/fonts 0.119.0 → 0.121.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.
Files changed (2) hide show
  1. package/lib/index.js +4 -3
  2. package/package.json +1 -1
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('${url}') format('${format}')`,
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('${url}') format('${format}')`
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('${url}') format('${format}')`;
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.119.0",
3
+ "version": "0.121.0",
4
4
  "description": "Fonts utils",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",