Commit 34faaa1
authored
fix(text): honour letter-spacing when breaking lines (#132)
The fit test that decides where a line breaks measured with zero tracking while
every consumer measured the resulting lines with the real value, so measurement
and paint no longer shared a fixed point: the box was sized for one line, paint
decided two were needed, and left-aligned them in a box sized for one.
Measured on a centred headline, frame centre 960: at 290px with -9px tracking
the ink centre sat at 552, a 408px error, and the validator called the scenario
clean whenever the text carried an explicit height — it re-measures through the
same intrinsic and inherited the same blind spot. At 240px a negative tracking,
which makes the string narrower, gained it a break it did not have at zero.
Wrapping now takes the tracking. All four sweep rows converge on the frame
centre, and the spurious breaks are gone. This matters because tight negative
tracking on large type is the defining trait of the register this project
targets — it was the one thing that could not be expressed.
gradient_text turned out to drop letter-spacing entirely: it was hardcoded to
zero at wrap, at width measurement and at draw, while its intrinsic sized the
box with the real value. Fixing only the wrap would have replaced one mismatch
with another, so all three now agree.
Relative units are the same defect one layer down: em, rem, vw and vh parse
cleanly and are then discarded by Length::px(), which returns 0 — indistinguishable
from a deliberate zero, and advertised as valid by the exported schema. A
scenario sized in vw rendered a black frame and exited 0. They now resolve
through a LengthContext where one is reachable, and warn loudly where it is
not. em on font-size itself still needs a resolved parent size from the
cascade; that is left, and documented, rather than half-done.
All seven tracked examples render pixel-identically.
Closes #1251 parent 4a519ba commit 34faaa1
7 files changed
Lines changed: 800 additions & 40 deletions
File tree
- crates
- rustmotion-components/src
- rustmotion-core/src
- css
- engine/renderer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
94 | 98 | | |
95 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
96 | 118 | | |
97 | 119 | | |
98 | 120 | | |
| |||
108 | 130 | | |
109 | 131 | | |
110 | 132 | | |
111 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
112 | 137 | | |
113 | 138 | | |
114 | 139 | | |
| |||
119 | 144 | | |
120 | 145 | | |
121 | 146 | | |
122 | | - | |
| 147 | + | |
123 | 148 | | |
124 | 149 | | |
125 | 150 | | |
| |||
185 | 210 | | |
186 | 211 | | |
187 | 212 | | |
188 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
189 | 223 | | |
190 | 224 | | |
191 | 225 | | |
| |||
198 | 232 | | |
199 | 233 | | |
200 | 234 | | |
201 | | - | |
| 235 | + | |
202 | 236 | | |
203 | 237 | | |
204 | 238 | | |
| |||
248 | 282 | | |
249 | 283 | | |
250 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
251 | 297 | | |
252 | 298 | | |
253 | 299 | | |
| |||
271 | 317 | | |
272 | 318 | | |
273 | 319 | | |
274 | | - | |
| 320 | + | |
275 | 321 | | |
276 | 322 | | |
277 | 323 | | |
| |||
291 | 337 | | |
292 | 338 | | |
293 | 339 | | |
294 | | - | |
| 340 | + | |
295 | 341 | | |
296 | 342 | | |
297 | 343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| |||
115 | 127 | | |
116 | 128 | | |
117 | 129 | | |
118 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
119 | 141 | | |
120 | 142 | | |
121 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
191 | 203 | | |
192 | 204 | | |
193 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
363 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
364 | 384 | | |
365 | 385 | | |
366 | 386 | | |
| |||
386 | 406 | | |
387 | 407 | | |
388 | 408 | | |
389 | | - | |
390 | | - | |
| 409 | + | |
| 410 | + | |
391 | 411 | | |
392 | 412 | | |
393 | 413 | | |
| |||
443 | 463 | | |
444 | 464 | | |
445 | 465 | | |
446 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
447 | 473 | | |
448 | 474 | | |
449 | 475 | | |
| |||
455 | 481 | | |
456 | 482 | | |
457 | 483 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
| 484 | + | |
466 | 485 | | |
467 | 486 | | |
468 | 487 | | |
| |||
0 commit comments