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: Allow specifying multiple device fonts for text fields #19274

Merged
merged 5 commits into from
Mar 10, 2025

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Jan 18, 2025

When device fonts are used, you can specify a list of font names for a text field, in which case the first one available will be used. No glyph fallback mechanism between fonts on the list is applied.

This is true for both CSS and pure TextFormats.

Additionally some refactors are included.

@kjarosh kjarosh added text Issues relating to text rendering/input A-core Area: Core player, where no other category fits T-compat Type: Compatibility with Flash Player waiting-on-review Waiting on review from a Ruffle team member labels Jan 18, 2025
@kjarosh kjarosh force-pushed the text-font-list branch 2 times, most recently from f8daf5e to 1645906 Compare February 2, 2025 20:23
.first()
{
// Specifying multiple font names is supported only for device fonts.
let font_names: Vec<&str> = font_name.split(",").collect();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this work if you iterated on the split without collecting into a Vec?

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 could do that, sure, but then I'm using the vec to get the fallback font name and IMO it's clearer when I do font_names.first() compared to not collecting into a vec and doing something else.

That matches the behavior of Flash Player and Ruffle Desktop.
kjarosh added 4 commits March 10, 2025 10:18
When device fonts are used, you can specify a list of font names for
a text field, in which case the first one available will be used.
No glyph fallback mechanism between fonts on the list is applied.

This is true for both CSS and pure TextFormats.
This test verifies the behavior of styling with a list of fonts.
@kjarosh kjarosh enabled auto-merge (rebase) March 10, 2025 09:19
@kjarosh kjarosh merged commit 609d095 into ruffle-rs:master Mar 10, 2025
22 checks passed
@kjarosh kjarosh deleted the text-font-list branch March 10, 2025 09:33
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 T-compat Type: Compatibility with Flash Player 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