A Swift Package providing a curated collection of accessibility-focused fonts for Apple platforms.
AccessibleFonts makes it easy to use fonts designed for accessibility in your Apple platform apps. The package includes six carefully selected font families, each addressing specific readability needs:
| Font | Best For |
|---|---|
| OpenDyslexic | Readers with dyslexia |
| Atkinson Hyperlegible | Users with low vision |
| Lexend | Improving reading fluency |
| Inter | UI elements and screen readability |
| Open Sans | General-purpose readable content |
| Inconsolata | Code and monospace content |
Add AccessibleFonts to your project using Xcode:
- Go to File → Add Package Dependencies...
- Enter the repository URL
- Select the version you want to use
Or add it to your Package.swift:
dependencies: [
.package(url: "https://github.com/ezefranca/AccessibleFonts.git", from: "1.0.0")
]import AccessibleFonts
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, World!")
.font(.accessible(.openDyslexic, size: 17))
Text("Bold Text")
.accessibleFont(.lexend, size: 24, weight: .bold)
}
}
}import AccessibleFonts
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let label = UILabel()
label.font = UIFont.accessible(.atkinsonHyperlegible, size: 17)
label.text = "Easy to read text"
}
}import AccessibleFonts
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let textField = NSTextField()
textField.font = NSFont.accessible(.inter, size: 17)
}
}Fonts are automatically registered when you first use them. No setup required!
// Just use the font - registration happens automatically
Text("Hello").font(.accessible(.lexend, size: 17))If you prefer explicit control:
// Register all fonts at app startup
try AccessibleFonts.registerAll()
// Or register specific families
try AccessibleFonts.register(.openDyslexic)All APIs support Dynamic Type on iOS, iPadOS, tvOS, and watchOS:
// SwiftUI - automatically scales with text style
Text("Headline")
.font(.accessible(.lexend, size: 28, relativeTo: .headline))
// UIKit - uses UIFontMetrics for scaling
let font = UIFont.accessible(.lexend, size: 17, textStyle: .body)// Different weights
Text("Thin").font(.accessible(.inter, size: 17, weight: .thin))
Text("Regular").font(.accessible(.inter, size: 17, weight: .regular))
Text("Bold").font(.accessible(.inter, size: 17, weight: .bold))
Text("Black").font(.accessible(.inter, size: 17, weight: .black))
// Italic (where available)
Text("Italic").font(.accessibleItalic(.inter, size: 17))If a font can't be loaded, the API gracefully falls back to a system font:
- Debug builds: Triggers an assertion failure so you can fix the issue
- Release builds: Silently uses a matching system font
- Weights: Regular, Bold
- Styles: Normal, Italic
- Weights: Regular, Bold
- Styles: Normal, Italic
- Weights: Thin, ExtraLight, Light, Regular, Medium, SemiBold, Bold, ExtraBold, Black
- Styles: Normal only
- Weights: Thin, ExtraLight, Light, Regular, Medium, SemiBold, Bold, ExtraBold, Black
- Styles: Normal, Italic
- Weights: Light, Regular, Medium, SemiBold, Bold, ExtraBold
- Styles: Normal, Italic
- Weights: ExtraLight, Light, Regular, Medium, SemiBold, Bold, ExtraBold, Black
- Styles: Normal only
All included fonts are open source:
- OpenDyslexic, Atkinson Hyperlegible, Lexend, Inter, Open Sans, Inconsolata: SIL Open Font License 1.1
See NOTICE.md for full attribution information.
// Get attribution for a specific font
let attribution = AccessibleFonts.attribution(for: .openDyslexic)
// Get all attributions for credits screen
let allCredits = AccessibleFonts.allAttributions
// Get full license text
if let license = AccessibleFonts.licenseText(for: .lexend) {
print(license)
}Full documentation is available via DocC. Build documentation in Xcode:
- Product → Build Documentation
- Access in the Developer Documentation window
- iOS 15.0+
- macOS 12.0+
- tvOS 15.0+
- watchOS 8.0+
- Swift 6.0+
Check out the Example for a complete SwiftUI demo showcasing all APIs.
Contributions are welcome! Please feel free to submit a Pull Request.
AccessibleFonts is available under the MIT license. See the LICENSE file for more info.
The included fonts are each provided under their respective open source licenses. See NOTICE.md for details.
