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 layout measurements #18332

Merged
merged 10 commits into from
Oct 22, 2024
Merged

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Oct 20, 2024

This patch fixes various measurements made during laying out text.

  1. After laying out a line, the cursor should be advanced by the value of ascent + descent + leading, not font_size + font_leading + leading.

  2. Font leading is ignored.

  3. Proper line bounds (not interior bounds) are now used for calculating exterior text bounds.

Additionally, it updates the following tests, as their output now is more similar to the output produced by the Flash Player:

  1. avm2/away3d_advanced_shallow_water_demo
  2. visual/definefont4
  3. visual/fonts/device-font
  4. visual/shumway_acid_tests/acid
  5. visual/shumway_acid_tests/acid_text

In general, this PR should make a lot of text look so much better, especially multiline text fields.

@kjarosh kjarosh added text Issues relating to text rendering/input A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) labels Oct 20, 2024
@kjarosh kjarosh marked this pull request as draft October 20, 2024 19:19
@kjarosh kjarosh force-pushed the text-layout-measurements branch 2 times, most recently from 9019b83 to a2326d8 Compare October 20, 2024 21:12
@kjarosh kjarosh marked this pull request as ready for review October 20, 2024 21:23
@kjarosh kjarosh force-pushed the text-layout-measurements branch 2 times, most recently from b0d251c to a0e448e Compare October 20, 2024 21:34
@kjarosh
Copy link
Member Author

kjarosh commented Oct 21, 2024

After this PR I was able to make epsilons smaller in 7 tests, and remove approximations altogether in 5 tests 🎉

This effectively changes nothing, as text exterior bounds are used only
for size measurement, but it makes their debug boxes render
in a proper position.
These two methods were doing almost the same thing,
no need to duplicate code.
This patch fixes various measurements made during laying out text.

1. After laying out a line, the cursor should be advanced by the value of
   `ascent + descent + leading`, not `font_size + font_leading + leading`.

2. Font leading is ignored.

3. Proper line bounds (not interior bounds) are now used for calculating
   exterior text bounds.

Additionally, it updates the following tests, as their output now
is more similar to the output produced by the Flash Player:

1. avm2/away3d_advanced_shallow_water_demo
2. visual/definefont4
3. visual/fonts/device-font
4. visual/shumway_acid_tests/acid
5. visual/shumway_acid_tests/acid_text
This test verifies how the test height is
calculated in relation to leading.
This test verifies how FP renders text when the font has leading and
it's a device font.
This test verifies how FP renders text when the font has leading and
it's an embedded font.
This test verifies how FP renders text when the font has leading,
dependeing on different DefineFont tags used.
Some of epsilons now can be smaller!
Ruffle now produces the exact same output as FP in these tests!
@kjarosh kjarosh merged commit 682f3c6 into ruffle-rs:master Oct 22, 2024
17 checks passed
@kjarosh kjarosh deleted the text-layout-measurements branch October 22, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core player, where no other category fits newsworthy T-fix Type: Bug fix (in something that's supposed to work already) text Issues relating to text rendering/input
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants