@junwan666/remotion-fonts 4.0.448-zh.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/README.md +18 -0
- package/dist/cjs/get-font-format.d.ts +2 -0
- package/dist/cjs/get-font-format.js +20 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/load-font.d.ts +17 -0
- package/dist/cjs/load-font.js +32 -0
- package/dist/esm/index.mjs +5 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @remotion/fonts
|
|
2
|
+
|
|
3
|
+
Helpers for loading local fonts into Remotion
|
|
4
|
+
|
|
5
|
+
[](https://npmcharts.com/compare/@remotion/fonts?minimal=true)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @remotion/fonts --save-exact
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
When installing a Remotion package, make sure to align the version of all `remotion` and `@remotion/*` packages to the same version.
|
|
14
|
+
Remove the `^` character from the version number to use the exact version.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
See the [documentation](https://www.remotion.dev/docs/fonts-api) for more information.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFontFormat = void 0;
|
|
4
|
+
const getFontFormat = (url) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const ext = (_a = url.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
7
|
+
switch (ext) {
|
|
8
|
+
case 'woff2':
|
|
9
|
+
return 'woff2';
|
|
10
|
+
case 'woff':
|
|
11
|
+
return 'woff';
|
|
12
|
+
case 'otf':
|
|
13
|
+
return 'opentype';
|
|
14
|
+
case 'ttf':
|
|
15
|
+
return 'truetype';
|
|
16
|
+
default:
|
|
17
|
+
throw new Error(`Could not automatically derive font format from extension: ${ext}. Pass the "format" parameter explicitly.`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
exports.getFontFormat = getFontFormat;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFont = void 0;
|
|
4
|
+
const load_font_1 = require("./load-font");
|
|
5
|
+
Object.defineProperty(exports, "loadFont", { enumerable: true, get: function () { return load_font_1.loadFont; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FontFormat } from './get-font-format';
|
|
2
|
+
export type LoadFontOptions = {
|
|
3
|
+
family: string;
|
|
4
|
+
url: string;
|
|
5
|
+
ascentOverride?: string;
|
|
6
|
+
descentOverride?: string;
|
|
7
|
+
display?: 'auto' | 'block' | 'fallback' | 'optional' | 'swap';
|
|
8
|
+
featureSettings?: string;
|
|
9
|
+
lineGapOverride?: string;
|
|
10
|
+
stretch?: string;
|
|
11
|
+
style?: string;
|
|
12
|
+
unicodeRange?: string;
|
|
13
|
+
variant?: string;
|
|
14
|
+
weight?: string;
|
|
15
|
+
format?: FontFormat;
|
|
16
|
+
};
|
|
17
|
+
export declare const loadFont: ({ family, url, ascentOverride, descentOverride, display, featureSettings, lineGapOverride, stretch, style, unicodeRange, weight, format, variant, }: LoadFontOptions) => Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFont = void 0;
|
|
4
|
+
const remotion_1 = require("remotion");
|
|
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, }) => {
|
|
7
|
+
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
|
+
try {
|
|
9
|
+
const fontFormat = format !== null && format !== void 0 ? format : (0, get_font_format_1.getFontFormat)(url);
|
|
10
|
+
const font = new FontFace(family, `url('${url}') format('${fontFormat}')`, {
|
|
11
|
+
ascentOverride,
|
|
12
|
+
descentOverride,
|
|
13
|
+
display,
|
|
14
|
+
featureSettings,
|
|
15
|
+
lineGapOverride,
|
|
16
|
+
stretch,
|
|
17
|
+
style,
|
|
18
|
+
unicodeRange,
|
|
19
|
+
weight,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
21
|
+
// @ts-ignore variant is not in the FontFace constructor
|
|
22
|
+
variant,
|
|
23
|
+
});
|
|
24
|
+
await font.load();
|
|
25
|
+
document.fonts.add(font);
|
|
26
|
+
(0, remotion_1.continueRender)(waitForFont);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
(0, remotion_1.cancelRender)(err);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.loadFont = loadFont;
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"repository": {
|
|
3
|
+
"url": "https://github.com/JunWan666/remotion-zh/tree/main/packages/fonts"
|
|
4
|
+
},
|
|
5
|
+
"name": "@junwan666/remotion-fonts",
|
|
6
|
+
"version": "4.0.448-zh.0",
|
|
7
|
+
"description": "Helpers for loading local fonts into Remotion",
|
|
8
|
+
"main": "dist/cjs/index.js",
|
|
9
|
+
"types": "dist/cjs/index.d.ts",
|
|
10
|
+
"module": "dist/esm/index.mjs",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"scripts": {
|
|
13
|
+
"formatting": "oxfmt src --check",
|
|
14
|
+
"format": "oxfmt src",
|
|
15
|
+
"lint": "eslint src",
|
|
16
|
+
"make": "tsgo -d && bun --env-file=../.env.bundle bundle.ts"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"remotion",
|
|
20
|
+
"fonts"
|
|
21
|
+
],
|
|
22
|
+
"author": "Lucas Benya <bitup.games@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/remotion-dev/remotion/issues"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"remotion": "npm:@junwan666/remotion@4.0.448-zh.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@remotion/eslint-config-internal": "npm:@junwan666/remotion-eslint-config-internal@4.0.448-zh.0",
|
|
32
|
+
"eslint": "9.19.0",
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260217.1"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://www.remotion.dev/docs/fonts-api"
|
|
39
|
+
}
|