@remotion/google-fonts 4.0.384 → 4.0.385

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.
@@ -0,0 +1,38 @@
1
+ export declare const getInfo: () => {
2
+ fontFamily: string;
3
+ importName: string;
4
+ version: string;
5
+ url: string;
6
+ unicodeRanges: {
7
+ 'latin-ext': string;
8
+ latin: string;
9
+ };
10
+ fonts: {
11
+ normal: {
12
+ '400': {
13
+ 'latin-ext': string;
14
+ latin: string;
15
+ };
16
+ };
17
+ };
18
+ subsets: string[];
19
+ };
20
+ export declare const fontFamily: "Sekuya";
21
+ type Variants = {
22
+ normal: {
23
+ weights: '400';
24
+ subsets: 'latin' | 'latin-ext';
25
+ };
26
+ };
27
+ export declare const loadFont: <T extends keyof Variants>(style?: T, options?: {
28
+ weights?: Variants[T]["weights"][];
29
+ subsets?: Variants[T]["subsets"][];
30
+ document?: Document;
31
+ ignoreTooManyRequestsWarning?: boolean;
32
+ }) => {
33
+ fontFamily: import("./base").FontInfo["fontFamily"];
34
+ fonts: import("./base").FontInfo["fonts"];
35
+ unicodeRanges: import("./base").FontInfo["unicodeRanges"];
36
+ waitUntilDone: () => Promise<undefined>;
37
+ };
38
+ export {};
@@ -0,0 +1,29 @@
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: 'Sekuya',
7
+ importName: 'Sekuya',
8
+ version: 'v1',
9
+ url: 'https://fonts.googleapis.com/css2?family=Sekuya:ital,wght@0,400',
10
+ unicodeRanges: {
11
+ 'latin-ext': 'U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF',
12
+ 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',
13
+ },
14
+ fonts: {
15
+ normal: {
16
+ '400': {
17
+ 'latin-ext': 'https://fonts.gstatic.com/s/sekuya/v1/fdN_9suEu39Dg3wU0yBerF8.woff2',
18
+ latin: 'https://fonts.gstatic.com/s/sekuya/v1/fdN_9suEu39Dg3wU3SBe.woff2',
19
+ },
20
+ },
21
+ },
22
+ subsets: ['latin', 'latin-ext'],
23
+ });
24
+ exports.getInfo = getInfo;
25
+ exports.fontFamily = 'Sekuya';
26
+ const loadFont = (style, options) => {
27
+ return (0, base_1.loadFonts)((0, exports.getInfo)(), style, options);
28
+ };
29
+ exports.loadFont = loadFont;
package/dist/cjs/index.js CHANGED
@@ -337,6 +337,11 @@ const getAvailableFonts = () => [
337
337
  importName: 'Amaranth',
338
338
  load: () => Promise.resolve().then(() => __importStar(require('./Amaranth'))),
339
339
  },
340
+ {
341
+ fontFamily: 'Amarna',
342
+ importName: 'Amarna',
343
+ load: () => Promise.resolve().then(() => __importStar(require('./Amarna'))),
344
+ },
340
345
  {
341
346
  fontFamily: 'Amatic SC',
342
347
  importName: 'AmaticSC',
@@ -742,6 +747,21 @@ const getAvailableFonts = () => [
742
747
  importName: 'B612Mono',
743
748
  load: () => Promise.resolve().then(() => __importStar(require('./B612Mono'))),
744
749
  },
750
+ {
751
+ fontFamily: 'BBH Bartle',
752
+ importName: 'BBHBartle',
753
+ load: () => Promise.resolve().then(() => __importStar(require('./BBHBartle'))),
754
+ },
755
+ {
756
+ fontFamily: 'BBH Bogle',
757
+ importName: 'BBHBogle',
758
+ load: () => Promise.resolve().then(() => __importStar(require('./BBHBogle'))),
759
+ },
760
+ {
761
+ fontFamily: 'BBH Hegarty',
762
+ importName: 'BBHHegarty',
763
+ load: () => Promise.resolve().then(() => __importStar(require('./BBHHegarty'))),
764
+ },
745
765
  {
746
766
  fontFamily: 'BIZ UDGothic',
747
767
  importName: 'BIZUDGothic',
@@ -1517,6 +1537,11 @@ const getAvailableFonts = () => [
1517
1537
  importName: 'Caudex',
1518
1538
  load: () => Promise.resolve().then(() => __importStar(require('./Caudex'))),
1519
1539
  },
1540
+ {
1541
+ fontFamily: 'Cause',
1542
+ importName: 'Cause',
1543
+ load: () => Promise.resolve().then(() => __importStar(require('./Cause'))),
1544
+ },
1520
1545
  {
1521
1546
  fontFamily: 'Caveat',
1522
1547
  importName: 'Caveat',
@@ -2787,6 +2812,11 @@ const getAvailableFonts = () => [
2787
2812
  importName: 'Geologica',
2788
2813
  load: () => Promise.resolve().then(() => __importStar(require('./Geologica'))),
2789
2814
  },
2815
+ {
2816
+ fontFamily: 'Geom',
2817
+ importName: 'Geom',
2818
+ load: () => Promise.resolve().then(() => __importStar(require('./Geom'))),
2819
+ },
2790
2820
  {
2791
2821
  fontFamily: 'Georama',
2792
2822
  importName: 'Georama',
@@ -2887,6 +2917,11 @@ const getAvailableFonts = () => [
2887
2917
  importName: 'GolosText',
2888
2918
  load: () => Promise.resolve().then(() => __importStar(require('./GolosText'))),
2889
2919
  },
2920
+ {
2921
+ fontFamily: 'Google Sans',
2922
+ importName: 'GoogleSans',
2923
+ load: () => Promise.resolve().then(() => __importStar(require('./GoogleSans'))),
2924
+ },
2890
2925
  {
2891
2926
  fontFamily: 'Google Sans Code',
2892
2927
  importName: 'GoogleSansCode',
@@ -4197,6 +4232,11 @@ const getAvailableFonts = () => [
4197
4232
  importName: 'LifeSavers',
4198
4233
  load: () => Promise.resolve().then(() => __importStar(require('./LifeSavers'))),
4199
4234
  },
4235
+ {
4236
+ fontFamily: 'Lilex',
4237
+ importName: 'Lilex',
4238
+ load: () => Promise.resolve().then(() => __importStar(require('./Lilex'))),
4239
+ },
4200
4240
  {
4201
4241
  fontFamily: 'Lilita One',
4202
4242
  importName: 'LilitaOne',
@@ -7592,6 +7632,11 @@ const getAvailableFonts = () => [
7592
7632
  importName: 'SedgwickAveDisplay',
7593
7633
  load: () => Promise.resolve().then(() => __importStar(require('./SedgwickAveDisplay'))),
7594
7634
  },
7635
+ {
7636
+ fontFamily: 'Sekuya',
7637
+ importName: 'Sekuya',
7638
+ load: () => Promise.resolve().then(() => __importStar(require('./Sekuya'))),
7639
+ },
7595
7640
  {
7596
7641
  fontFamily: 'Sen',
7597
7642
  importName: 'Sen',
@@ -0,0 +1,191 @@
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/Amarna.ts
110
+ var getInfo = () => ({
111
+ fontFamily: "Amarna",
112
+ importName: "Amarna",
113
+ version: "v1",
114
+ url: "https://fonts.googleapis.com/css2?family=Amarna:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700",
115
+ unicodeRanges: {
116
+ "latin-ext": "U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF",
117
+ 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"
118
+ },
119
+ fonts: {
120
+ italic: {
121
+ "100": {
122
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
123
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
124
+ },
125
+ "200": {
126
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
127
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
128
+ },
129
+ "300": {
130
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
131
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
132
+ },
133
+ "400": {
134
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
135
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
136
+ },
137
+ "500": {
138
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
139
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
140
+ },
141
+ "600": {
142
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
143
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
144
+ },
145
+ "700": {
146
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7Ax-p7ABg.woff2",
147
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoQzAj-18jIHCA0R7A_-p4.woff2"
148
+ }
149
+ },
150
+ normal: {
151
+ "100": {
152
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
153
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
154
+ },
155
+ "200": {
156
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
157
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
158
+ },
159
+ "300": {
160
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
161
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
162
+ },
163
+ "400": {
164
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
165
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
166
+ },
167
+ "500": {
168
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
169
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
170
+ },
171
+ "600": {
172
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
173
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
174
+ },
175
+ "700": {
176
+ "latin-ext": "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0TIA94po.woff2",
177
+ latin: "https://fonts.gstatic.com/s/amarna/v1/MCoSzAj-18jIHCA0QoA9.woff2"
178
+ }
179
+ }
180
+ },
181
+ subsets: ["latin", "latin-ext"]
182
+ });
183
+ var fontFamily = "Amarna";
184
+ var loadFont = (style, options) => {
185
+ return loadFonts(getInfo(), style, options);
186
+ };
187
+ export {
188
+ loadFont,
189
+ getInfo,
190
+ fontFamily
191
+ };
@@ -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/BBHBartle.ts
110
+ var getInfo = () => ({
111
+ fontFamily: "BBH Bartle",
112
+ importName: "BBHBartle",
113
+ version: "v1",
114
+ url: "https://fonts.googleapis.com/css2?family=BBH+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/bbhbartle/v1/zYXjKVYuMYMaN-IMqP3RemmZkA.woff2"
122
+ }
123
+ }
124
+ },
125
+ subsets: ["latin"]
126
+ });
127
+ var fontFamily = "BBH 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/BBHBogle.ts
110
+ var getInfo = () => ({
111
+ fontFamily: "BBH Bogle",
112
+ importName: "BBHBogle",
113
+ version: "v1",
114
+ url: "https://fonts.googleapis.com/css2?family=BBH+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/bbhbogle/v1/GFDoWA58rVDJf-fOV9A7rJJd.woff2"
122
+ }
123
+ }
124
+ },
125
+ subsets: ["latin"]
126
+ });
127
+ var fontFamily = "BBH Bogle";
128
+ var loadFont = (style, options) => {
129
+ return loadFonts(getInfo(), style, options);
130
+ };
131
+ export {
132
+ loadFont,
133
+ getInfo,
134
+ fontFamily
135
+ };