Skip to content

An easy, swifty, and enum(ey) font manager for iOS

License

Notifications You must be signed in to change notification settings

briannadoubt/FontBook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FontBook

An easy, swifty, and enum(ey) font manager for iOS

Prerequisites

  • Xcode 9+
  • Swift 4+
  • Access to font files to embed in project

Installation

Cocoapods

pod 'FontBook'

Manually

Copy FontBook.swift (link) into your Xcode project. Make sure to add it to your app's target in Xcode.

Setup

First, copy the font files you want to use into your project. FontBook uses UIFont at its core so it accepts all standard font file formats. Be sure to select the relevent target and make sure that "Copy items if needed" option is checked.

Usage

import FontBook

Create an enum with a raw value of FontBook. For each font that you copied into your project, add a case and name it appropriately. Give each case a raw value matching the font file's name.

enum Fonts: FontBook {
    case arial = "Arial"
    case arialItalic = "Arial Italic"
    case arialBold = "Arial Bold"
    case arialBoldItalic = "Arial Bold Italic"
    
    case helveticaNeue = "HelveticaNeue"
}

To access UIFont:

let font = Fonts.arial.rawValue.of(size: 12, color: .black)

Versioning

This project uses SemVer for versioning semantics. For all the available versions, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details