@remotion/google-fonts 4.0.355 → 4.0.357
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/cjs/BBHSansBartle.d.ts +36 -0
- package/dist/cjs/BBHSansBartle.js +27 -0
- package/dist/cjs/BBHSansBogle.d.ts +36 -0
- package/dist/cjs/BBHSansBogle.js +27 -0
- package/dist/cjs/BBHSansHegarty.d.ts +36 -0
- package/dist/cjs/BBHSansHegarty.js +27 -0
- package/dist/cjs/index.js +15 -0
- package/dist/esm/BBHSansBartle.mjs +135 -0
- package/dist/esm/BBHSansBogle.mjs +135 -0
- package/dist/esm/BBHSansHegarty.mjs +135 -0
- package/dist/esm/index.mjs +15 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const getInfo: () => {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
importName: string;
|
|
4
|
+
version: string;
|
|
5
|
+
url: string;
|
|
6
|
+
unicodeRanges: {
|
|
7
|
+
latin: string;
|
|
8
|
+
};
|
|
9
|
+
fonts: {
|
|
10
|
+
normal: {
|
|
11
|
+
'400': {
|
|
12
|
+
latin: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
subsets: string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const fontFamily: "BBH Sans Bartle";
|
|
19
|
+
type Variants = {
|
|
20
|
+
normal: {
|
|
21
|
+
weights: '400';
|
|
22
|
+
subsets: 'latin';
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const loadFont: <T extends keyof Variants>(style?: T, options?: {
|
|
26
|
+
weights?: Variants[T]["weights"][];
|
|
27
|
+
subsets?: Variants[T]["subsets"][];
|
|
28
|
+
document?: Document;
|
|
29
|
+
ignoreTooManyRequestsWarning?: boolean;
|
|
30
|
+
}) => {
|
|
31
|
+
fontFamily: import("./base").FontInfo["fontFamily"];
|
|
32
|
+
fonts: import("./base").FontInfo["fonts"];
|
|
33
|
+
unicodeRanges: import("./base").FontInfo["unicodeRanges"];
|
|
34
|
+
waitUntilDone: () => Promise<undefined>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFont = exports.fontFamily = exports.getInfo = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const getInfo = () => ({
|
|
6
|
+
fontFamily: 'BBH Sans Bartle',
|
|
7
|
+
importName: 'BBHSansBartle',
|
|
8
|
+
version: 'v1',
|
|
9
|
+
url: 'https://fonts.googleapis.com/css2?family=BBH+Sans+Bartle:ital,wght@0,400',
|
|
10
|
+
unicodeRanges: {
|
|
11
|
+
latin: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
12
|
+
},
|
|
13
|
+
fonts: {
|
|
14
|
+
normal: {
|
|
15
|
+
'400': {
|
|
16
|
+
latin: 'https://fonts.gstatic.com/s/bbhsansbartle/v1/eLGEP-v-CSnwOk_evJ1qrrCJCQT58uwg.woff2',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
subsets: ['latin'],
|
|
21
|
+
});
|
|
22
|
+
exports.getInfo = getInfo;
|
|
23
|
+
exports.fontFamily = 'BBH Sans Bartle';
|
|
24
|
+
const loadFont = (style, options) => {
|
|
25
|
+
return (0, base_1.loadFonts)((0, exports.getInfo)(), style, options);
|
|
26
|
+
};
|
|
27
|
+
exports.loadFont = loadFont;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const getInfo: () => {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
importName: string;
|
|
4
|
+
version: string;
|
|
5
|
+
url: string;
|
|
6
|
+
unicodeRanges: {
|
|
7
|
+
latin: string;
|
|
8
|
+
};
|
|
9
|
+
fonts: {
|
|
10
|
+
normal: {
|
|
11
|
+
'400': {
|
|
12
|
+
latin: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
subsets: string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const fontFamily: "BBH Sans Bogle";
|
|
19
|
+
type Variants = {
|
|
20
|
+
normal: {
|
|
21
|
+
weights: '400';
|
|
22
|
+
subsets: 'latin';
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const loadFont: <T extends keyof Variants>(style?: T, options?: {
|
|
26
|
+
weights?: Variants[T]["weights"][];
|
|
27
|
+
subsets?: Variants[T]["subsets"][];
|
|
28
|
+
document?: Document;
|
|
29
|
+
ignoreTooManyRequestsWarning?: boolean;
|
|
30
|
+
}) => {
|
|
31
|
+
fontFamily: import("./base").FontInfo["fontFamily"];
|
|
32
|
+
fonts: import("./base").FontInfo["fonts"];
|
|
33
|
+
unicodeRanges: import("./base").FontInfo["unicodeRanges"];
|
|
34
|
+
waitUntilDone: () => Promise<undefined>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFont = exports.fontFamily = exports.getInfo = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const getInfo = () => ({
|
|
6
|
+
fontFamily: 'BBH Sans Bogle',
|
|
7
|
+
importName: 'BBHSansBogle',
|
|
8
|
+
version: 'v1',
|
|
9
|
+
url: 'https://fonts.googleapis.com/css2?family=BBH+Sans+Bogle:ital,wght@0,400',
|
|
10
|
+
unicodeRanges: {
|
|
11
|
+
latin: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
12
|
+
},
|
|
13
|
+
fonts: {
|
|
14
|
+
normal: {
|
|
15
|
+
'400': {
|
|
16
|
+
latin: 'https://fonts.gstatic.com/s/bbhsansbogle/v1/LYjbdGTyv25vPsUz0wMCwj1DMc_YeJE.woff2',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
subsets: ['latin'],
|
|
21
|
+
});
|
|
22
|
+
exports.getInfo = getInfo;
|
|
23
|
+
exports.fontFamily = 'BBH Sans Bogle';
|
|
24
|
+
const loadFont = (style, options) => {
|
|
25
|
+
return (0, base_1.loadFonts)((0, exports.getInfo)(), style, options);
|
|
26
|
+
};
|
|
27
|
+
exports.loadFont = loadFont;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const getInfo: () => {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
importName: string;
|
|
4
|
+
version: string;
|
|
5
|
+
url: string;
|
|
6
|
+
unicodeRanges: {
|
|
7
|
+
latin: string;
|
|
8
|
+
};
|
|
9
|
+
fonts: {
|
|
10
|
+
normal: {
|
|
11
|
+
'400': {
|
|
12
|
+
latin: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
subsets: string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const fontFamily: "BBH Sans Hegarty";
|
|
19
|
+
type Variants = {
|
|
20
|
+
normal: {
|
|
21
|
+
weights: '400';
|
|
22
|
+
subsets: 'latin';
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const loadFont: <T extends keyof Variants>(style?: T, options?: {
|
|
26
|
+
weights?: Variants[T]["weights"][];
|
|
27
|
+
subsets?: Variants[T]["subsets"][];
|
|
28
|
+
document?: Document;
|
|
29
|
+
ignoreTooManyRequestsWarning?: boolean;
|
|
30
|
+
}) => {
|
|
31
|
+
fontFamily: import("./base").FontInfo["fontFamily"];
|
|
32
|
+
fonts: import("./base").FontInfo["fonts"];
|
|
33
|
+
unicodeRanges: import("./base").FontInfo["unicodeRanges"];
|
|
34
|
+
waitUntilDone: () => Promise<undefined>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFont = exports.fontFamily = exports.getInfo = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
const getInfo = () => ({
|
|
6
|
+
fontFamily: 'BBH Sans Hegarty',
|
|
7
|
+
importName: 'BBHSansHegarty',
|
|
8
|
+
version: 'v1',
|
|
9
|
+
url: 'https://fonts.googleapis.com/css2?family=BBH+Sans+Hegarty:ital,wght@0,400',
|
|
10
|
+
unicodeRanges: {
|
|
11
|
+
latin: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
|
|
12
|
+
},
|
|
13
|
+
fonts: {
|
|
14
|
+
normal: {
|
|
15
|
+
'400': {
|
|
16
|
+
latin: 'https://fonts.gstatic.com/s/bbhsanshegarty/v1/UqyLK9cfCFIq--EuUZn21v4dILtJfKcDdw.woff2',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
subsets: ['latin'],
|
|
21
|
+
});
|
|
22
|
+
exports.getInfo = getInfo;
|
|
23
|
+
exports.fontFamily = 'BBH Sans Hegarty';
|
|
24
|
+
const loadFont = (style, options) => {
|
|
25
|
+
return (0, base_1.loadFonts)((0, exports.getInfo)(), style, options);
|
|
26
|
+
};
|
|
27
|
+
exports.loadFont = loadFont;
|
package/dist/cjs/index.js
CHANGED
|
@@ -742,6 +742,21 @@ const getAvailableFonts = () => [
|
|
|
742
742
|
importName: 'B612Mono',
|
|
743
743
|
load: () => Promise.resolve().then(() => __importStar(require('./B612Mono'))),
|
|
744
744
|
},
|
|
745
|
+
{
|
|
746
|
+
fontFamily: 'BBH Sans Bartle',
|
|
747
|
+
importName: 'BBHSansBartle',
|
|
748
|
+
load: () => Promise.resolve().then(() => __importStar(require('./BBHSansBartle'))),
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
fontFamily: 'BBH Sans Bogle',
|
|
752
|
+
importName: 'BBHSansBogle',
|
|
753
|
+
load: () => Promise.resolve().then(() => __importStar(require('./BBHSansBogle'))),
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
fontFamily: 'BBH Sans Hegarty',
|
|
757
|
+
importName: 'BBHSansHegarty',
|
|
758
|
+
load: () => Promise.resolve().then(() => __importStar(require('./BBHSansHegarty'))),
|
|
759
|
+
},
|
|
745
760
|
{
|
|
746
761
|
fontFamily: 'BIZ UDGothic',
|
|
747
762
|
importName: 'BIZUDGothic',
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/base.ts
|
|
2
|
+
import { continueRender, delayRender } from "remotion";
|
|
3
|
+
import { NoReactInternals } from "remotion/no-react";
|
|
4
|
+
var loadedFonts = {};
|
|
5
|
+
var withResolvers = function() {
|
|
6
|
+
let resolve;
|
|
7
|
+
let reject;
|
|
8
|
+
const promise = new Promise((res, rej) => {
|
|
9
|
+
resolve = res;
|
|
10
|
+
reject = rej;
|
|
11
|
+
});
|
|
12
|
+
return { promise, resolve, reject };
|
|
13
|
+
};
|
|
14
|
+
var loadFontFaceOrTimeoutAfter20Seconds = (fontFace) => {
|
|
15
|
+
const timeout = withResolvers();
|
|
16
|
+
const int = setTimeout(() => {
|
|
17
|
+
timeout.reject(new Error("Timed out loading Google Font"));
|
|
18
|
+
}, 18000);
|
|
19
|
+
return Promise.race([
|
|
20
|
+
fontFace.load().then(() => {
|
|
21
|
+
clearTimeout(int);
|
|
22
|
+
}),
|
|
23
|
+
timeout.promise
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
var loadFonts = (meta, style, options) => {
|
|
27
|
+
const weightsAndSubsetsAreSpecified = Array.isArray(options?.weights) && Array.isArray(options?.subsets) && options.weights.length > 0 && options.subsets.length > 0;
|
|
28
|
+
if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES && !weightsAndSubsetsAreSpecified) {
|
|
29
|
+
throw new Error("Loading Google Fonts without specifying weights and subsets is not supported in Remotion v5. Please specify the weights and subsets you need.");
|
|
30
|
+
}
|
|
31
|
+
const promises = [];
|
|
32
|
+
const styles = style ? [style] : Object.keys(meta.fonts);
|
|
33
|
+
let fontsLoaded = 0;
|
|
34
|
+
for (const style2 of styles) {
|
|
35
|
+
if (typeof FontFace === "undefined") {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (!meta.fonts[style2]) {
|
|
39
|
+
throw new Error(`The font ${meta.fontFamily} does not have a style ${style2}`);
|
|
40
|
+
}
|
|
41
|
+
const weights = options?.weights ?? Object.keys(meta.fonts[style2]);
|
|
42
|
+
for (const weight of weights) {
|
|
43
|
+
if (!meta.fonts[style2][weight]) {
|
|
44
|
+
throw new Error(`The font ${meta.fontFamily} does not have a weight ${weight} in style ${style2}`);
|
|
45
|
+
}
|
|
46
|
+
const subsets = options?.subsets ?? Object.keys(meta.fonts[style2][weight]);
|
|
47
|
+
for (const subset of subsets) {
|
|
48
|
+
let font = meta.fonts[style2]?.[weight]?.[subset];
|
|
49
|
+
if (!font) {
|
|
50
|
+
throw new Error(`weight: ${weight} subset: ${subset} is not available for '${meta.fontFamily}'`);
|
|
51
|
+
}
|
|
52
|
+
let fontKey = `${meta.fontFamily}-${style2}-${weight}-${subset}`;
|
|
53
|
+
const previousPromise = loadedFonts[fontKey];
|
|
54
|
+
if (previousPromise) {
|
|
55
|
+
promises.push(previousPromise);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const baseLabel = `Fetching ${meta.fontFamily} font ${JSON.stringify({
|
|
59
|
+
style: style2,
|
|
60
|
+
weight,
|
|
61
|
+
subset
|
|
62
|
+
})}`;
|
|
63
|
+
const label = weightsAndSubsetsAreSpecified ? baseLabel : `${baseLabel}. This might be caused by loading too many font variations. Read more: https://www.remotion.dev/docs/troubleshooting/font-loading-errors#render-timeout-when-loading-google-fonts`;
|
|
64
|
+
const handle = delayRender(label, { timeoutInMilliseconds: 60000 });
|
|
65
|
+
fontsLoaded++;
|
|
66
|
+
const fontFace = new FontFace(meta.fontFamily, `url(${font}) format('woff2')`, {
|
|
67
|
+
weight,
|
|
68
|
+
style: style2,
|
|
69
|
+
unicodeRange: meta.unicodeRanges[subset]
|
|
70
|
+
});
|
|
71
|
+
let attempts = 2;
|
|
72
|
+
const tryToLoad = () => {
|
|
73
|
+
if (fontFace.status === "loaded") {
|
|
74
|
+
continueRender(handle);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const promise = loadFontFaceOrTimeoutAfter20Seconds(fontFace).then(() => {
|
|
78
|
+
(options?.document ?? document).fonts.add(fontFace);
|
|
79
|
+
continueRender(handle);
|
|
80
|
+
}).catch((err) => {
|
|
81
|
+
loadedFonts[fontKey] = undefined;
|
|
82
|
+
if (attempts === 0) {
|
|
83
|
+
throw err;
|
|
84
|
+
} else {
|
|
85
|
+
attempts--;
|
|
86
|
+
tryToLoad();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
loadedFonts[fontKey] = promise;
|
|
90
|
+
promises.push(promise);
|
|
91
|
+
};
|
|
92
|
+
tryToLoad();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (fontsLoaded > 20) {
|
|
96
|
+
console.warn(`Made ${fontsLoaded} network requests to load fonts for ${meta.fontFamily}. Consider loading fewer weights and subsets by passing options to loadFont(). Disable this warning by passing "ignoreTooManyRequestsWarning: true" to "options".`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
fontFamily: meta.fontFamily,
|
|
101
|
+
fonts: meta.fonts,
|
|
102
|
+
unicodeRanges: meta.unicodeRanges,
|
|
103
|
+
waitUntilDone: () => Promise.all(promises).then(() => {
|
|
104
|
+
return;
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/BBHSansBartle.ts
|
|
110
|
+
var getInfo = () => ({
|
|
111
|
+
fontFamily: "BBH Sans Bartle",
|
|
112
|
+
importName: "BBHSansBartle",
|
|
113
|
+
version: "v1",
|
|
114
|
+
url: "https://fonts.googleapis.com/css2?family=BBH+Sans+Bartle:ital,wght@0,400",
|
|
115
|
+
unicodeRanges: {
|
|
116
|
+
latin: "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
|
117
|
+
},
|
|
118
|
+
fonts: {
|
|
119
|
+
normal: {
|
|
120
|
+
"400": {
|
|
121
|
+
latin: "https://fonts.gstatic.com/s/bbhsansbartle/v1/eLGEP-v-CSnwOk_evJ1qrrCJCQT58uwg.woff2"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
subsets: ["latin"]
|
|
126
|
+
});
|
|
127
|
+
var fontFamily = "BBH Sans Bartle";
|
|
128
|
+
var loadFont = (style, options) => {
|
|
129
|
+
return loadFonts(getInfo(), style, options);
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
loadFont,
|
|
133
|
+
getInfo,
|
|
134
|
+
fontFamily
|
|
135
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/base.ts
|
|
2
|
+
import { continueRender, delayRender } from "remotion";
|
|
3
|
+
import { NoReactInternals } from "remotion/no-react";
|
|
4
|
+
var loadedFonts = {};
|
|
5
|
+
var withResolvers = function() {
|
|
6
|
+
let resolve;
|
|
7
|
+
let reject;
|
|
8
|
+
const promise = new Promise((res, rej) => {
|
|
9
|
+
resolve = res;
|
|
10
|
+
reject = rej;
|
|
11
|
+
});
|
|
12
|
+
return { promise, resolve, reject };
|
|
13
|
+
};
|
|
14
|
+
var loadFontFaceOrTimeoutAfter20Seconds = (fontFace) => {
|
|
15
|
+
const timeout = withResolvers();
|
|
16
|
+
const int = setTimeout(() => {
|
|
17
|
+
timeout.reject(new Error("Timed out loading Google Font"));
|
|
18
|
+
}, 18000);
|
|
19
|
+
return Promise.race([
|
|
20
|
+
fontFace.load().then(() => {
|
|
21
|
+
clearTimeout(int);
|
|
22
|
+
}),
|
|
23
|
+
timeout.promise
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
var loadFonts = (meta, style, options) => {
|
|
27
|
+
const weightsAndSubsetsAreSpecified = Array.isArray(options?.weights) && Array.isArray(options?.subsets) && options.weights.length > 0 && options.subsets.length > 0;
|
|
28
|
+
if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES && !weightsAndSubsetsAreSpecified) {
|
|
29
|
+
throw new Error("Loading Google Fonts without specifying weights and subsets is not supported in Remotion v5. Please specify the weights and subsets you need.");
|
|
30
|
+
}
|
|
31
|
+
const promises = [];
|
|
32
|
+
const styles = style ? [style] : Object.keys(meta.fonts);
|
|
33
|
+
let fontsLoaded = 0;
|
|
34
|
+
for (const style2 of styles) {
|
|
35
|
+
if (typeof FontFace === "undefined") {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (!meta.fonts[style2]) {
|
|
39
|
+
throw new Error(`The font ${meta.fontFamily} does not have a style ${style2}`);
|
|
40
|
+
}
|
|
41
|
+
const weights = options?.weights ?? Object.keys(meta.fonts[style2]);
|
|
42
|
+
for (const weight of weights) {
|
|
43
|
+
if (!meta.fonts[style2][weight]) {
|
|
44
|
+
throw new Error(`The font ${meta.fontFamily} does not have a weight ${weight} in style ${style2}`);
|
|
45
|
+
}
|
|
46
|
+
const subsets = options?.subsets ?? Object.keys(meta.fonts[style2][weight]);
|
|
47
|
+
for (const subset of subsets) {
|
|
48
|
+
let font = meta.fonts[style2]?.[weight]?.[subset];
|
|
49
|
+
if (!font) {
|
|
50
|
+
throw new Error(`weight: ${weight} subset: ${subset} is not available for '${meta.fontFamily}'`);
|
|
51
|
+
}
|
|
52
|
+
let fontKey = `${meta.fontFamily}-${style2}-${weight}-${subset}`;
|
|
53
|
+
const previousPromise = loadedFonts[fontKey];
|
|
54
|
+
if (previousPromise) {
|
|
55
|
+
promises.push(previousPromise);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const baseLabel = `Fetching ${meta.fontFamily} font ${JSON.stringify({
|
|
59
|
+
style: style2,
|
|
60
|
+
weight,
|
|
61
|
+
subset
|
|
62
|
+
})}`;
|
|
63
|
+
const label = weightsAndSubsetsAreSpecified ? baseLabel : `${baseLabel}. This might be caused by loading too many font variations. Read more: https://www.remotion.dev/docs/troubleshooting/font-loading-errors#render-timeout-when-loading-google-fonts`;
|
|
64
|
+
const handle = delayRender(label, { timeoutInMilliseconds: 60000 });
|
|
65
|
+
fontsLoaded++;
|
|
66
|
+
const fontFace = new FontFace(meta.fontFamily, `url(${font}) format('woff2')`, {
|
|
67
|
+
weight,
|
|
68
|
+
style: style2,
|
|
69
|
+
unicodeRange: meta.unicodeRanges[subset]
|
|
70
|
+
});
|
|
71
|
+
let attempts = 2;
|
|
72
|
+
const tryToLoad = () => {
|
|
73
|
+
if (fontFace.status === "loaded") {
|
|
74
|
+
continueRender(handle);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const promise = loadFontFaceOrTimeoutAfter20Seconds(fontFace).then(() => {
|
|
78
|
+
(options?.document ?? document).fonts.add(fontFace);
|
|
79
|
+
continueRender(handle);
|
|
80
|
+
}).catch((err) => {
|
|
81
|
+
loadedFonts[fontKey] = undefined;
|
|
82
|
+
if (attempts === 0) {
|
|
83
|
+
throw err;
|
|
84
|
+
} else {
|
|
85
|
+
attempts--;
|
|
86
|
+
tryToLoad();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
loadedFonts[fontKey] = promise;
|
|
90
|
+
promises.push(promise);
|
|
91
|
+
};
|
|
92
|
+
tryToLoad();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (fontsLoaded > 20) {
|
|
96
|
+
console.warn(`Made ${fontsLoaded} network requests to load fonts for ${meta.fontFamily}. Consider loading fewer weights and subsets by passing options to loadFont(). Disable this warning by passing "ignoreTooManyRequestsWarning: true" to "options".`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
fontFamily: meta.fontFamily,
|
|
101
|
+
fonts: meta.fonts,
|
|
102
|
+
unicodeRanges: meta.unicodeRanges,
|
|
103
|
+
waitUntilDone: () => Promise.all(promises).then(() => {
|
|
104
|
+
return;
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/BBHSansBogle.ts
|
|
110
|
+
var getInfo = () => ({
|
|
111
|
+
fontFamily: "BBH Sans Bogle",
|
|
112
|
+
importName: "BBHSansBogle",
|
|
113
|
+
version: "v1",
|
|
114
|
+
url: "https://fonts.googleapis.com/css2?family=BBH+Sans+Bogle:ital,wght@0,400",
|
|
115
|
+
unicodeRanges: {
|
|
116
|
+
latin: "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
|
117
|
+
},
|
|
118
|
+
fonts: {
|
|
119
|
+
normal: {
|
|
120
|
+
"400": {
|
|
121
|
+
latin: "https://fonts.gstatic.com/s/bbhsansbogle/v1/LYjbdGTyv25vPsUz0wMCwj1DMc_YeJE.woff2"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
subsets: ["latin"]
|
|
126
|
+
});
|
|
127
|
+
var fontFamily = "BBH Sans Bogle";
|
|
128
|
+
var loadFont = (style, options) => {
|
|
129
|
+
return loadFonts(getInfo(), style, options);
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
loadFont,
|
|
133
|
+
getInfo,
|
|
134
|
+
fontFamily
|
|
135
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/base.ts
|
|
2
|
+
import { continueRender, delayRender } from "remotion";
|
|
3
|
+
import { NoReactInternals } from "remotion/no-react";
|
|
4
|
+
var loadedFonts = {};
|
|
5
|
+
var withResolvers = function() {
|
|
6
|
+
let resolve;
|
|
7
|
+
let reject;
|
|
8
|
+
const promise = new Promise((res, rej) => {
|
|
9
|
+
resolve = res;
|
|
10
|
+
reject = rej;
|
|
11
|
+
});
|
|
12
|
+
return { promise, resolve, reject };
|
|
13
|
+
};
|
|
14
|
+
var loadFontFaceOrTimeoutAfter20Seconds = (fontFace) => {
|
|
15
|
+
const timeout = withResolvers();
|
|
16
|
+
const int = setTimeout(() => {
|
|
17
|
+
timeout.reject(new Error("Timed out loading Google Font"));
|
|
18
|
+
}, 18000);
|
|
19
|
+
return Promise.race([
|
|
20
|
+
fontFace.load().then(() => {
|
|
21
|
+
clearTimeout(int);
|
|
22
|
+
}),
|
|
23
|
+
timeout.promise
|
|
24
|
+
]);
|
|
25
|
+
};
|
|
26
|
+
var loadFonts = (meta, style, options) => {
|
|
27
|
+
const weightsAndSubsetsAreSpecified = Array.isArray(options?.weights) && Array.isArray(options?.subsets) && options.weights.length > 0 && options.subsets.length > 0;
|
|
28
|
+
if (NoReactInternals.ENABLE_V5_BREAKING_CHANGES && !weightsAndSubsetsAreSpecified) {
|
|
29
|
+
throw new Error("Loading Google Fonts without specifying weights and subsets is not supported in Remotion v5. Please specify the weights and subsets you need.");
|
|
30
|
+
}
|
|
31
|
+
const promises = [];
|
|
32
|
+
const styles = style ? [style] : Object.keys(meta.fonts);
|
|
33
|
+
let fontsLoaded = 0;
|
|
34
|
+
for (const style2 of styles) {
|
|
35
|
+
if (typeof FontFace === "undefined") {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (!meta.fonts[style2]) {
|
|
39
|
+
throw new Error(`The font ${meta.fontFamily} does not have a style ${style2}`);
|
|
40
|
+
}
|
|
41
|
+
const weights = options?.weights ?? Object.keys(meta.fonts[style2]);
|
|
42
|
+
for (const weight of weights) {
|
|
43
|
+
if (!meta.fonts[style2][weight]) {
|
|
44
|
+
throw new Error(`The font ${meta.fontFamily} does not have a weight ${weight} in style ${style2}`);
|
|
45
|
+
}
|
|
46
|
+
const subsets = options?.subsets ?? Object.keys(meta.fonts[style2][weight]);
|
|
47
|
+
for (const subset of subsets) {
|
|
48
|
+
let font = meta.fonts[style2]?.[weight]?.[subset];
|
|
49
|
+
if (!font) {
|
|
50
|
+
throw new Error(`weight: ${weight} subset: ${subset} is not available for '${meta.fontFamily}'`);
|
|
51
|
+
}
|
|
52
|
+
let fontKey = `${meta.fontFamily}-${style2}-${weight}-${subset}`;
|
|
53
|
+
const previousPromise = loadedFonts[fontKey];
|
|
54
|
+
if (previousPromise) {
|
|
55
|
+
promises.push(previousPromise);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const baseLabel = `Fetching ${meta.fontFamily} font ${JSON.stringify({
|
|
59
|
+
style: style2,
|
|
60
|
+
weight,
|
|
61
|
+
subset
|
|
62
|
+
})}`;
|
|
63
|
+
const label = weightsAndSubsetsAreSpecified ? baseLabel : `${baseLabel}. This might be caused by loading too many font variations. Read more: https://www.remotion.dev/docs/troubleshooting/font-loading-errors#render-timeout-when-loading-google-fonts`;
|
|
64
|
+
const handle = delayRender(label, { timeoutInMilliseconds: 60000 });
|
|
65
|
+
fontsLoaded++;
|
|
66
|
+
const fontFace = new FontFace(meta.fontFamily, `url(${font}) format('woff2')`, {
|
|
67
|
+
weight,
|
|
68
|
+
style: style2,
|
|
69
|
+
unicodeRange: meta.unicodeRanges[subset]
|
|
70
|
+
});
|
|
71
|
+
let attempts = 2;
|
|
72
|
+
const tryToLoad = () => {
|
|
73
|
+
if (fontFace.status === "loaded") {
|
|
74
|
+
continueRender(handle);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const promise = loadFontFaceOrTimeoutAfter20Seconds(fontFace).then(() => {
|
|
78
|
+
(options?.document ?? document).fonts.add(fontFace);
|
|
79
|
+
continueRender(handle);
|
|
80
|
+
}).catch((err) => {
|
|
81
|
+
loadedFonts[fontKey] = undefined;
|
|
82
|
+
if (attempts === 0) {
|
|
83
|
+
throw err;
|
|
84
|
+
} else {
|
|
85
|
+
attempts--;
|
|
86
|
+
tryToLoad();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
loadedFonts[fontKey] = promise;
|
|
90
|
+
promises.push(promise);
|
|
91
|
+
};
|
|
92
|
+
tryToLoad();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (fontsLoaded > 20) {
|
|
96
|
+
console.warn(`Made ${fontsLoaded} network requests to load fonts for ${meta.fontFamily}. Consider loading fewer weights and subsets by passing options to loadFont(). Disable this warning by passing "ignoreTooManyRequestsWarning: true" to "options".`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
fontFamily: meta.fontFamily,
|
|
101
|
+
fonts: meta.fonts,
|
|
102
|
+
unicodeRanges: meta.unicodeRanges,
|
|
103
|
+
waitUntilDone: () => Promise.all(promises).then(() => {
|
|
104
|
+
return;
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/BBHSansHegarty.ts
|
|
110
|
+
var getInfo = () => ({
|
|
111
|
+
fontFamily: "BBH Sans Hegarty",
|
|
112
|
+
importName: "BBHSansHegarty",
|
|
113
|
+
version: "v1",
|
|
114
|
+
url: "https://fonts.googleapis.com/css2?family=BBH+Sans+Hegarty:ital,wght@0,400",
|
|
115
|
+
unicodeRanges: {
|
|
116
|
+
latin: "U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"
|
|
117
|
+
},
|
|
118
|
+
fonts: {
|
|
119
|
+
normal: {
|
|
120
|
+
"400": {
|
|
121
|
+
latin: "https://fonts.gstatic.com/s/bbhsanshegarty/v1/UqyLK9cfCFIq--EuUZn21v4dILtJfKcDdw.woff2"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
subsets: ["latin"]
|
|
126
|
+
});
|
|
127
|
+
var fontFamily = "BBH Sans Hegarty";
|
|
128
|
+
var loadFont = (style, options) => {
|
|
129
|
+
return loadFonts(getInfo(), style, options);
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
loadFont,
|
|
133
|
+
getInfo,
|
|
134
|
+
fontFamily
|
|
135
|
+
};
|
package/dist/esm/index.mjs
CHANGED
|
@@ -704,6 +704,21 @@ export const getAvailableFonts = () => [
|
|
|
704
704
|
importName: 'B612Mono',
|
|
705
705
|
load: () => import('./B612Mono.mjs'),
|
|
706
706
|
},
|
|
707
|
+
{
|
|
708
|
+
fontFamily: 'BBH Sans Bartle',
|
|
709
|
+
importName: 'BBHSansBartle',
|
|
710
|
+
load: () => import('./BBHSansBartle.mjs'),
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
fontFamily: 'BBH Sans Bogle',
|
|
714
|
+
importName: 'BBHSansBogle',
|
|
715
|
+
load: () => import('./BBHSansBogle.mjs'),
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
fontFamily: 'BBH Sans Hegarty',
|
|
719
|
+
importName: 'BBHSansHegarty',
|
|
720
|
+
load: () => import('./BBHSansHegarty.mjs'),
|
|
721
|
+
},
|
|
707
722
|
{
|
|
708
723
|
fontFamily: 'BIZ UDGothic',
|
|
709
724
|
importName: 'BIZUDGothic',
|