Implement TextBlock::recreateTextLine and basic multi line support#23215
Implement TextBlock::recreateTextLine and basic multi line support#23215evilpie wants to merge 3 commits intoruffle-rs:masterfrom
Conversation
| None => 0, | ||
| }; | ||
|
|
||
| if start >= full_text.len() { |
There was a problem hiding this comment.
Can start > full_text.len() ever be true?
There was a problem hiding this comment.
So you mean we would usually assume that we either previously consumed less than or at most equal to the length of the full_text? That makes sense. But currently you can still pass random TextLines into that function, which means that property doesn't hold. I imagine when we add more checks we could maybe soften this to ==.
|
#15159 seems to hang with this PR |
|
Temporarily switched https://new.weedtowonder.org/ to be built from this branch, can confirm significant improvements. |
Due to the multiple lines we are now executing other code and hanging in this code: https://github.com/apache/flex-sdk/blob/7c47bb9b10c7ca3643079be21597cde022f1bfe1/frameworks/projects/spark/src/spark/components/Label.as#L1544-L1565. Basically |
|
For completeness, here are the pages above (screenshots with current Ruffle and this PR) taken from Flash's output. |
Maybe I'm missing something but it looks like a significant regression? The text looks cut off at the descender, which also means the line would disappear when we implement FP's text culling logic. |

Improves #10173
This implements pretty basic multi-line support for FTE's TextBlock. Most of the code was written by Claude using the Weed to Wonder as a test case.
It works by first applying the current format and then measuring the number of characters that fit into the first line. The created TextLine is then limited to the number of chracters that fit. Based on the
textLineCreationResultbeing "success" (line created) or "completed" (all remaining text fit into the current line, no more lines needed) the caller (flashx) decides whether to create new lines or not.recreateTextLine allows re-layouting a specific line after changing its width. Which means it might fit more or less text than before.