Repository navigation
Fix optimized fallbacks rendering bold and italic text as regular and upright - #18801
astro-factory[bot] wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 0e0e295 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
astro-author owns this pull requestFactory's code author persona works on this branch when a maintainer or Factory's reviewer requests changes, or when checks fail: it pushes follow-up commits, replies to review threads, and asks for another review. It never merges. Unassign astro-author to take the pull request back; reassign it to start a fresh budget. Rounds used: 1 of 5 — astro-author (Factory persona) |
There was a problem hiding this comment.
Verdict: changes requested.
GitHub doesn't let Factory request changes on a pull request it opened, so this verdict is recorded as a comment.
Findings
[medium][correctness]packages/astro/src/assets/fonts/core/optimize-fallbacks.ts:76: Bold text still renders regular when a face's declared weight reaches the bold range but maps to a regular local font. Details are in the inline comment.
Merge Requirement Assessment
Status: gaps found
Italic/oblique fallback faces are no longer emitted: met.deriveFallbackVariantreturnsnullfor non-normal styles, and faces with no local fonts are skipped (line 116). The updated grouping test checks this.Bold faces that would only map to a regular system font are not emitted (e.g. monospace): met for theboldvariant only (line 76). The newskips bold faces when the bold variant only has regular local fontstest checks this. Faces in thenormalvariant whose declared weight is 600 or more, or is a range that reaches 600, still have the same problem. See the finding.Weight variants for the same system font share one family so Arial Bold is reachable for 700 text: met.familyFonttakes its name from the normal list at the same index, andfallbacksusesuniqueFamilyFonts. The updated sans-serif assertions check this, and thesystem-uilists line up by index.Bold and italic text renders correctly in the optimized fallback (#18796): partly met. Variable-weight and semibold faces still render regular (see the finding).
Review Status
Verdict: changes required
Context: PR #18801 description (I couldn't retrieve linked issue #18796 with the available tools)
Scope: base c302892e to head 2121e0cb, 3 files.
Changeset: present and covers astro (patch).
Limitations: I couldn't read issue #18796 or the PR discussion. My reasoning about browser font-synthesis behaviour comes from the CSS Fonts matching and synthesis rules, not from running anything.
Validation: Static review only; no project code, tests, builds, or checks were run.
GitHub context: collected (PR metadata and diff only)
Git scope: PR base/head verified
This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.
Merging this PR will not alter performance1 warning, 1 note
Comparing Footnotes |
Faces whose declared weight reaches the bold range (e.g. 600 or "100 900") but resolve to a regular system font would match bold text and render it regular. Cap their emitted font-weight at 500 so browsers synthesize bold.
|
Round 1 of 5: applied the requested changes I fixed the bug where faces mapped to a regular local font could still declare a bold-capable weight. For those faces, the fallback I added a unit test that checks the emitted Checks:
One thing to review: the 500 limit is based on my understanding of when Chromium and Firefox synthesize bold (Chromium when the face is below 600, Firefox when it is at most 500, so 500 works for both). I haven't checked this in a browser. Tradeoff: a Pushed These changes were made by an LLM. They may be wrong; review them like any other contribution. |
There was a problem hiding this comment.
Verdict: approved. No blocking findings remain.
GitHub doesn't let Factory approve a pull request it opened, so this verdict is recorded as a comment.
Findings
No findings.
Merge Requirement Assessment
Status: satisfied
- Bold faces shouldn't point at regular local fonts (issue #18796). In
optimize-fallbacks.ts, a non-normal variant entry is now dropped when its local font also appears in the provider'snormallist. The monospace stack has no bold entry, so a 700 face that would only map toCourier Newis no longer emitted. Bold text then falls back to the regular face and the browser synthesizes bold. The testskips bold faces when the bold variant only has regular local fontscovers this. - Italic and oblique faces shouldn't be emitted, so the browser can synthesize the slant.
deriveFallbackVariantreturnsnullfor any style other thannormal, and faces with no remaining local fonts are skipped. The testgroups bold faces under the normal fallback family and skips italic facescovers this. - Weight variants for the same system font should share one family, so
Arial Boldis reachable at weight 700. Each local font is paired with the normal-list font at the same position (familyFont), and only one prepended family name is emitted per position. Withsystem-ui, the bold list'sArial Bold(position 4) lands under theArialfamily as intended, and fonts the bold list shares with the normal list are filtered out. Updated assertions check both the facenameand thesrcfont. - Normal faces shouldn't declare bold-capable weights.
capWeightcaps numeric weights and ranges at 500 for normal-variant faces. This covers ranges like100 900and single weights like 600, which would otherwise block bold synthesis. Non-numeric weights andundefinedpass through unchanged, andrenderFontWeightrenders array weights correctly. The testcaps the weight of faces backed by regular local fonts…covers the string-range, array-range, numeric and in-range cases.
Review Status
Verdict: ready to merge based on static review
Context: PR #18801 plus its description and linked issue #18796 (as referenced in the PR body)
Scope: PR #18801, base c302892e → head 0e0e2954 (3 files).
Changeset: present and covers astro (patch).
Limitations: Only the provided read-only PR file tools were available. I didn't open issue #18796 itself; I took the requirements from the PR description.
Validation: Static review only. No project code, tests, builds or checks were run.
GitHub context: supplied only
Git scope: PR base/head verified
This review was made by an LLM. The analysis may be wrong, and reports might be incorrect.
Changes
optimizeFallbacks()emitted@font-facerules that declaredfont-weight: 700orfont-style: italicwhile pointingsrcat a regular, upright local font (e.g.local("Courier New")). That declaration suppresses the browser's bold/oblique synthesis, causing the text to render regular and upright until the web font loads — or permanently when web fonts are blocked.Arial Boldis reachable forfont-weight: 700text instead of being shadowed by the earlierArial-only family. The browser synthesizes bold or oblique from the regular local face in cases where no heavier/slanted system font is available.Testing
packages/astro/test/units/assets/fonts/core.test.tsto cover the corrected face-grouping and face-omission logic, verifying that italic faces and weight-only-matched bold faces pointing to regular fonts are dropped from the generated@font-faceoutput.Docs
Closes #18796