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 getCharBoundaries() for 0-width characters #18860

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

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Dec 4, 2024

Basically, getCharBoundaries() returns null for 0-width characters. This PR also fixes a bug where some characters (with missing glyphs) were not taken into account properly because Font::evaluate skipped them.

@kjarosh kjarosh added text Issues relating to text rendering/input A-avm2 Area: AVM2 (ActionScript 3) T-fix Type: Bug fix (in something that's supposed to work already) labels Dec 4, 2024
@kjarosh kjarosh marked this pull request as draft December 4, 2024 21:35
@kjarosh kjarosh added the waiting-on-review Waiting on review from a Ruffle team member label Dec 5, 2024
@@ -613,6 +619,9 @@ impl<'gc> Font<'gc> {
// Step horizontally.
transform.matrix.tx += twips_advance;
x += twips_advance;
} else {
// No glyph, zero advance
glyph_func(pos, &transform, &Glyph::empty(), Twips::ZERO, x);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the difference between processing a "noop" glyph and skipping it entirely?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've described it in my commit message:

This is a natural assumption of Font::evaluate and makes writing code easier.
Code that renders glyphs will work the same way as non-renderable characters
will produce empty glyphs, but code that evaluates the font for measurement
purposes will use this property.

I'll add a short comment about it here too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@kjarosh kjarosh force-pushed the evaluate-missing-glyphs branch from 2a8e0c7 to ff00d12 Compare December 12, 2024 21:48
This is a natural assumption of Font::evaluate and makes writing code easier.
Code that renders glyphs will work the same way as non-renderable characters
will produce empty glyphs, but code that evaluates the font for measurement
purposes will use this property.
@kjarosh kjarosh force-pushed the evaluate-missing-glyphs branch from ff00d12 to d8404e7 Compare December 19, 2024 20:07
This test verifies how getCharBoundaries() works when glyphs are missing.
This test verifies how getCharBoundaries() works when glyphs are missing
due to embedded font not being present.
@kjarosh kjarosh force-pushed the evaluate-missing-glyphs branch from d8404e7 to 89c2faa Compare December 19, 2024 21:53
@kjarosh kjarosh requested a review from adrian17 December 19, 2024 21:58
@kjarosh kjarosh marked this pull request as ready for review December 19, 2024 21:58
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) T-fix Type: Bug fix (in something that's supposed to work already) text Issues relating to text rendering/input waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants