Skip to content

Implement TextBlock::recreateTextLine and basic multi line support#23215

Draft
evilpie wants to merge 3 commits intoruffle-rs:masterfrom
evilpie:tlf-text-line
Draft

Implement TextBlock::recreateTextLine and basic multi line support#23215
evilpie wants to merge 3 commits intoruffle-rs:masterfrom
evilpie:tlf-text-line

Conversation

@evilpie
Copy link
Copy Markdown
Collaborator

@evilpie evilpie commented Mar 9, 2026

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 textLineCreationResult being "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.

image

@evilpie evilpie added A-avm2 Area: AVM2 (ActionScript 3) fte/tlf Issues relating to the FTE (Flash Text Engine) AVM2 API or TLF (Text Layout Framework) in general llm The PR contains mostly LLM-generated code labels Mar 9, 2026
None => 0,
};

if start >= full_text.len() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can start > full_text.len() ever be true?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ==.

@Lord-McSweeney
Copy link
Copy Markdown
Collaborator

#15159 seems to hang with this PR

@evilpie evilpie marked this pull request as draft March 9, 2026 19:20
@danielhjacobs
Copy link
Copy Markdown
Contributor

Temporarily switched https://new.weedtowonder.org/ to be built from this branch, can confirm significant improvements.
weedtowonder_current.zip
weedtowonder_PR.zip

@evilpie
Copy link
Copy Markdown
Collaborator Author

evilpie commented Mar 10, 2026

#15159 seems to hang with this PR

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 getAtomIndexAtCharIndex and getAtomTextBlockEndIndex always returning zero means it just got stuck inside the loop.

@danielhjacobs
Copy link
Copy Markdown
Contributor

Screenshot From 2026-03-11 09-41-18 For the failing test, left is Linux with this PR, middle is Adobe Flash Player, and right is the expected image in the repo right now. I think it's fair to say it's not really a regression. It seems like there's a preference for using Flash output or if the Flash output is too different marking the test a known failure and still including the Flash output in the repo, so it may be best to change the test accordingly.

@danielhjacobs
Copy link
Copy Markdown
Contributor

For completeness, here are the pages above (screenshots with current Ruffle and this PR) taken from Flash's output.
weedtowonder_Flash.zip

@kjarosh
Copy link
Copy Markdown
Member

kjarosh commented Mar 11, 2026

For the failing test, left is Linux with this PR, middle is Adobe Flash Player, and right is the expected image in the repo right now. I think it's fair to say it's not really a regression. It seems like there's a preference for using Flash output or if the Flash output is too different marking the test a known failure and still including the Flash output in the repo, so it may be best to change the test accordingly.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm2 Area: AVM2 (ActionScript 3) fte/tlf Issues relating to the FTE (Flash Text Engine) AVM2 API or TLF (Text Layout Framework) in general llm The PR contains mostly LLM-generated code newsworthy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants