Skip to content

Conversation

@kjarosh
Copy link
Member

@kjarosh kjarosh commented Nov 11, 2025

Device text in FP cannot be scaled independently in x/y. Only the y scale is applied, and the x scale is set so that the aspect ratio of characters is preserved. It's used only for calculating metrics and sizing bounds.

This PR contains a bunch of patches that bring us closer to FP's behavior. We're still not perfect, especially related to measurements, but the good news is that it's a mess in Flash Player too, just a different one.

The main issue with dependent x/y scaling is that measurements operate in unscaled coordinate space, meaning that we have to emulate the size of the unscaled glyphs. If scaleX/scaleY == 0.5, we have to act as if glyphs were twice as wide.

After this PR Ruffle still behaves differently, especially related to:

  1. y metrics (which are "broken" in FP, but they work "properly" in Ruffle),
  2. laying out text (which is broken in Ruffle, but works properly in FP),
  3. negative scales (I don't even know where they are broken anymore),
  4. small sizes (less than gutters, i.e. <4px, but no one uses that realistically).

This is needed as this transformation applies device-text specific
scaling.
This makes sure that the device-text specific transforms are applied.
Device text requires non-translation-only transformations in the
layout_to_local_matrix, which requires the generic inverse() function
to be called when calculating its inverse.
Device text in FP cannot be scaled independently in x/y. Only the y
scale is applied, and the x scale is set so that the aspect ratio of
characters is preserved. It's used only for calculating metrics and
sizing bounds.
Tests basic translations applied to device text.
@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 device-fonts Issues related to device fonts. They are usually very system-dependent. waiting-on-review Waiting on review from a Ruffle team member newsworthy labels Nov 11, 2025
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 device-fonts Issues related to device fonts. They are usually very system-dependent. newsworthy 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

1 participant