yonat/systemfontoverride
Easy font branding for your iOS app.
Features
- Override the default system font with your own branded font.
- Compatible with both UIKit and SwiftUI.
- Simple and intuitive API for quick integration.
Usage
Instant font branding, automatically overriding system font:
UIFont.systemFontFamilyOverride = "Marker Felt" // replace with appropriate fontExplicitly specify font in UIKit:
someUIKitElement.font = .systemFontOverride(size: 16)Explicitly specify font in SwiftUI:
someSwiftUIView
.font(.systemOverride(size: 16))Installation
CocoaPods:
pod 'SystemFontOverride'Swift Package Manager:
dependencies: [
.package(url: "https://github.com/yonat/SystemFontOverride", from: "1.0.0")
]Limitations
Most UI elements will just work with the override font.
However, a few elements completely ignore the override:
- Sheet presented by
ColorPickerorUIColorWell
Additionally, some SwiftUI controls require explicit .font() modifier to update their title font:
PickerMenuToggleborderedandborderedProminentbutton stylesLabelin some contexts
See the Demo app for details.
Mechanism
To automatically override the system font, SystemFontOverride uses method swizzling for UIFont.systemFont(ofSize:) and related methods.
Segmented controls and UITextField ignore the system font override, but their appearance() proxy correctly sets their titles to the override font.
[swift-image]:https://img.shields.io/badge/swift-5.0-orange.svg [swift-url]: https://swift.org/ [license-image]: https://img.shields.io/badge/License-MIT-blue.svg [license-url]: LICENSE.txt
Package Metadata
Repository: yonat/systemfontoverride
Default branch: main
README: README.md