@webstudio-is/fonts 0.2.0 → 0.15.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/cjs/constants.cjs +37 -16
- package/lib/cjs/font-data.cjs +61 -44
- package/lib/cjs/font-weights.cjs +68 -48
- package/lib/cjs/get-font-faces.cjs +44 -27
- package/lib/cjs/index.cjs +19 -18
- package/lib/cjs/index.server.cjs +22 -18
- package/lib/cjs/schema.cjs +35 -8
- package/lib/constants.js +18 -14
- package/lib/font-data.js +43 -40
- package/lib/font-weights.js +49 -46
- package/lib/get-font-faces.js +25 -24
- package/lib/index.js +1 -1
- package/lib/index.server.js +4 -2
- package/lib/schema.js +14 -4
- package/package.json +7 -16
- package/src/__snapshots__/get-font-faces.test.ts.snap +51 -0
- package/src/constants.ts +21 -0
- package/src/font-data.test.ts +69 -0
- package/src/font-data.ts +74 -0
- package/src/font-weights.ts +52 -0
- package/src/get-font-faces.test.ts +75 -0
- package/src/get-font-faces.ts +53 -0
- package/src/index.server.ts +1 -0
- package/{lib/cjs/index.d.ts → src/index.ts} +1 -2
- package/src/schema.ts +17 -0
- package/lib/cjs/constants.d.ts +0 -6
- package/lib/cjs/constants.d.ts.map +0 -1
- package/lib/cjs/font-data.d.ts +0 -23
- package/lib/cjs/font-data.d.ts.map +0 -1
- package/lib/cjs/font-data.test.cjs +0 -67
- package/lib/cjs/font-data.test.d.ts +0 -2
- package/lib/cjs/font-data.test.d.ts.map +0 -1
- package/lib/cjs/font-weights.d.ts +0 -50
- package/lib/cjs/font-weights.d.ts.map +0 -1
- package/lib/cjs/get-font-faces.d.ts +0 -16
- package/lib/cjs/get-font-faces.d.ts.map +0 -1
- package/lib/cjs/get-font-faces.test.cjs +0 -74
- package/lib/cjs/get-font-faces.test.d.ts +0 -2
- package/lib/cjs/get-font-faces.test.d.ts.map +0 -1
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/index.server.d.ts +0 -3
- package/lib/cjs/index.server.d.ts.map +0 -1
- package/lib/cjs/schema.d.ts +0 -16
- package/lib/cjs/schema.d.ts.map +0 -1
- package/lib/cjs/types.cjs +0 -2
- package/lib/cjs/types.d.ts +0 -2
- package/lib/cjs/types.d.ts.map +0 -1
- package/lib/constants.d.ts +0 -6
- package/lib/constants.d.ts.map +0 -1
- package/lib/font-data.d.ts +0 -23
- package/lib/font-data.d.ts.map +0 -1
- package/lib/font-data.test.d.ts +0 -2
- package/lib/font-data.test.d.ts.map +0 -1
- package/lib/font-data.test.js +0 -65
- package/lib/font-weights.d.ts +0 -50
- package/lib/font-weights.d.ts.map +0 -1
- package/lib/get-font-faces.d.ts +0 -16
- package/lib/get-font-faces.d.ts.map +0 -1
- package/lib/get-font-faces.test.d.ts +0 -2
- package/lib/get-font-faces.test.d.ts.map +0 -1
- package/lib/get-font-faces.test.js +0 -72
- package/lib/index.d.ts +0 -5
- package/lib/index.d.ts.map +0 -1
- package/lib/index.server.d.ts +0 -3
- package/lib/index.server.d.ts.map +0 -1
- package/lib/schema.d.ts +0 -16
- package/lib/schema.d.ts.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types.d.ts +0 -2
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,YAAY,uBAKvB,CAAC;AAEH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAK/C,CAAC;AAEH,eAAO,MAAM,eAAe,QAEf,CAAC"}
|
package/lib/cjs/font-data.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { FontFormat } from "./types";
|
|
2
|
-
declare module "fontkit" {
|
|
3
|
-
interface Font {
|
|
4
|
-
type: string;
|
|
5
|
-
getName: (name: string) => string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export declare const styles: readonly ["normal", "italic", "oblique"];
|
|
9
|
-
declare type Style = typeof styles[number];
|
|
10
|
-
export declare const parseSubfamily: (subfamily: string) => {
|
|
11
|
-
style: "normal" | "italic" | "oblique";
|
|
12
|
-
weight: number;
|
|
13
|
-
};
|
|
14
|
-
export declare const normalizeFamily: (family: string, subfamily: string) => string;
|
|
15
|
-
declare type FontData = {
|
|
16
|
-
format: FontFormat;
|
|
17
|
-
family: string;
|
|
18
|
-
style: Style;
|
|
19
|
-
weight: number;
|
|
20
|
-
};
|
|
21
|
-
export declare const getFontData: (data: Uint8Array) => FontData;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=font-data.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-data.d.ts","sourceRoot":"","sources":["../../src/font-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,IAAI;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;KACnC;CACF;AAED,eAAO,MAAM,MAAM,0CAA2C,CAAC;AAC/D,aAAK,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAEnC,eAAO,MAAM,cAAc,cAAe,MAAM;;;CAmB/C,CAAC;AAUF,eAAO,MAAM,eAAe,WAAY,MAAM,aAAa,MAAM,WAOhE,CAAC;AAEF,aAAK,QAAQ,GAAG;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW,SAAU,UAAU,KAAG,QAa9C,CAAC"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const font_data_1 = require("./font-data");
|
|
4
|
-
describe("font-data", () => {
|
|
5
|
-
describe("parseSubfamily()", () => {
|
|
6
|
-
test("Black Italic", () => {
|
|
7
|
-
expect((0, font_data_1.parseSubfamily)("Black Italic")).toEqual({
|
|
8
|
-
style: "italic",
|
|
9
|
-
weight: 900,
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
test("Bold", () => {
|
|
13
|
-
expect((0, font_data_1.parseSubfamily)("Bold")).toEqual({
|
|
14
|
-
style: "normal",
|
|
15
|
-
weight: 700,
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
test("Demi Bold Italic", () => {
|
|
19
|
-
expect((0, font_data_1.parseSubfamily)("Demi Bold Italic")).toEqual({
|
|
20
|
-
style: "italic",
|
|
21
|
-
weight: 600,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
test("Light", () => {
|
|
25
|
-
expect((0, font_data_1.parseSubfamily)("Light")).toEqual({
|
|
26
|
-
style: "normal",
|
|
27
|
-
weight: 300,
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
test("Extra Light", () => {
|
|
31
|
-
expect((0, font_data_1.parseSubfamily)("Extra Light")).toEqual({
|
|
32
|
-
style: "normal",
|
|
33
|
-
weight: 200,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
test("Extra Light Italic", () => {
|
|
37
|
-
expect((0, font_data_1.parseSubfamily)("Extra Light Italic")).toEqual({
|
|
38
|
-
style: "italic",
|
|
39
|
-
weight: 200,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
test("Heavy Italic", () => {
|
|
43
|
-
expect((0, font_data_1.parseSubfamily)("Heavy Italic")).toEqual({
|
|
44
|
-
style: "italic",
|
|
45
|
-
weight: 900,
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
test("Medium Italic", () => {
|
|
49
|
-
expect((0, font_data_1.parseSubfamily)("Medium Italic")).toEqual({
|
|
50
|
-
style: "italic",
|
|
51
|
-
weight: 500,
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe("normalizeFamily()", () => {
|
|
56
|
-
test("basic", () => {
|
|
57
|
-
expect((0, font_data_1.normalizeFamily)("Roboto Black", "Black")).toBe("Roboto");
|
|
58
|
-
expect((0, font_data_1.normalizeFamily)("Roboto Light", "Light Italic")).toBe("Roboto");
|
|
59
|
-
expect((0, font_data_1.normalizeFamily)("Robolder Bold", "Bold")).toBe("Robolder");
|
|
60
|
-
expect((0, font_data_1.normalizeFamily)(" Roboto X Bold ", "Bold")).toBe("Roboto X");
|
|
61
|
-
expect((0, font_data_1.normalizeFamily)(" 'Roboto X' Bold ", "Bold")).toBe("'Roboto X'");
|
|
62
|
-
expect((0, font_data_1.normalizeFamily)(` "Roboto X" Bold `, "Bold")).toBe(`"Roboto X"`);
|
|
63
|
-
expect((0, font_data_1.normalizeFamily)(`"Roboto Bold"`, "Bold")).toBe(`"Roboto Bold"`);
|
|
64
|
-
expect((0, font_data_1.normalizeFamily)(`"Roboto Bold" Bold`, "Bold")).toBe(`"Roboto Bold"`);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-data.test.d.ts","sourceRoot":"","sources":["../../src/font-data.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,50 +0,0 @@
|
|
|
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 declare type FontWeight = keyof typeof fontWeights;
|
|
49
|
-
export declare type FontWeightKeyword = typeof fontWeights[FontWeight]["name"] | typeof fontWeights[FontWeight]["alt"];
|
|
50
|
-
//# sourceMappingURL=font-weights.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-weights.d.ts","sourceRoot":"","sources":["../../src/font-weights.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Cd,CAAC;AAEX,oBAAY,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAClD,oBAAY,iBAAiB,GACzB,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,GACtC,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FontMeta } from "./schema";
|
|
2
|
-
import type { FontFormat } from "./types";
|
|
3
|
-
export declare type PartialFontAsset = {
|
|
4
|
-
format: FontFormat;
|
|
5
|
-
meta: FontMeta;
|
|
6
|
-
path: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type FontFace = {
|
|
9
|
-
fontFamily: string;
|
|
10
|
-
fontStyle: FontMeta["style"];
|
|
11
|
-
fontWeight: number;
|
|
12
|
-
fontDisplay: "swap" | "auto" | "block" | "fallback" | "optional";
|
|
13
|
-
src: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const getFontFaces: (assets: Array<PartialFontAsset>) => Array<FontFace>;
|
|
16
|
-
//# sourceMappingURL=get-font-faces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-font-faces.d.ts","sourceRoot":"","sources":["../../src/get-font-faces.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;IACjE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAeF,eAAO,MAAM,YAAY,WACf,MAAM,gBAAgB,CAAC,KAC9B,MAAM,QAAQ,CAoBhB,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const get_font_faces_1 = require("./get-font-faces");
|
|
4
|
-
describe("getFontFaces()", () => {
|
|
5
|
-
test("different formats", () => {
|
|
6
|
-
const assets = [
|
|
7
|
-
{
|
|
8
|
-
format: "woff",
|
|
9
|
-
meta: {
|
|
10
|
-
family: "Roboto",
|
|
11
|
-
style: "normal",
|
|
12
|
-
weight: 400,
|
|
13
|
-
},
|
|
14
|
-
path: "/fonts/roboto.woff",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
format: "ttf",
|
|
18
|
-
meta: {
|
|
19
|
-
family: "Roboto",
|
|
20
|
-
style: "normal",
|
|
21
|
-
weight: 400,
|
|
22
|
-
},
|
|
23
|
-
path: "/fonts/roboto.ttf",
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
expect((0, get_font_faces_1.getFontFaces)(assets)).toMatchSnapshot();
|
|
27
|
-
});
|
|
28
|
-
test("different style", () => {
|
|
29
|
-
const assets = [
|
|
30
|
-
{
|
|
31
|
-
format: "ttf",
|
|
32
|
-
meta: {
|
|
33
|
-
family: "Roboto",
|
|
34
|
-
style: "normal",
|
|
35
|
-
weight: 400,
|
|
36
|
-
},
|
|
37
|
-
path: "/fonts/roboto.ttf",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
format: "ttf",
|
|
41
|
-
meta: {
|
|
42
|
-
family: "Roboto",
|
|
43
|
-
style: "italic",
|
|
44
|
-
weight: 400,
|
|
45
|
-
},
|
|
46
|
-
path: "/fonts/roboto-italic.ttf",
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
expect((0, get_font_faces_1.getFontFaces)(assets)).toMatchSnapshot();
|
|
50
|
-
});
|
|
51
|
-
test("different weight", () => {
|
|
52
|
-
const assets = [
|
|
53
|
-
{
|
|
54
|
-
format: "ttf",
|
|
55
|
-
meta: {
|
|
56
|
-
family: "Roboto",
|
|
57
|
-
style: "normal",
|
|
58
|
-
weight: 400,
|
|
59
|
-
},
|
|
60
|
-
path: "/fonts/roboto.ttf",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
format: "ttf",
|
|
64
|
-
meta: {
|
|
65
|
-
family: "Roboto",
|
|
66
|
-
style: "normal",
|
|
67
|
-
weight: 500,
|
|
68
|
-
},
|
|
69
|
-
path: "/fonts/roboto-bold.ttf",
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
expect((0, get_font_faces_1.getFontFaces)(assets)).toMatchSnapshot();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-font-faces.test.d.ts","sourceRoot":"","sources":["../../src/get-font-faces.test.ts"],"names":[],"mappings":""}
|
package/lib/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../../src/index.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,cAAc,UAAU,CAAC"}
|
package/lib/cjs/schema.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const FontMeta: z.ZodObject<{
|
|
3
|
-
family: z.ZodString;
|
|
4
|
-
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
5
|
-
weight: z.ZodNumber;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
family: string;
|
|
8
|
-
style: "normal" | "italic" | "oblique";
|
|
9
|
-
weight: number;
|
|
10
|
-
}, {
|
|
11
|
-
family: string;
|
|
12
|
-
style: "normal" | "italic" | "oblique";
|
|
13
|
-
weight: number;
|
|
14
|
-
}>;
|
|
15
|
-
export declare type FontMeta = z.infer<typeof FontMeta>;
|
|
16
|
-
//# sourceMappingURL=schema.d.ts.map
|
package/lib/cjs/schema.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;EAInB,CAAC;AACH,oBAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|
package/lib/cjs/types.cjs
DELETED
package/lib/cjs/types.d.ts
DELETED
package/lib/cjs/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC"}
|
package/lib/constants.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { FontFormat } from "./types";
|
|
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;
|
|
6
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/lib/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,YAAY,uBAKvB,CAAC;AAEH,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,eAAO,MAAM,YAAY,EAAE,GAAG,CAAC,UAAU,EAAE,MAAM,CAK/C,CAAC;AAEH,eAAO,MAAM,eAAe,QAEf,CAAC"}
|
package/lib/font-data.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { FontFormat } from "./types";
|
|
2
|
-
declare module "fontkit" {
|
|
3
|
-
interface Font {
|
|
4
|
-
type: string;
|
|
5
|
-
getName: (name: string) => string;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export declare const styles: readonly ["normal", "italic", "oblique"];
|
|
9
|
-
declare type Style = typeof styles[number];
|
|
10
|
-
export declare const parseSubfamily: (subfamily: string) => {
|
|
11
|
-
style: "normal" | "italic" | "oblique";
|
|
12
|
-
weight: number;
|
|
13
|
-
};
|
|
14
|
-
export declare const normalizeFamily: (family: string, subfamily: string) => string;
|
|
15
|
-
declare type FontData = {
|
|
16
|
-
format: FontFormat;
|
|
17
|
-
family: string;
|
|
18
|
-
style: Style;
|
|
19
|
-
weight: number;
|
|
20
|
-
};
|
|
21
|
-
export declare const getFontData: (data: Uint8Array) => FontData;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=font-data.d.ts.map
|
package/lib/font-data.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-data.d.ts","sourceRoot":"","sources":["../src/font-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAiB,IAAI;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;KACnC;CACF;AAED,eAAO,MAAM,MAAM,0CAA2C,CAAC;AAC/D,aAAK,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAEnC,eAAO,MAAM,cAAc,cAAe,MAAM;;;CAmB/C,CAAC;AAUF,eAAO,MAAM,eAAe,WAAY,MAAM,aAAa,MAAM,WAOhE,CAAC;AAEF,aAAK,QAAQ,GAAG;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,WAAW,SAAU,UAAU,KAAG,QAa9C,CAAC"}
|
package/lib/font-data.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-data.test.d.ts","sourceRoot":"","sources":["../src/font-data.test.ts"],"names":[],"mappings":""}
|
package/lib/font-data.test.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { parseSubfamily, normalizeFamily } from "./font-data";
|
|
2
|
-
describe("font-data", () => {
|
|
3
|
-
describe("parseSubfamily()", () => {
|
|
4
|
-
test("Black Italic", () => {
|
|
5
|
-
expect(parseSubfamily("Black Italic")).toEqual({
|
|
6
|
-
style: "italic",
|
|
7
|
-
weight: 900,
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
test("Bold", () => {
|
|
11
|
-
expect(parseSubfamily("Bold")).toEqual({
|
|
12
|
-
style: "normal",
|
|
13
|
-
weight: 700,
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
test("Demi Bold Italic", () => {
|
|
17
|
-
expect(parseSubfamily("Demi Bold Italic")).toEqual({
|
|
18
|
-
style: "italic",
|
|
19
|
-
weight: 600,
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
test("Light", () => {
|
|
23
|
-
expect(parseSubfamily("Light")).toEqual({
|
|
24
|
-
style: "normal",
|
|
25
|
-
weight: 300,
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
test("Extra Light", () => {
|
|
29
|
-
expect(parseSubfamily("Extra Light")).toEqual({
|
|
30
|
-
style: "normal",
|
|
31
|
-
weight: 200,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
test("Extra Light Italic", () => {
|
|
35
|
-
expect(parseSubfamily("Extra Light Italic")).toEqual({
|
|
36
|
-
style: "italic",
|
|
37
|
-
weight: 200,
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
test("Heavy Italic", () => {
|
|
41
|
-
expect(parseSubfamily("Heavy Italic")).toEqual({
|
|
42
|
-
style: "italic",
|
|
43
|
-
weight: 900,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
test("Medium Italic", () => {
|
|
47
|
-
expect(parseSubfamily("Medium Italic")).toEqual({
|
|
48
|
-
style: "italic",
|
|
49
|
-
weight: 500,
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
describe("normalizeFamily()", () => {
|
|
54
|
-
test("basic", () => {
|
|
55
|
-
expect(normalizeFamily("Roboto Black", "Black")).toBe("Roboto");
|
|
56
|
-
expect(normalizeFamily("Roboto Light", "Light Italic")).toBe("Roboto");
|
|
57
|
-
expect(normalizeFamily("Robolder Bold", "Bold")).toBe("Robolder");
|
|
58
|
-
expect(normalizeFamily(" Roboto X Bold ", "Bold")).toBe("Roboto X");
|
|
59
|
-
expect(normalizeFamily(" 'Roboto X' Bold ", "Bold")).toBe("'Roboto X'");
|
|
60
|
-
expect(normalizeFamily(` "Roboto X" Bold `, "Bold")).toBe(`"Roboto X"`);
|
|
61
|
-
expect(normalizeFamily(`"Roboto Bold"`, "Bold")).toBe(`"Roboto Bold"`);
|
|
62
|
-
expect(normalizeFamily(`"Roboto Bold" Bold`, "Bold")).toBe(`"Roboto Bold"`);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
package/lib/font-weights.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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 declare type FontWeight = keyof typeof fontWeights;
|
|
49
|
-
export declare type FontWeightKeyword = typeof fontWeights[FontWeight]["name"] | typeof fontWeights[FontWeight]["alt"];
|
|
50
|
-
//# sourceMappingURL=font-weights.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font-weights.d.ts","sourceRoot":"","sources":["../src/font-weights.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Cd,CAAC;AAEX,oBAAY,UAAU,GAAG,MAAM,OAAO,WAAW,CAAC;AAClD,oBAAY,iBAAiB,GACzB,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,GACtC,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC"}
|
package/lib/get-font-faces.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { FontMeta } from "./schema";
|
|
2
|
-
import type { FontFormat } from "./types";
|
|
3
|
-
export declare type PartialFontAsset = {
|
|
4
|
-
format: FontFormat;
|
|
5
|
-
meta: FontMeta;
|
|
6
|
-
path: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type FontFace = {
|
|
9
|
-
fontFamily: string;
|
|
10
|
-
fontStyle: FontMeta["style"];
|
|
11
|
-
fontWeight: number;
|
|
12
|
-
fontDisplay: "swap" | "auto" | "block" | "fallback" | "optional";
|
|
13
|
-
src: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const getFontFaces: (assets: Array<PartialFontAsset>) => Array<FontFace>;
|
|
16
|
-
//# sourceMappingURL=get-font-faces.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-font-faces.d.ts","sourceRoot":"","sources":["../src/get-font-faces.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;IACjE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAeF,eAAO,MAAM,YAAY,WACf,MAAM,gBAAgB,CAAC,KAC9B,MAAM,QAAQ,CAoBhB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-font-faces.test.d.ts","sourceRoot":"","sources":["../src/get-font-faces.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { getFontFaces } from "./get-font-faces";
|
|
2
|
-
describe("getFontFaces()", () => {
|
|
3
|
-
test("different formats", () => {
|
|
4
|
-
const assets = [
|
|
5
|
-
{
|
|
6
|
-
format: "woff",
|
|
7
|
-
meta: {
|
|
8
|
-
family: "Roboto",
|
|
9
|
-
style: "normal",
|
|
10
|
-
weight: 400,
|
|
11
|
-
},
|
|
12
|
-
path: "/fonts/roboto.woff",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
format: "ttf",
|
|
16
|
-
meta: {
|
|
17
|
-
family: "Roboto",
|
|
18
|
-
style: "normal",
|
|
19
|
-
weight: 400,
|
|
20
|
-
},
|
|
21
|
-
path: "/fonts/roboto.ttf",
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
expect(getFontFaces(assets)).toMatchSnapshot();
|
|
25
|
-
});
|
|
26
|
-
test("different style", () => {
|
|
27
|
-
const assets = [
|
|
28
|
-
{
|
|
29
|
-
format: "ttf",
|
|
30
|
-
meta: {
|
|
31
|
-
family: "Roboto",
|
|
32
|
-
style: "normal",
|
|
33
|
-
weight: 400,
|
|
34
|
-
},
|
|
35
|
-
path: "/fonts/roboto.ttf",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
format: "ttf",
|
|
39
|
-
meta: {
|
|
40
|
-
family: "Roboto",
|
|
41
|
-
style: "italic",
|
|
42
|
-
weight: 400,
|
|
43
|
-
},
|
|
44
|
-
path: "/fonts/roboto-italic.ttf",
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
expect(getFontFaces(assets)).toMatchSnapshot();
|
|
48
|
-
});
|
|
49
|
-
test("different weight", () => {
|
|
50
|
-
const assets = [
|
|
51
|
-
{
|
|
52
|
-
format: "ttf",
|
|
53
|
-
meta: {
|
|
54
|
-
family: "Roboto",
|
|
55
|
-
style: "normal",
|
|
56
|
-
weight: 400,
|
|
57
|
-
},
|
|
58
|
-
path: "/fonts/roboto.ttf",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
format: "ttf",
|
|
62
|
-
meta: {
|
|
63
|
-
family: "Roboto",
|
|
64
|
-
style: "normal",
|
|
65
|
-
weight: 500,
|
|
66
|
-
},
|
|
67
|
-
path: "/fonts/roboto-bold.ttf",
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
expect(getFontFaces(assets)).toMatchSnapshot();
|
|
71
|
-
});
|
|
72
|
-
});
|
package/lib/index.d.ts
DELETED
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
|
package/lib/index.server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,cAAc,UAAU,CAAC"}
|
package/lib/schema.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const FontMeta: z.ZodObject<{
|
|
3
|
-
family: z.ZodString;
|
|
4
|
-
style: z.ZodEnum<["normal", "italic", "oblique"]>;
|
|
5
|
-
weight: z.ZodNumber;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
family: string;
|
|
8
|
-
style: "normal" | "italic" | "oblique";
|
|
9
|
-
weight: number;
|
|
10
|
-
}, {
|
|
11
|
-
family: string;
|
|
12
|
-
style: "normal" | "italic" | "oblique";
|
|
13
|
-
weight: number;
|
|
14
|
-
}>;
|
|
15
|
-
export declare type FontMeta = z.infer<typeof FontMeta>;
|
|
16
|
-
//# sourceMappingURL=schema.d.ts.map
|
package/lib/schema.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,QAAQ;;;;;;;;;;;;EAInB,CAAC;AACH,oBAAY,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC"}
|