SystemFontOverride 1.0.0

SystemFontOverride 1.0.0

Maintained by Yonat Sharon.



  • By
  • Yonat Sharon

SystemFontOverride

Easy font branding for your iOS app.

Swift Version License CocoaPods Compatible Platform PRs Welcome

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 font

Explicitly 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 ColorPicker or UIColorWell

Additionally, some SwiftUI controls require explicit .font() modifier to update their title font:

  • Picker
  • Menu
  • Toggle
  • bordered and borderedProminent button styles
  • Label in 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.