Make font-holding config structs Sendable via SendableFont wrapper - #125
Draft
Jun Yan (junyan72) wants to merge 2 commits into
Draft
Make font-holding config structs Sendable via SendableFont wrapper#125Jun Yan (junyan72) wants to merge 2 commits into
Jun Yan (junyan72) wants to merge 2 commits into
Conversation
Introduce an internal SendableFont value type that centralizes the @unchecked Sendable assertion for MDFont (UIFont/NSFont). TextFonts, MarkdownInlineTextStyle, and CitationConfig now store SendableFont privately and expose their existing public MDFont API via computed accessors, so they are plainly Sendable without a per-struct unchecked assertion and without leaking a retroactive Sendable conformance onto the platform font types. Closes #124 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR centralizes the single @unchecked Sendable assertion needed for platform fonts (UIFont/NSFont) into an internal SendableFont wrapper so public configuration types can remain plainly Sendable under strict concurrency without scattering @unchecked Sendable across multiple structs.
Changes:
- Added internal
SendableFontwrapper that holdsMDFontand carries the only@unchecked Sendableconformance. - Updated
TextFontsto store fonts privately asSendableFont/SendableFont?while preserving the existing publicMDFontAPI via computed accessors. - Updated
MarkdownRenderConfig.MarkdownInlineTextStyleandMarkdownRenderConfig.CitationConfigto use privateSendableFontstorage and computedMDFontaccessors, keeping public initializer signatures and types unchanged.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Sources/MarkdownText/Utilities/SendableFont.swift | Introduces a single internal wrapper type that centralizes the unchecked Sendable assertion for platform fonts. |
| Sources/MarkdownText/Style/TextFonts.swift | Moves stored font variants to private SendableFont backing storage while exposing the same public MDFont-typed API. |
| Sources/MarkdownText/Models/MarkdownRenderConfig.swift | Updates inline text style and citation config to store fonts via SendableFont backing fields and keep public MDFont accessors/initializers. |
Use internal-prefixed property names (internalNormal, internalFont, etc.) instead of a leading underscore for the private SendableFont storage, per repo naming convention. Refs #124 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jun Yan (junyan72)
marked this pull request as draft
July 7, 2026 22:11
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.
Summary
Make the font-holding configuration structs safely
Sendableunder strict concurrency by centralizing the unchecked assertion in a single internal wrapper, instead of applying@unchecked Sendableto each struct.SendableFontvalue type (Utilities/SendableFont.swift) that wrapsMDFont(UIFont/NSFont) and carries the sole@unchecked Sendableassertion, documented in one auditable place.TextFonts,MarkdownRenderConfig.MarkdownInlineTextStyle, andMarkdownRenderConfig.CitationConfignow storeSendableFontprivately and expose their existing publicMDFontAPI via computed accessors. The structs stay declaredHashable, Sendable(unchanged public surface, no@unchecked).MDFontremains the native alias everywhere in the rendering path (NSAttributedStringboundaries, font metrics) and in tests.Sendableconformance onto the platform font types.Closes #124
Validation
xcodebuild build -scheme SwiftStreamingMarkdown -destination "platform=iOS Simulator,name=iPhone 17" -skipMacroValidation SWIFT_STRICT_CONCURRENCY=complete— BUILD SUCCEEDED, zero errors and zero font/SendableFontSendable warnings (remaining strict-concurrency warnings are unrelated: LaTeX regexes, view controllers, TableView mocks).swiftlint --stricton the three changed/added files — 0 violations.MDFontfactory methods, which still resolve to the native font type.OSS readiness