Skip to content

Add AttributedString.emphasizing helper to FuturedHelpers - #67

Closed
janpollak wants to merge 1 commit into
mainfrom
feature/attributed-string-emphasis
Closed

janpollak wants to merge 1 commit into
mainfrom
feature/attributed-string-emphasis

Conversation

@janpollak

Copy link
Copy Markdown
Contributor

Shared helper for the recurring "localized template + emphasize one substring" AttributedString pattern (bolding an email in a sentence, etc.), which several apps have each reimplemented locally.

  • AttributeContainer.stronglyEmphasized — bold default via inlinePresentationIntent (an intent, not a pinned font, so it renders bold in SwiftUI Text + UIKit and survives Dynamic Type).
  • AttributedString.emphasizing(_:in:with:) — applies an AttributeContainer (default .stronglyEmphasized) to the first occurrence of the substring; returns the template unchanged when the substring is empty or absent.
  • AttributedString.emphasizing(_:in:style:) — TextStyle overload built on the existing stylize(with:), #if canImport(UIKit)-gated to match TextStyle.

Tests cover both overloads (macOS for the container API, iOS for the TextStyle path). Verified with swift test and xcodebuild build-for-testing -destination 'generic/platform=iOS Simulator'; SwiftLint clean.

Shared helper for the recurring "localized template + emphasize one
substring" pattern, so apps stop reimplementing it locally.

- AttributeContainer.stronglyEmphasized — bold default via
  inlinePresentationIntent (intent, not a pinned font).
- AttributedString.emphasizing(_:in:with:) — takes an AttributeContainer,
  defaulting to .stronglyEmphasized.
- AttributedString.emphasizing(_:in:style:) — TextStyle overload built on
  stylize(with:), #if canImport(UIKit) gated to match TextStyle.
@janpollak janpollak closed this Jul 1, 2026
@jmarek41
jmarek41 deleted the feature/attributed-string-emphasis branch September 4, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant