All Projects → kgn → KGNPreferredFontManager

kgn / KGNPreferredFontManager

Licence: MIT license
Helper class to registering custom fonts for UIFontTextStyle

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to KGNPreferredFontManager

tiny-ui
⚛️ A friendly UI component set for React.js
Stars: ✭ 202 (+963.16%)
Mutual labels:  uikit
SimplePagedView
A UIPageViewController replacement built to be as simple as possible
Stars: ✭ 77 (+305.26%)
Mutual labels:  uikit
iOS-11-Framer
iOS 11 Design System GUI for Framer
Stars: ✭ 42 (+121.05%)
Mutual labels:  uikit
okeedesign-mobile-vue
High Performance, Flexiable Configuration, Various Components
Stars: ✭ 139 (+631.58%)
Mutual labels:  uikit
stb-truetype-example
Example of how to use stb_truetype library for rendering TrueType fonts.
Stars: ✭ 51 (+168.42%)
Mutual labels:  font
VCore
VCore is a Swift collection containing objects, functions, and extensions that I use for my projects
Stars: ✭ 32 (+68.42%)
Mutual labels:  uikit
swiftui-example
SwiftUI 示例,技巧和技术集合,帮助我构建应用程序,解决问题以及了解SwiftUI的实际工作方式。
Stars: ✭ 109 (+473.68%)
Mutual labels:  uikit
shock
Free business application template, front & dashborad, build on vuetify
Stars: ✭ 16 (-15.79%)
Mutual labels:  uikit
react-native-custom-fonts
React Native Custom Fonts 📚
Stars: ✭ 19 (+0%)
Mutual labels:  font
tk-fangsong-font
剔骨仿宋: Experimental Fang Song style Chinese font
Stars: ✭ 93 (+389.47%)
Mutual labels:  font
electron-markdown-editor
A simple electron markdown editor made with Uikit, Codemirror and markdown-it. Support for MathJax, code highlighting, live preview, and more.
Stars: ✭ 54 (+184.21%)
Mutual labels:  uikit
CoachMarks
UI component to focus the user's attention on parts of the app
Stars: ✭ 37 (+94.74%)
Mutual labels:  uikit
farro
Farro is an artsy, four-weighted, display typeface that has a peculiar personality flowing through its European humanist silhouette.
Stars: ✭ 26 (+36.84%)
Mutual labels:  font
StackableTableView
A UITableView subclass that enables setting an array of views for both headers and footers utilizing UIStackView
Stars: ✭ 72 (+278.95%)
Mutual labels:  uikit
three-font-outliner
Constructing shapes from glyphs at runtime for three.js.
Stars: ✭ 58 (+205.26%)
Mutual labels:  font
FontManager-Module
Font Manager is the premier font and emoji management and changing solution for android.
Stars: ✭ 60 (+215.79%)
Mutual labels:  font
Acy-Font
自制手写字体。A hand-writing font set.
Stars: ✭ 20 (+5.26%)
Mutual labels:  font
mdb-vue-ui-kit
Vue 3 & Bootstrap 5 & Material Design 2.0 UI KIT
Stars: ✭ 887 (+4568.42%)
Mutual labels:  uikit
BJOTPViewController
Entering OTP made simpler.
Stars: ✭ 42 (+121.05%)
Mutual labels:  uikit
brass mono
Retro monospaced font inspired by 70's design.
Stars: ✭ 58 (+205.26%)
Mutual labels:  font

KGNPreferredFontManager

Helper class to registering custom fonts for UIFontTextStyle.

Swift 3 Release License

Build Status Test Coverage Carthage Compatible CocoaPods Version CocoaPods Platforms

Twitter Star Star

iOS 7 introduced the concept of dynamic fonts for accessibility and readability. This library makes it easy to implement these features to help make your app more accessible and readable.

This library also helps keep the fonts in your app consistent by setting a strict set of fonts to use based on the text styles introduced in iOS 7.

Subclasses of UILabel and UIButton are also provided that work with these text styles and the KGNPreferredFontManager to automatically update and resize to the appropriate font size for the user’s text size and accessibility settings. It is recommended that KGNAutoLayout be used in conjunction with this library so that elements resize and adjust appropriately as font sizes change.

Example Gif

Installing

Carthage

github "kgn/KGNPreferredFontManager"

CocoaPods

pod 'KGNPreferredFontManager'

Examples

PreferredFontManager

Create a PreferredFontManager to specify the font sizes to be used when the user changes their accessibility settings.

The following code registers each of the standard text styles with a fontWeight and baseFontSize. This base font size is used for the UIContentSizeCategoryLarge font size and then incremented and decremented by the amounts passed to the increment and decrement properties.

There is an additional property that defines if the incrementing should extend into the extra accessibility size categories. This includeAccessibilitySizes argument is false by default, but is often useful to make sure body text is extra large, like in Messages.app.

There are two versions of this method. One takes fontWeight: CGFloat, which is a UIFontWeight... constant introduced in iOS 8.2. The other takes fontName: String which is a the name of the font, either a system one or a custom one.

fontWeight(iOS 8.2+)

Check out the Example app provided to see this in action.

PreferredFontManager.sharedManager.registerFonts(forTextStyle: .headline, fontWeight: UIFontWeightUltraLight, baseFontSize: UIFont.systemFontSize*4, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .subheadline, fontWeight: UIFontWeightRegular, baseFontSize: UIFont.systemFontSize*2, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .body, fontWeight: UIFontWeightRegular, baseFontSize: UIFont.labelFontSize, increment: 2, decrement: 1, includeAccessibilitySizes: true)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .caption1, fontWeight: UIFontWeightMedium, baseFontSize: UIFont.systemFontSize, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .caption2, fontWeight: UIFontWeightRegular, baseFontSize: UIFont.systemFontSize, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .footnote, fontWeight: UIFontWeightRegular, baseFontSize: UIFont.smallSystemFontSize, increment: 1, decrement: 1)

fontName

PreferredFontManager.sharedManager.registerFonts(forTextStyle: .headline, fontName: "AvenirNext-Light", baseFontSize: 28, increment: 2, decrement: 2)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .subheadline, fontName: "AvenirNext-Regular", baseFontSize: 22, increment: 2, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .body, fontName: "AvenirNext-Regular", baseFontSize: 17, increment: 1, decrement: 1, includeAccessibilitySizes: true)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .caption1, fontName: "AvenirNext-Medium", baseFontSize: 15, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .caption2, fontName: "AvenirNext-Regular", baseFontSize: 13, increment: 1, decrement: 1)
PreferredFontManager.sharedManager.registerFonts(forTextStyle: .footnote, fontName: "AvenirNext-Regular", baseFontSize: 11, increment: 1, decrement: 1)

PreferredFontButton, PreferredFontLabel & PreferredFontTextField

PreferredFontButton, PreferredFontLabel and PreferredFontTextField are subclasses of UIButton, UILabel and UITextFieldrespectively but they incorporate a PreferredFontManager and subscribe to UIContentSizeCategoryDidChangeNotification so the font used it automatically updated for the selected accessibility font size selected buy the user.

let label = PreferredFontLabel()
let button = PreferredFontButton()
let textField = PreferredFontTextField()

Property: textStyle

By default the UIFontTextStyle.body is used, but this can be customized and changed at any time with the textStyle: initializer or the .textStyle property.

let label = PreferredFontLabel(textStyle: .headline)
let button = PreferredFontButton(textStyle: .headline)
let textField = PreferredFontTextField(textStyle: .headline)

Property: preferredFontManager

By default this property is set to PreferredFontManager.shared, if there is not a registered text style UIFont.preferredFontForTextStyle is used instead. This property can also be set to a custom PreferredFontManager object.

Progress:

  • Tests
  • Travis
  • Badges
  • Carthage
  • CocoaPods
  • Description
  • Documentation
  • AppleTV
  • Prebuilt Frameworks
  • Travis Test Matrix
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].