Repository navigation
Follow the Bold Text and Increase Contrast settings - #36
Merged
servercimen merged 12 commits intoNov 24, 2026
Merged
Conversation
The style has an internal Bold Text state that the font cache key includes. When it is on, system fonts take a heavier weight: regular becomes semibold, and bold becomes heavy. The default code font takes its bold face. Named fonts keep their own weight. The new followsBoldText property turns this off. It is on by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TranscriptTextView gives layout its style with the Bold Text state of its trait collection. It observes the legibility weight trait, and it lays out again when the change gives other fonts. The public style does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TranscriptColor keeps a light and a dark value for Increase Contrast too. The UIColor initializer resolves them, so system colors keep their high-contrast values. init(light:dark:) takes optional high-contrast colors. Drawing takes a highContrast flag next to the dark flag, and the view resolves the style colors for the contrast of its traits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TranscriptTextView observes the accessibility contrast trait with the appearance and display scale traits. A change redraws the text in the colors for the new contrast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README says how the text follows the Bold Text setting and how to turn that off. It also says that colors keep Increase Contrast values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The heavier weight now comes from the declared weight of the font, not from the weight of the font that the system gives. If the system already gives a heavy enough font for Bold Text, the font stays as it is, and the weight does not go up two times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lazy stack can measure a row and not place it. The row has no width, so a style change did not reach the layout engine. The engine then laid out new text in the old style, the view dropped each result, and the row kept its old height. The engine now takes a new style at the width that it already lays out at. The view gives the engine the new style, and asks SwiftUI to measure the row again after a Bold Text change. sizeThatFits uses the installed layout only when its style is the current one. The empty layout follows the style too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The style now keeps the Bold Text setting itself, and followsBoldText decides whether layout uses it. Both go in the font cache key. If the system fonts change with the setting, fonts made with the setting on are not used with it off, also when followsBoldText is false. withBoldText(_:) is public, so an app that lays out a DocumentLayout itself can follow Bold Text too. The LaTeX fallback font of a formula now comes from the cache. The documentation now says that bold code looks the same as other code with the default code font, and how a system code font keeps it heavier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The internal draw has no default for highContrast now, as it has none for dark. The fade cache check is on two lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A view can lose its width, see a style or Bold Text change, and then get the same width back. It now lays out again when the installed layout has another style. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DocumentLayout.draw: the doc comment keeps the style colors and the Increase Contrast values. TranscriptStyle.font(for:traits:weight:): the font cache key keeps the weight and the Bold Text fields. TranscriptStyle.mathFallbackFont(size:): the font cache key gives no weight. DocumentLayout: the style colors for quote bars, table headers, quote text and task boxes get the Increase Contrast state. TranscriptStyle.makeFont: Bold Text starts from the weight of a list number or a table header, with a new test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part 6 of a stack of 13 pull requests. The base is #35 (
feature/math-image-reuse). #31 (part 1) tells how to merge the stack.On this stacked branch,
swift testpasses (260 tests), and the iOS build and build-for-testing pass.Summary
Bold Text and Increase Contrast are accessibility settings. Before this change, the text view did not follow them. With Bold Text on, the fonts stayed the same while the system text became heavier.
TranscriptColor(UIColor)kept only the light and dark values, so system colors lost their high-contrast values.TranscriptStyle.followsBoldText(defaulttrue). With Bold Text on, system fonts become heavier: weights below semibold go two steps up, and heavier weights go one step, to at most black. Regular text becomes semibold, and bold text becomes heavy. A named font keeps its weight.codeFont, such asTranscriptFont(size: 15, monospaced: true), keeps bold code heavier. The README tells this.TranscriptStyle.withBoldText(_:)for an app that lays out aDocumentLayoutitself. The setting is part of the font cache key and of==.TranscriptTextViewobservesUITraitLegibilityWeightand lays out again when it changes. The publicstyledoes not change. A lazy-stack row that is measured but not placed yet, and a view that gets its width back, also get the new style.TranscriptColorkeeps four values: light, dark, and a high-contrast value for each.TranscriptColor(UIColor)resolves all four.init(light:dark:highContrastLight:highContrastDark:)has two new optional arguments.DocumentLayout.draw(in:dirtyRect:text:codeBackground:accent:dark:highContrast:)has a newhighContrastargument (defaultfalse).TranscriptTextViewobservesUITraitAccessibilityContrastand draws again, also the streaming tail.Tests
swift teston macOS: 192 tests pass. 13 new tests cover the weight steps, the default and named fonts, bold code, the opt-out, the cache key, a style that reaches a row before it is placed, the four color values and a highlight drawn in its high-contrast colors.Checked on an iPhone 12 mini
iOS 27.0, in a check screen in a local test app. Trait overrides on the window scene stand in for the two settings. The first runs were on main. Main showed the problem in the first three items. The numbers come from the last runs of each build.
UILabels next to it become heavier. The branch draws again in 44 to 51 ms: body.SFUI-Semibold, bold and heading.SFUI-Heavy, codeMenlo-Bold. The body text is 113.87 pt wide, the same as aUILabel. The fonts go back to the main fonts when the trait goes off. WithfollowsBoldText = false, the fonts do not change.systemBlueandsystemGray5. The branch draws the high-contrast values thatUIColorgives.LazyVStackrow that is empty or off screen at the change gets a height equal to its layout.Other stand-ins:
overrideUserInterfaceStylefor dark mode, andsetContentOffsetfor scrolling.Not checked
UIFont.systemFontandCTFontCreateUIFontForLanguagedid not change. So the check did not show that the weight goes up only one time, or that the cache keeps the fonts of the two settings apart.UILabelmakes these weights two steps heavier. The code of this branch makes them one step heavier.🤖 Generated with Claude Code