Jia Hao 4ab132f0f2
Load fonts in the order addFont is called (#174253)
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

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

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
2025-09-23 00:51:26 +00:00
..