@remotion/google-fonts 4.0.372 → 4.0.373

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,157 @@
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/StackSansText.ts
110
+ var getInfo = () => ({
111
+ fontFamily: "Stack Sans Text",
112
+ importName: "StackSansText",
113
+ version: "v1",
114
+ url: "https://fonts.googleapis.com/css2?family=Stack+Sans+Text:ital,wght@0,200;0,300;0,400;0,500;0,600;0,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
+ normal: {
121
+ "200": {
122
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
123
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
124
+ },
125
+ "300": {
126
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
127
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
128
+ },
129
+ "400": {
130
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
131
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
132
+ },
133
+ "500": {
134
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
135
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
136
+ },
137
+ "600": {
138
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
139
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
140
+ },
141
+ "700": {
142
+ "latin-ext": "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnBLy4NY8.woff2",
143
+ latin: "https://fonts.gstatic.com/s/stacksanstext/v1/kJErBuAJ-Q0hiGPmzHEu345X1JJnCry4.woff2"
144
+ }
145
+ }
146
+ },
147
+ subsets: ["latin", "latin-ext"]
148
+ });
149
+ var fontFamily = "Stack Sans Text";
150
+ var loadFont = (style, options) => {
151
+ return loadFonts(getInfo(), style, options);
152
+ };
153
+ export {
154
+ loadFont,
155
+ getInfo,
156
+ fontFamily
157
+ };
@@ -2229,6 +2229,11 @@ export const getAvailableFonts = () => [
2229
2229
  importName: 'Electrolize',
2230
2230
  load: () => import('./Electrolize.mjs'),
2231
2231
  },
2232
+ {
2233
+ fontFamily: 'Elms Sans',
2234
+ importName: 'ElmsSans',
2235
+ load: () => import('./ElmsSans.mjs'),
2236
+ },
2232
2237
  {
2233
2238
  fontFamily: 'Elsie',
2234
2239
  importName: 'Elsie',
@@ -7975,6 +7980,21 @@ export const getAvailableFonts = () => [
7975
7980
  importName: 'Staatliches',
7976
7981
  load: () => import('./Staatliches.mjs'),
7977
7982
  },
7983
+ {
7984
+ fontFamily: 'Stack Sans Headline',
7985
+ importName: 'StackSansHeadline',
7986
+ load: () => import('./StackSansHeadline.mjs'),
7987
+ },
7988
+ {
7989
+ fontFamily: 'Stack Sans Notch',
7990
+ importName: 'StackSansNotch',
7991
+ load: () => import('./StackSansNotch.mjs'),
7992
+ },
7993
+ {
7994
+ fontFamily: 'Stack Sans Text',
7995
+ importName: 'StackSansText',
7996
+ load: () => import('./StackSansText.mjs'),
7997
+ },
7978
7998
  {
7979
7999
  fontFamily: 'Stalemate',
7980
8000
  importName: 'Stalemate',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/google-fonts"
4
4
  },
5
5
  "name": "@remotion/google-fonts",
6
- "version": "4.0.372",
6
+ "version": "4.0.373",
7
7
  "description": "Use Google Fonts in Remotion",
8
8
  "main": "dist/cjs/index.js",
9
9
  "module": "dist/esm/index.mjs",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "license": "SEE LICENSE IN LICENSE.md",
16
16
  "dependencies": {
17
- "remotion": "4.0.372"
17
+ "remotion": "4.0.373"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/css-font-loading-module": "0.0.14",
@@ -1363,6 +1363,9 @@
1363
1363
  "Electrolize": [
1364
1364
  "dist/cjs/Electrolize.d.ts"
1365
1365
  ],
1366
+ "ElmsSans": [
1367
+ "dist/cjs/ElmsSans.d.ts"
1368
+ ],
1366
1369
  "Elsie": [
1367
1370
  "dist/cjs/Elsie.d.ts"
1368
1371
  ],
@@ -4810,6 +4813,15 @@
4810
4813
  "Staatliches": [
4811
4814
  "dist/cjs/Staatliches.d.ts"
4812
4815
  ],
4816
+ "StackSansHeadline": [
4817
+ "dist/cjs/StackSansHeadline.d.ts"
4818
+ ],
4819
+ "StackSansNotch": [
4820
+ "dist/cjs/StackSansNotch.d.ts"
4821
+ ],
4822
+ "StackSansText": [
4823
+ "dist/cjs/StackSansText.d.ts"
4824
+ ],
4813
4825
  "Stalemate": [
4814
4826
  "dist/cjs/Stalemate.d.ts"
4815
4827
  ],