Skip to content

Load fonts in the order addFont is called #174253

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jiahaog
Copy link
Member

@jiahaog jiahaog commented Aug 22, 2025

Before this change, load loads fonts in a non-deterministic order. After this change, it loads the fonts sequentially.

See cl/797583429 for the full context. We found that the order of how fonts load for a specific font family actually affects runtime behavior, and the current non-deterministic order of loading fonts leads to flakiness.

Consider the following:

  • foo.ttf has glyphs 'A' and 'B'
  • foo-italic.ttf only has glyph 'B'

If addFont(foo-italic.ttf) is called before addFont(foo.ttf), the font loader will load foo-italic.ttf first and use that as the base font. When looking for the 'A' glyph, it may will look for the glyph only in foo-italic.ttf, which doesn't have it, and will show an incorrect empty placeholder glyph.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 22, 2025
@jiahaog jiahaog force-pushed the font-load-ordering branch from 87f37d9 to d106b2a Compare August 22, 2025 04:13
@jiahaog jiahaog marked this pull request as ready for review August 22, 2025 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant