Ios Custom Font Dynamic Type
Custom fonts must be scaled with Dynamic Type by registering them via UIFontMetrics.scaled(for:) in UIKit or Font.custom(_:relativeTo:) in SwiftUI, anchored to a semantic text style.
$ aoe install @community/rule-ios-custom-font-dynamic-type Projection
Always in _index.xml · the agent never has to ask for this.
IosCustomFontDynamicType [rule] v1.0.0
Custom fonts must be scaled with Dynamic Type by registering them via UIFontMetrics.scaled(for:) in UIKit or Font.custom(_:relativeTo:) in SwiftUI, anchored to a semantic text style.
Loaded when retrieval picks the atom as adjacent / supporting.
IosCustomFontDynamicType [rule] v1.0.0
Custom fonts must be scaled with Dynamic Type by registering them via UIFontMetrics.scaled(for:) in UIKit or Font.custom(_:relativeTo:) in SwiftUI, anchored to a semantic text style.
Meta
- License: MIT AND Apache-2.0
- License Provenance: legacy-backfill
Applies To
all non-system typefaces used in an iOS app
Loaded when retrieval picks the atom as a focal / direct hit.
IosCustomFontDynamicType [rule] v1.0.0
Custom fonts must be scaled with Dynamic Type by registering them via UIFontMetrics.scaled(for:) in UIKit or Font.custom(_:relativeTo:) in SwiftUI, anchored to a semantic text style.
Meta
- License: MIT AND Apache-2.0
- License Provenance: legacy-backfill
Applies To
all non-system typefaces used in an iOS app
Examples
- SwiftUI: Font.custom('BrandSans', size: 17, relativeTo: .body) — scales with the body text style.
- UIKit: UIFontMetrics(forTextStyle: .body).scaledFont(for: UIFont(name: 'BrandSans', size: 17)!).
- Verify: set Dynamic Type to a large size in Settings → Accessibility; custom-font text must grow proportionally.
Relations
related: [@community/rule-ios-dynamic-type-semantic, @community/rule-ios-dynamic-type-reflow, @community/constraint-ios-text-min-17pt]
Rationale
Custom fonts that do not scale break accessibility for users who rely on larger text sizes. UIFontMetrics and Font.custom(_:relativeTo:) are the only correct hooks for propagating Dynamic Type scale to a non-system typeface.
Meta
- License: MIT AND Apache-2.0
- License Provenance: legacy-backfill
Applies To
all non-system typefaces used in an iOS app
Source
aoe-engine/examples/frontend-design/primes/compiled/@community/rule-ios-custom-font-dynamic-type/atom.yaml