Skip to content

Commit

Permalink
Fix layout update on font load
Browse files Browse the repository at this point in the history
This fixes 2 bugs that were manifesting in the following scenario:
1. Text object using a font wider than the default font
2. Text object set to autoWidth AND wrap
3. Text object has a parent layout set to Hug

In these cases, since text objects initially use the default font (while the actual font loads), the layout would measure the width using the default font, however, once the font loaded, we needed to force another update cycle so we could re-measure and update the layout bounds (which should become wider to accomodate the wider text). Since this was not happening, the result was the wider font sometimes wrapping to the next line because its width was constrained by its parent layout.

There are 2 fixes here, once addresses the issue in Dart (simple fix), while the other addresses issues with nested artboards in the editor only (due to dart -> CPP interaction).

Regarding the Dart -> CPP fix for nested artboards, the CPP side appeared to be doing things correctly, marking layout dirty when the font was decoded, however, at that time, the RuntimeMountedArtboard has not been instantiated yet, thus the layoutDirty callback (which the CPP side calls in order to indicate to the Dart side that its layout is dirty) was not set.

The proposed fix for this is:
1. When the RuntimeMountedArtboard is instantiated, active it's nested artboard so we force an update cycle from the Dart side.
2. When setting the layout dirty callback on the nested artboard's CPP Artboard, add ComponentDirt::Components to prevent updateComponents from earlying out.

Diffs=
93e625c1d4 Fix layout update on font load (#9034)
  • Loading branch information
philter committed Feb 17, 2025
1 parent ccd1fa9 commit a7fd388
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a4c0954201bd38aca9f6d65514994d9c9969c9ed
93e625c1d4265f8e36a5b76cd39b16ee77fff622
2 changes: 1 addition & 1 deletion wasm/submodules/rive-runtime

0 comments on commit a7fd388

Please sign in to comment.