Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text: Fix caret positioning in empty text fields #17319

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Jul 31, 2024

Fixes #14716, fixes #3802, progresses #10852.

Before After

Summary of changes:

  • the test avm1/edittext_scroll is fixed — it used device fonts, now Noto Sans has been embedded,
  • code related to drawing a caret when there's no layout boxes has been deleted, as it's outdated,
  • max font size is now being reset on newlines, which fixes line height in multiline text fields with varying font sizes and a span spanning across multiple newlines (that was the case in avm1/edittext_scroll of course),
  • empty boxes take into account alignment adjustments, which fixes positioning of the caret in empty fields and empty lines.

@kjarosh kjarosh added the text Issues relating to text rendering/input label Jul 31, 2024
@kjarosh kjarosh changed the title text: Fix caret rendering in empty text fields text: Fix caret positioning in empty text fields Jul 31, 2024
@kjarosh kjarosh added the waiting-on-review Waiting on review from a Ruffle team member label Jul 31, 2024
@Dinnerbone Dinnerbone force-pushed the edittext-caret-empty branch from 390600a to 9617cb3 Compare July 31, 2024 09:55
kjarosh added 5 commits August 2, 2024 17:07
This test used device fonts, this patch embeds Noto Sans
and uses it instead.
That condition related to drawing a cursor when there are no boxes is
outdated, as currently it's guaranteed that there's at least one box.

FormatSpans.normalize() ensures that there's at least one span, and
LayoutContext.fixup_line() ensures that each line has at least one box.
Before this patch, max font size (which claimed to be the highest font
size observed within the current line) was calculated for each span,
regardless of newlines.
This patch fixes how empty text boxes are laid out.
The empty boxes are now added during line fixup, and not after,
which ensures they are subjected to alignment and other adjustments.
This test verifies how the caret in a text field is rendered when
the text field is empty.
@kjarosh kjarosh force-pushed the edittext-caret-empty branch from 9617cb3 to 32561b1 Compare August 2, 2024 15:07
@kjarosh kjarosh merged commit 815bc3b into ruffle-rs:master Aug 2, 2024
16 of 17 checks passed
@kjarosh kjarosh deleted the edittext-caret-empty branch August 2, 2024 15:56
@kjarosh kjarosh removed the waiting-on-review Waiting on review from a Ruffle team member label Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
text Issues relating to text rendering/input
Projects
None yet
2 participants