@remotion/layout-utils 4.0.87 → 4.0.88

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.
@@ -1,2 +1,3 @@
1
1
  export { fillTextBox } from './layouts/fill-text-box';
2
+ export { fitText } from './layouts/fit-text';
2
3
  export { measureText } from './layouts/measure-text';
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.measureText = exports.fillTextBox = void 0;
3
+ exports.measureText = exports.fitText = exports.fillTextBox = void 0;
4
4
  var fill_text_box_1 = require("./layouts/fill-text-box");
5
5
  Object.defineProperty(exports, "fillTextBox", { enumerable: true, get: function () { return fill_text_box_1.fillTextBox; } });
6
+ var fit_text_1 = require("./layouts/fit-text");
7
+ Object.defineProperty(exports, "fitText", { enumerable: true, get: function () { return fit_text_1.fitText; } });
6
8
  var measure_text_1 = require("./layouts/measure-text");
7
9
  Object.defineProperty(exports, "measureText", { enumerable: true, get: function () { return measure_text_1.measureText; } });
@@ -0,0 +1,10 @@
1
+ export declare const fitText: ({ text, withinWidth, fontFamily, fontVariantNumeric, fontWeight, letterSpacing, }: {
2
+ text: string;
3
+ withinWidth: number;
4
+ fontFamily: string;
5
+ fontWeight?: string | number | undefined;
6
+ letterSpacing?: string | undefined;
7
+ fontVariantNumeric?: string | undefined;
8
+ }) => {
9
+ fontSize: number;
10
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fitText = void 0;
4
+ const measure_text_1 = require("../layouts/measure-text");
5
+ const sampleSize = 100;
6
+ const fitText = ({ text, withinWidth, fontFamily, fontVariantNumeric, fontWeight, letterSpacing, }) => {
7
+ const estimate = (0, measure_text_1.measureText)({
8
+ text,
9
+ fontFamily,
10
+ fontSize: sampleSize,
11
+ fontWeight,
12
+ fontVariantNumeric,
13
+ letterSpacing,
14
+ });
15
+ return { fontSize: (withinWidth / estimate.width) * sampleSize };
16
+ };
17
+ exports.fitText = fitText;
@@ -1,2 +1,3 @@
1
1
  export { fillTextBox } from './layouts/fill-text-box';
2
+ export { fitText } from './layouts/fit-text';
2
3
  export { measureText } from './layouts/measure-text';
@@ -83,4 +83,17 @@ const fillTextBox = ({ maxBoxWidth, maxLines, }) => {
83
83
  };
84
84
  };
85
85
 
86
- export { fillTextBox, measureText };
86
+ const sampleSize = 100;
87
+ const fitText = ({ text, withinWidth, fontFamily, fontVariantNumeric, fontWeight, letterSpacing, }) => {
88
+ const estimate = measureText({
89
+ text,
90
+ fontFamily,
91
+ fontSize: sampleSize,
92
+ fontWeight,
93
+ fontVariantNumeric,
94
+ letterSpacing,
95
+ });
96
+ return { fontSize: (withinWidth / estimate.width) * sampleSize };
97
+ };
98
+
99
+ export { fillTextBox, fitText, measureText };
@@ -0,0 +1,10 @@
1
+ export declare const fitText: ({ text, withinWidth, fontFamily, fontVariantNumeric, fontWeight, letterSpacing, }: {
2
+ text: string;
3
+ withinWidth: number;
4
+ fontFamily: string;
5
+ fontWeight?: string | number | undefined;
6
+ letterSpacing?: string | undefined;
7
+ fontVariantNumeric?: string | undefined;
8
+ }) => {
9
+ fontSize: number;
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/layout-utils",
3
- "version": "4.0.87",
3
+ "version": "4.0.88",
4
4
  "description": "Layout Utils for Remotion",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/cjs/index.d.ts",
@@ -28,9 +28,7 @@
28
28
  "bugs": {
29
29
  "url": "https://github.com/remotion-dev/remotion/issues"
30
30
  },
31
- "dependencies": {
32
- "remotion": "4.0.87"
33
- },
31
+ "dependencies": {},
34
32
  "devDependencies": {
35
33
  "@jonny/eslint-config": "3.0.276",
36
34
  "@rollup/plugin-typescript": "^8.2.0",