fix: Recalculate bounding boxes after fonts load - #8094
Merged
Merged
Conversation
camdecoster
marked this pull request as ready for review
September 30, 2026 23:17
alexcjohnson
reviewed
Oct 1, 2026
alexcjohnson
reviewed
Oct 1, 2026
| */ | ||
| async function redrawAfterFontLoads(gd, unloadedFaces) { | ||
| // The draw started these loads, or they finished during the draw | ||
| const faces = unloadedFaces.filter((face) => ['loaded', 'loading'].includes(face.status)); |
Collaborator
There was a problem hiding this comment.
So the other options apparently are unloaded and error (or possibly failed, MDN is inconsistent about this). Makes sense to ignore errors at this point, as there's nothing more to wait for. Can we be confident that every relevant font will have been transitioned from unloaded to loading synchronously? I guess we have to assume this, as looking at an existing site I see various fonts staying indefinitely in the unloaded state, presumably because it was declared but never used on the page.
Contributor
Author
There was a problem hiding this comment.
I think we can be confident in this. That's why my testing showed. If real world use tells a different story, we can tweak the check (or force the fonts to load ourselves).
alexcjohnson
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Recalculate bounding boxes after fonts load to ensure they are sized properly.
Closes #8089.
Changes
Screenshots
Testing
Notes
plotly_beforeplotandplotly_afterplotagaindocument.fonts.readydoes not work for this, because ready does not start the load of a font that no text uses yetloadingdoneevent on the document fontsgl-axes3dcaches each label mesh by font family for the life of the page, sogl3dlabels keep the fallback font after the redraw.