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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

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.

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.
@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
These two methods were doing almost the same thing,
no need to duplicate code.
@kjarosh kjarosh marked this pull request as ready for review October 20, 2024 21:23
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.
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.

1 participant