@unocss/preset-web-fonts 0.45.1 → 0.45.3
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/README.md +2 -1
- package/dist/index.cjs +22 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +22 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,12 +70,13 @@ Currently supported Providers:
|
|
|
70
70
|
|
|
71
71
|
- `none` - do nothing, treat the font as system font
|
|
72
72
|
- `google` - [Google Fonts](https://fonts.google.com/)
|
|
73
|
+
- `bunny` - [Privacy-Friendly Google Fonts](https://fonts.bunny.net/)
|
|
73
74
|
|
|
74
75
|
PR welcome to add more providers 🙌
|
|
75
76
|
|
|
76
77
|
## Configuration
|
|
77
78
|
|
|
78
|
-
Refer to the [type definition](https://github.com/unocss/unocss/blob/main/packages/preset-web-fonts/src/types.ts#L4) for all configurations
|
|
79
|
+
Refer to the [type definition](https://github.com/unocss/unocss/blob/main/packages/preset-web-fonts/src/types.ts#L4) for all configurations available.
|
|
79
80
|
|
|
80
81
|
## License
|
|
81
82
|
|
package/dist/index.cjs
CHANGED
|
@@ -4,22 +4,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const core = require('@unocss/core');
|
|
6
6
|
|
|
7
|
-
const GoogleFontsProvider =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
7
|
+
const GoogleFontsProvider = createGoogleProvider("google", "https://fonts.googleapis.com");
|
|
8
|
+
function createGoogleProvider(name, host) {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
getImportUrl(fonts) {
|
|
12
|
+
const strings = fonts.filter((i) => i.provider === name).map((i) => {
|
|
13
|
+
let name2 = i.name.replace(/\s+/g, "+");
|
|
14
|
+
if (i.weights?.length) {
|
|
15
|
+
name2 += i.italic ? `:ital,wght@${i.weights.flatMap((i2) => [`0,${i2}`, `1,${i2}`]).sort().join(";")}` : `:wght@${i.weights.sort().join(";")}`;
|
|
16
|
+
}
|
|
17
|
+
return `family=${name2}`;
|
|
18
|
+
}).join("&");
|
|
19
|
+
return `${host}/css2?${strings}&display=swap`;
|
|
20
|
+
},
|
|
21
|
+
getFontName(font) {
|
|
22
|
+
return `"${font.name}"`;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const BunnyFontsProvider = createGoogleProvider("bunny", "https://fonts.bunny.net");
|
|
23
28
|
|
|
24
29
|
const NoneProvider = {
|
|
25
30
|
name: "none",
|
|
@@ -45,6 +50,7 @@ function normalizedFontMeta(meta, defaultProvider) {
|
|
|
45
50
|
}
|
|
46
51
|
const providers = {
|
|
47
52
|
google: GoogleFontsProvider,
|
|
53
|
+
bunny: BunnyFontsProvider,
|
|
48
54
|
none: NoneProvider
|
|
49
55
|
};
|
|
50
56
|
const preset = (options = {}) => {
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { toArray } from '@unocss/core';
|
|
2
2
|
|
|
3
|
-
const GoogleFontsProvider =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
3
|
+
const GoogleFontsProvider = createGoogleProvider("google", "https://fonts.googleapis.com");
|
|
4
|
+
function createGoogleProvider(name, host) {
|
|
5
|
+
return {
|
|
6
|
+
name,
|
|
7
|
+
getImportUrl(fonts) {
|
|
8
|
+
const strings = fonts.filter((i) => i.provider === name).map((i) => {
|
|
9
|
+
let name2 = i.name.replace(/\s+/g, "+");
|
|
10
|
+
if (i.weights?.length) {
|
|
11
|
+
name2 += i.italic ? `:ital,wght@${i.weights.flatMap((i2) => [`0,${i2}`, `1,${i2}`]).sort().join(";")}` : `:wght@${i.weights.sort().join(";")}`;
|
|
12
|
+
}
|
|
13
|
+
return `family=${name2}`;
|
|
14
|
+
}).join("&");
|
|
15
|
+
return `${host}/css2?${strings}&display=swap`;
|
|
16
|
+
},
|
|
17
|
+
getFontName(font) {
|
|
18
|
+
return `"${font.name}"`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const BunnyFontsProvider = createGoogleProvider("bunny", "https://fonts.bunny.net");
|
|
19
24
|
|
|
20
25
|
const NoneProvider = {
|
|
21
26
|
name: "none",
|
|
@@ -41,6 +46,7 @@ function normalizedFontMeta(meta, defaultProvider) {
|
|
|
41
46
|
}
|
|
42
47
|
const providers = {
|
|
43
48
|
google: GoogleFontsProvider,
|
|
49
|
+
bunny: BunnyFontsProvider,
|
|
44
50
|
none: NoneProvider
|
|
45
51
|
};
|
|
46
52
|
const preset = (options = {}) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-web-fonts",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.3",
|
|
4
4
|
"description": "Web Fonts support for Uno CSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"*.css"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@unocss/core": "0.45.
|
|
45
|
+
"@unocss/core": "0.45.3",
|
|
46
46
|
"ohmyfetch": "^0.4.18"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|