@remotion/fonts 4.0.450 → 4.0.452

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.
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFontFormat = void 0;
4
4
  const getFontFormat = (url) => {
5
5
  var _a;
6
+ if (typeof url !== 'string') {
7
+ throw new TypeError(`Expected a URL string but received ${url === undefined ? 'undefined' : typeof url}. Make sure to pass a "url" field in the options object of loadFont().`);
8
+ }
6
9
  const ext = (_a = url.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
7
10
  switch (ext) {
8
11
  case 'woff2':
@@ -14,4 +14,4 @@ export type LoadFontOptions = {
14
14
  weight?: string;
15
15
  format?: FontFormat;
16
16
  };
17
- export declare const loadFont: ({ family, url, ascentOverride, descentOverride, display, featureSettings, lineGapOverride, stretch, style, unicodeRange, weight, format, variant, }: LoadFontOptions) => Promise<void>;
17
+ export declare const loadFont: (options: LoadFontOptions) => Promise<void>;
@@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadFont = void 0;
4
4
  const remotion_1 = require("remotion");
5
5
  const get_font_format_1 = require("./get-font-format");
6
- const loadFont = async ({ family, url, ascentOverride, descentOverride, display, featureSettings, lineGapOverride, stretch, style, unicodeRange, weight, format, variant, }) => {
6
+ const loadFont = async (options) => {
7
+ if (typeof options !== 'object' || options === null) {
8
+ throw new TypeError(`loadFont() requires an object as its argument, but received ${typeof options === 'string' ? `"${options}"` : typeof options}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font`);
9
+ }
10
+ const { family, url, ascentOverride, descentOverride, display, featureSettings, lineGapOverride, stretch, style, unicodeRange, weight, format, variant, } = options;
11
+ if (typeof url !== 'string') {
12
+ throw new TypeError(`loadFont() requires a "url" field in the options object, but received ${url === undefined ? 'undefined' : JSON.stringify(url)}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font`);
13
+ }
7
14
  const waitForFont = (0, remotion_1.delayRender)(`Loading font ${family} (url: ${url}, format: ${format}, weight: ${weight}, style: ${style}, variant: ${variant}, ascentOverride: ${ascentOverride}, descentOverride: ${descentOverride}, display: ${display}, featureSettings: ${featureSettings}, lineGapOverride: ${lineGapOverride}, stretch: ${stretch}, unicodeRange: ${unicodeRange})`);
8
15
  try {
9
16
  const fontFormat = format !== null && format !== void 0 ? format : (0, get_font_format_1.getFontFormat)(url);
@@ -1,5 +1,8 @@
1
1
  // src/get-font-format.ts
2
2
  var getFontFormat = (url) => {
3
+ if (typeof url !== "string") {
4
+ throw new TypeError(`Expected a URL string but received ${url === undefined ? "undefined" : typeof url}. Make sure to pass a "url" field in the options object of loadFont().`);
5
+ }
3
6
  const ext = url.split(".").pop()?.toLowerCase();
4
7
  switch (ext) {
5
8
  case "woff2":
@@ -17,21 +20,28 @@ var getFontFormat = (url) => {
17
20
 
18
21
  // src/load-font.ts
19
22
  import { cancelRender, continueRender, delayRender } from "remotion";
20
- var loadFont = async ({
21
- family,
22
- url,
23
- ascentOverride,
24
- descentOverride,
25
- display,
26
- featureSettings,
27
- lineGapOverride,
28
- stretch,
29
- style,
30
- unicodeRange,
31
- weight,
32
- format,
33
- variant
34
- }) => {
23
+ var loadFont = async (options) => {
24
+ if (typeof options !== "object" || options === null) {
25
+ throw new TypeError(`loadFont() requires an object as its argument, but received ${typeof options === "string" ? `"${options}"` : typeof options}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font`);
26
+ }
27
+ const {
28
+ family,
29
+ url,
30
+ ascentOverride,
31
+ descentOverride,
32
+ display,
33
+ featureSettings,
34
+ lineGapOverride,
35
+ stretch,
36
+ style,
37
+ unicodeRange,
38
+ weight,
39
+ format,
40
+ variant
41
+ } = options;
42
+ if (typeof url !== "string") {
43
+ throw new TypeError(`loadFont() requires a "url" field in the options object, but received ${url === undefined ? "undefined" : JSON.stringify(url)}. If you want to load a Google Font, use the @remotion/google-fonts package instead. See: https://www.remotion.dev/docs/google-fonts/load-font`);
44
+ }
35
45
  const waitForFont = delayRender(`Loading font ${family} (url: ${url}, format: ${format}, weight: ${weight}, style: ${style}, variant: ${variant}, ascentOverride: ${ascentOverride}, descentOverride: ${descentOverride}, display: ${display}, featureSettings: ${featureSettings}, lineGapOverride: ${lineGapOverride}, stretch: ${stretch}, unicodeRange: ${unicodeRange})`);
36
46
  try {
37
47
  const fontFormat = format ?? getFontFormat(url);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/fonts"
4
4
  },
5
5
  "name": "@remotion/fonts",
6
- "version": "4.0.450",
6
+ "version": "4.0.452",
7
7
  "description": "Helpers for loading local fonts into Remotion",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -25,10 +25,10 @@
25
25
  "url": "https://github.com/remotion-dev/remotion/issues"
26
26
  },
27
27
  "dependencies": {
28
- "remotion": "4.0.449"
28
+ "remotion": "4.0.452"
29
29
  },
30
30
  "devDependencies": {
31
- "@remotion/eslint-config-internal": "4.0.449",
31
+ "@remotion/eslint-config-internal": "4.0.452",
32
32
  "eslint": "9.19.0",
33
33
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
34
34
  },