@webstudio-is/fonts 0.57.0 → 0.58.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/types/constants.d.ts +5 -0
- package/lib/types/font-data.d.ts +29 -0
- package/lib/types/font-data.test.d.ts +1 -0
- package/lib/types/font-weights.d.ts +49 -0
- package/lib/types/get-font-faces.d.ts +17 -0
- package/lib/types/get-font-faces.test.d.ts +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.server.d.ts +1 -0
- package/lib/types/schema.d.ts +83 -0
- package/package.json +5 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FontFormat } from "./schema";
|
|
2
|
+
export declare const SYSTEM_FONTS: Map<string, string[]>;
|
|
3
|
+
export declare const DEFAULT_FONT_FALLBACK = "sans-serif";
|
|
4
|
+
export declare const FONT_FORMATS: Map<FontFormat, string>;
|
|
5
|
+
export declare const FONT_MIME_TYPES: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FontFormat, VariationAxes } from "./schema";
|
|
2
|
+
declare module "fontkit" {
|
|
3
|
+
interface Font {
|
|
4
|
+
type: string;
|
|
5
|
+
getName: (name: string) => string;
|
|
6
|
+
variationAxes: VariationAxes;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const styles: readonly ["normal", "italic", "oblique"];
|
|
10
|
+
type Style = (typeof styles)[number];
|
|
11
|
+
export declare const parseSubfamily: (subfamily: string) => {
|
|
12
|
+
style: "normal" | "italic" | "oblique";
|
|
13
|
+
weight: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const normalizeFamily: (family: string, subfamily: string) => string;
|
|
16
|
+
type FontDataStatic = {
|
|
17
|
+
format: FontFormat;
|
|
18
|
+
family: string;
|
|
19
|
+
style: Style;
|
|
20
|
+
weight: number;
|
|
21
|
+
};
|
|
22
|
+
type FontDataVariable = {
|
|
23
|
+
format: FontFormat;
|
|
24
|
+
family: string;
|
|
25
|
+
variationAxes: VariationAxes;
|
|
26
|
+
};
|
|
27
|
+
type FontData = FontDataStatic | FontDataVariable;
|
|
28
|
+
export declare const getFontData: (data: Uint8Array) => FontData;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const fontWeights: {
|
|
2
|
+
readonly "100": {
|
|
3
|
+
readonly label: "Thin";
|
|
4
|
+
readonly name: "thin";
|
|
5
|
+
readonly alt: "hairline";
|
|
6
|
+
};
|
|
7
|
+
readonly "200": {
|
|
8
|
+
readonly label: "Extra Light";
|
|
9
|
+
readonly name: "extra light";
|
|
10
|
+
readonly alt: "ultra light";
|
|
11
|
+
};
|
|
12
|
+
readonly "300": {
|
|
13
|
+
readonly label: "Light";
|
|
14
|
+
readonly name: "light";
|
|
15
|
+
readonly alt: "light";
|
|
16
|
+
};
|
|
17
|
+
readonly "400": {
|
|
18
|
+
readonly label: "Normal";
|
|
19
|
+
readonly name: "normal";
|
|
20
|
+
readonly alt: "normal";
|
|
21
|
+
};
|
|
22
|
+
readonly "500": {
|
|
23
|
+
readonly label: "Medium";
|
|
24
|
+
readonly name: "medium";
|
|
25
|
+
readonly alt: "medium";
|
|
26
|
+
};
|
|
27
|
+
readonly "600": {
|
|
28
|
+
readonly label: "Semi Bold";
|
|
29
|
+
readonly name: "semi bold";
|
|
30
|
+
readonly alt: "demi bold";
|
|
31
|
+
};
|
|
32
|
+
readonly "700": {
|
|
33
|
+
readonly label: "Bold";
|
|
34
|
+
readonly name: "bold";
|
|
35
|
+
readonly alt: "bold";
|
|
36
|
+
};
|
|
37
|
+
readonly "800": {
|
|
38
|
+
readonly label: "Extra Bold";
|
|
39
|
+
readonly name: "extra bold";
|
|
40
|
+
readonly alt: "ultra bold";
|
|
41
|
+
};
|
|
42
|
+
readonly "900": {
|
|
43
|
+
readonly label: "Black";
|
|
44
|
+
readonly name: "black";
|
|
45
|
+
readonly alt: "heavy";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type FontWeight = keyof typeof fontWeights;
|
|
49
|
+
export type FontWeightKeyword = (typeof fontWeights)[FontWeight]["name"] | (typeof fontWeights)[FontWeight]["alt"];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FontMeta, FontFormat, FontMetaStatic } from "./schema";
|
|
2
|
+
export type PartialFontAsset = {
|
|
3
|
+
format: FontFormat;
|
|
4
|
+
meta: FontMeta;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
export type FontFace = {
|
|
8
|
+
fontFamily: string;
|
|
9
|
+
fontDisplay: "swap" | "auto" | "block" | "fallback" | "optional";
|
|
10
|
+
src: string;
|
|
11
|
+
fontStyle?: FontMetaStatic["style"];
|
|
12
|
+
fontWeight?: number | string;
|
|
13
|
+
fontStretch?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const getFontFaces: (assets: Array<PartialFontAsset>, options: {
|
|
16
|
+
assetBaseUrl: string;
|
|
17
|
+
}) => Array<FontFace>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getFontData } from "./font-data";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const FontFormat: z.ZodUnion<[z.ZodLiteral<"ttf">, z.ZodLiteral<"woff">, z.ZodLiteral<"woff2">, z.ZodLiteral<"otf">]>;
|
|
3
|
+
export type FontFormat = z.infer<typeof FontFormat>;
|
|
4
|
+
declare const VariationAxes: z.ZodRecord<z.ZodEnum<["wght", "wdth", "slnt", "opsz", "ital", "GRAD", "XTRA", "XOPQ", "YOPQ", "YTLC", "YTUC", "YTAS", "YTDE", "YTFI"]>, z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
min: z.ZodNumber;
|
|
7
|
+
default: z.ZodNumber;
|
|
8
|
+
max: z.ZodNumber;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
min: number;
|
|
12
|
+
default: number;
|
|
13
|
+
max: number;
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
min: number;
|
|
17
|
+
default: number;
|
|
18
|
+
max: number;
|
|
19
|
+
}>>;
|
|
20
|
+
export type VariationAxes = z.infer<typeof VariationAxes>;
|
|
21
|
+
export declare const FontMetaStatic: z.ZodObject<{
|
|
22
|
+
family: z.ZodString;
|
|
23
|
+
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
24
|
+
weight: z.ZodNumber;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
style: "normal" | "italic" | "oblique";
|
|
27
|
+
weight: number;
|
|
28
|
+
family: string;
|
|
29
|
+
}, {
|
|
30
|
+
style: "normal" | "italic" | "oblique";
|
|
31
|
+
weight: number;
|
|
32
|
+
family: string;
|
|
33
|
+
}>;
|
|
34
|
+
export type FontMetaStatic = z.infer<typeof FontMetaStatic>;
|
|
35
|
+
export declare const FontMeta: z.ZodUnion<[z.ZodObject<{
|
|
36
|
+
family: z.ZodString;
|
|
37
|
+
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
38
|
+
weight: z.ZodNumber;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
style: "normal" | "italic" | "oblique";
|
|
41
|
+
weight: number;
|
|
42
|
+
family: string;
|
|
43
|
+
}, {
|
|
44
|
+
style: "normal" | "italic" | "oblique";
|
|
45
|
+
weight: number;
|
|
46
|
+
family: string;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
family: z.ZodString;
|
|
49
|
+
variationAxes: z.ZodRecord<z.ZodEnum<["wght", "wdth", "slnt", "opsz", "ital", "GRAD", "XTRA", "XOPQ", "YOPQ", "YTLC", "YTUC", "YTAS", "YTDE", "YTFI"]>, z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
min: z.ZodNumber;
|
|
52
|
+
default: z.ZodNumber;
|
|
53
|
+
max: z.ZodNumber;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
name: string;
|
|
56
|
+
min: number;
|
|
57
|
+
default: number;
|
|
58
|
+
max: number;
|
|
59
|
+
}, {
|
|
60
|
+
name: string;
|
|
61
|
+
min: number;
|
|
62
|
+
default: number;
|
|
63
|
+
max: number;
|
|
64
|
+
}>>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
variationAxes: Partial<Record<"wght" | "wdth" | "slnt" | "opsz" | "ital" | "GRAD" | "XTRA" | "XOPQ" | "YOPQ" | "YTLC" | "YTUC" | "YTAS" | "YTDE" | "YTFI", {
|
|
67
|
+
name: string;
|
|
68
|
+
min: number;
|
|
69
|
+
default: number;
|
|
70
|
+
max: number;
|
|
71
|
+
}>>;
|
|
72
|
+
family: string;
|
|
73
|
+
}, {
|
|
74
|
+
variationAxes: Partial<Record<"wght" | "wdth" | "slnt" | "opsz" | "ital" | "GRAD" | "XTRA" | "XOPQ" | "YOPQ" | "YTLC" | "YTUC" | "YTAS" | "YTDE" | "YTFI", {
|
|
75
|
+
name: string;
|
|
76
|
+
min: number;
|
|
77
|
+
default: number;
|
|
78
|
+
max: number;
|
|
79
|
+
}>>;
|
|
80
|
+
family: string;
|
|
81
|
+
}>]>;
|
|
82
|
+
export type FontMeta = z.infer<typeof FontMeta>;
|
|
83
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/fonts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "Fonts utils",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"jest": "^29.3.1",
|
|
15
15
|
"typescript": "5.0.3",
|
|
16
16
|
"zod": "^3.19.1",
|
|
17
|
-
"@webstudio-is/design-system": "^0.
|
|
18
|
-
"@webstudio-is/jest-config": "^1.0.
|
|
17
|
+
"@webstudio-is/design-system": "^0.58.0",
|
|
18
|
+
"@webstudio-is/jest-config": "^1.0.5",
|
|
19
19
|
"@webstudio-is/scripts": "^0.0.0",
|
|
20
|
-
"@webstudio-is/tsconfig": "^1.0.
|
|
20
|
+
"@webstudio-is/tsconfig": "^1.0.5"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"zod": "^3.19.1"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"checks": "pnpm typecheck && pnpm lint && pnpm test",
|
|
50
50
|
"dev": "build-package --watch",
|
|
51
51
|
"build": "build-package",
|
|
52
|
-
"dts": "tsc",
|
|
52
|
+
"dts": "tsc --declarationDir lib/types",
|
|
53
53
|
"lint": "eslint ./src --ext .ts,.tsx --max-warnings 0"
|
|
54
54
|
}
|
|
55
55
|
}
|