@unocss/preset-web-fonts 0.53.4 → 0.53.6

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/index.cjs CHANGED
@@ -11,16 +11,15 @@ function createBunnyFontsProvider(name, host) {
11
11
  const fontFamilies = fonts.map((font) => {
12
12
  const { name: name2, weights, italic } = font;
13
13
  const formattedName = name2.toLowerCase().replace(/\s/g, "-");
14
- if (!weights?.length) {
14
+ if (!weights?.length)
15
15
  return `${formattedName}${italic ? ":i" : ""}`;
16
- }
17
- let weightsAsString = weights.sort().map((weight) => weight.toString());
16
+ let weightsAsString = weights.map((weight) => weight.toString());
18
17
  const weightsHaveItalic = weightsAsString.some((weight) => weight.endsWith("i"));
19
18
  if (!weightsHaveItalic && italic)
20
19
  weightsAsString = weightsAsString.map((weight) => weight += "i");
21
20
  return `${formattedName}:${weightsAsString.join(",")}`;
22
21
  });
23
- return `${host}/css?family=${fontFamilies.join("|")}`;
22
+ return `${host}/css?family=${fontFamilies.join("|")}&display=swap`;
24
23
  }
25
24
  };
26
25
  }
@@ -94,13 +93,13 @@ function normalizedFontMeta(meta, defaultProvider) {
94
93
  if (typeof meta !== "string") {
95
94
  meta.provider = resolveProvider(meta.provider || defaultProvider);
96
95
  if (meta.weights)
97
- meta.weights = [...new Set(meta.weights.map(Number).sort((a, b) => a - b))];
96
+ meta.weights = [...new Set(meta.weights.sort((a, b) => a.toString().localeCompare(b.toString(), "en", { numeric: true })))];
98
97
  return meta;
99
98
  }
100
99
  const [name, weights = ""] = meta.split(":");
101
100
  return {
102
101
  name,
103
- weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).map(Number).sort((a, b) => a - b))],
102
+ weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).sort((a, b) => a.localeCompare(b, "en", { numeric: true })))],
104
103
  provider: resolveProvider(defaultProvider)
105
104
  };
106
105
  }
package/dist/index.mjs CHANGED
@@ -7,16 +7,15 @@ function createBunnyFontsProvider(name, host) {
7
7
  const fontFamilies = fonts.map((font) => {
8
8
  const { name: name2, weights, italic } = font;
9
9
  const formattedName = name2.toLowerCase().replace(/\s/g, "-");
10
- if (!weights?.length) {
10
+ if (!weights?.length)
11
11
  return `${formattedName}${italic ? ":i" : ""}`;
12
- }
13
- let weightsAsString = weights.sort().map((weight) => weight.toString());
12
+ let weightsAsString = weights.map((weight) => weight.toString());
14
13
  const weightsHaveItalic = weightsAsString.some((weight) => weight.endsWith("i"));
15
14
  if (!weightsHaveItalic && italic)
16
15
  weightsAsString = weightsAsString.map((weight) => weight += "i");
17
16
  return `${formattedName}:${weightsAsString.join(",")}`;
18
17
  });
19
- return `${host}/css?family=${fontFamilies.join("|")}`;
18
+ return `${host}/css?family=${fontFamilies.join("|")}&display=swap`;
20
19
  }
21
20
  };
22
21
  }
@@ -90,13 +89,13 @@ function normalizedFontMeta(meta, defaultProvider) {
90
89
  if (typeof meta !== "string") {
91
90
  meta.provider = resolveProvider(meta.provider || defaultProvider);
92
91
  if (meta.weights)
93
- meta.weights = [...new Set(meta.weights.map(Number).sort((a, b) => a - b))];
92
+ meta.weights = [...new Set(meta.weights.sort((a, b) => a.toString().localeCompare(b.toString(), "en", { numeric: true })))];
94
93
  return meta;
95
94
  }
96
95
  const [name, weights = ""] = meta.split(":");
97
96
  return {
98
97
  name,
99
- weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).map(Number).sort((a, b) => a - b))],
98
+ weights: [...new Set(weights.split(/[,;]\s*/).filter(Boolean).sort((a, b) => a.localeCompare(b, "en", { numeric: true })))],
100
99
  provider: resolveProvider(defaultProvider)
101
100
  };
102
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-web-fonts",
3
- "version": "0.53.4",
3
+ "version": "0.53.6",
4
4
  "description": "Web Fonts support for Uno CSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "ofetch": "^1.1.1",
41
- "@unocss/core": "0.53.4"
41
+ "@unocss/core": "0.53.6"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "unbuild",