@remotion/layout-utils 4.0.462 → 4.0.464

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.
@@ -30,7 +30,7 @@ const fillTextBox = ({ maxBoxWidth, maxLines, }) => {
30
30
  ];
31
31
  const widths = lineWithWord.map((w) => (0, measure_text_1.measureText)(w).width);
32
32
  const lineWidthWithWordAdded = widths.reduce((a, b) => a + b, 0);
33
- if (Math.ceil(lineWidthWithWordAdded) < maxBoxWidth) {
33
+ if (Math.ceil(lineWidthWithWordAdded) <= maxBoxWidth) {
34
34
  lines[currentlyAt].push({
35
35
  text: lines[currentlyAt].length === 0 ? text.trimStart() : text,
36
36
  fontFamily,
@@ -39,23 +39,30 @@ const fillTextBox = ({ maxBoxWidth, maxLines, }) => {
39
39
  letterSpacing,
40
40
  textTransform,
41
41
  fontVariantNumeric,
42
+ validateFontIsLoaded,
43
+ additionalStyles,
42
44
  });
43
45
  return { exceedsBox: false, newLine: false };
44
46
  }
45
47
  if (currentlyAt === maxLines - 1) {
46
48
  return { exceedsBox: true, newLine: false };
47
49
  }
48
- lines[currentlyAt + 1] = [
49
- {
50
- text: text.trimStart(),
51
- fontFamily,
52
- fontWeight,
53
- fontSize,
54
- letterSpacing,
55
- textTransform,
56
- fontVariantNumeric,
57
- },
58
- ];
50
+ const wordForNewLine = {
51
+ text: text.trimStart(),
52
+ fontFamily,
53
+ fontWeight,
54
+ fontSize,
55
+ letterSpacing,
56
+ fontVariantNumeric,
57
+ validateFontIsLoaded,
58
+ textTransform,
59
+ additionalStyles,
60
+ };
61
+ const wordAloneWidth = (0, measure_text_1.measureText)(wordForNewLine).width;
62
+ if (Math.ceil(wordAloneWidth) > maxBoxWidth) {
63
+ return { exceedsBox: true, newLine: false };
64
+ }
65
+ lines[currentlyAt + 1] = [wordForNewLine];
59
66
  return { exceedsBox: false, newLine: true };
60
67
  },
61
68
  };
@@ -146,7 +146,7 @@ var fillTextBox = ({
146
146
  ];
147
147
  const widths = lineWithWord.map((w) => measureText(w).width);
148
148
  const lineWidthWithWordAdded = widths.reduce((a, b) => a + b, 0);
149
- if (Math.ceil(lineWidthWithWordAdded) < maxBoxWidth) {
149
+ if (Math.ceil(lineWidthWithWordAdded) <= maxBoxWidth) {
150
150
  lines[currentlyAt].push({
151
151
  text: lines[currentlyAt].length === 0 ? text.trimStart() : text,
152
152
  fontFamily,
@@ -154,24 +154,31 @@ var fillTextBox = ({
154
154
  fontSize,
155
155
  letterSpacing,
156
156
  textTransform,
157
- fontVariantNumeric
157
+ fontVariantNumeric,
158
+ validateFontIsLoaded,
159
+ additionalStyles
158
160
  });
159
161
  return { exceedsBox: false, newLine: false };
160
162
  }
161
163
  if (currentlyAt === maxLines - 1) {
162
164
  return { exceedsBox: true, newLine: false };
163
165
  }
164
- lines[currentlyAt + 1] = [
165
- {
166
- text: text.trimStart(),
167
- fontFamily,
168
- fontWeight,
169
- fontSize,
170
- letterSpacing,
171
- textTransform,
172
- fontVariantNumeric
173
- }
174
- ];
166
+ const wordForNewLine = {
167
+ text: text.trimStart(),
168
+ fontFamily,
169
+ fontWeight,
170
+ fontSize,
171
+ letterSpacing,
172
+ fontVariantNumeric,
173
+ validateFontIsLoaded,
174
+ textTransform,
175
+ additionalStyles
176
+ };
177
+ const wordAloneWidth = measureText(wordForNewLine).width;
178
+ if (Math.ceil(wordAloneWidth) > maxBoxWidth) {
179
+ return { exceedsBox: true, newLine: false };
180
+ }
181
+ lines[currentlyAt + 1] = [wordForNewLine];
175
182
  return { exceedsBox: false, newLine: true };
176
183
  }
177
184
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/layout-utils"
4
4
  },
5
5
  "name": "@remotion/layout-utils",
6
- "version": "4.0.462",
6
+ "version": "4.0.464",
7
7
  "description": "Utilities for working with layouts",
8
8
  "main": "dist/cjs/index.js",
9
9
  "types": "dist/cjs/index.d.ts",
@@ -12,7 +12,10 @@
12
12
  "formatting": "oxfmt src --check",
13
13
  "format": "oxfmt src",
14
14
  "lint": "eslint src",
15
- "make": "tsgo -d && bun --env-file=../.env.bundle bundle.ts"
15
+ "make": "tsgo -d && bun --env-file=../.env.bundle bundle.ts",
16
+ "testlayoututils": "vitest src/test --browser --run",
17
+ "studio": "cd ../example && bunx remotion studio ../layout-utils/src/test/studio.ts --public-dir=../example-videos/videos",
18
+ "remotion": "cd ../example && bunx remotion studio ../layout-utils/src/test/studio.ts --public-dir=../example-videos/videos"
16
19
  },
17
20
  "exports": {
18
21
  "./package.json": "./package.json",
@@ -24,9 +27,16 @@
24
27
  }
25
28
  },
26
29
  "devDependencies": {
27
- "@remotion/eslint-config-internal": "4.0.462",
30
+ "@remotion/eslint-config-internal": "4.0.464",
31
+ "@vitejs/plugin-react": "4.3.4",
32
+ "@vitest/browser-playwright": "4.0.9",
33
+ "@typescript/native-preview": "7.0.0-dev.20260217.1",
28
34
  "eslint": "9.19.0",
29
- "@typescript/native-preview": "7.0.0-dev.20260217.1"
35
+ "playwright": "1.55.1",
36
+ "react": "19.2.3",
37
+ "react-dom": "19.2.3",
38
+ "remotion": "4.0.464",
39
+ "vitest": "4.0.9"
30
40
  },
31
41
  "author": "Yehor Misiats (https://github.com/satelllte)",
32
42
  "maintainers": [