Skip to content
Programmatically load custom fonts into your iOS and tvOS app.
Branch: master
Clone or download
Latest commit 141145f Nov 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
FontBlasterExample Changed sample project to display all fonts programatically in a table ( Oct 9, 2018
Sources
docs
.gitignore
.jazzy.yml Added Jazzy docs Mar 5, 2017
FontBlaster.podspec Updated podfile swift_version Sep 17, 2018
Gemfile
Gemfile.lock
LICENSE Initial code commit May 6, 2015
Package.swift Updated README and package manager config files Mar 15, 2016
README.md Update README.md Nov 11, 2018

README.md

FontBlaster

Programmatically load custom fonts into your iOS and tvOS app.

Swift Support Platform CocoaPods Carthage Compatible SwiftPM Compatible


About

Say goodbye to importing custom fonts via property lists as FontBlaster automatically imports and loads all fonts in your app's Bundles with one line of code.

Features

  • CocoaPods Support
  • Carthage Support
  • Swift PM Support
  • Automatically imports fonts from Bundle.main
  • Able to import fonts from remote bundles
  • Sample Project
  • Documentation at http://sabintsev.com/FontBlaster/

Installation Instructions

Swift Version Branch Name Will Continue to Receive Updates?
4.2 master Yes
4.1 swift4.1 No
3.2 swift3.2 No
3.1 swift3.1 No

CocoaPods

pod 'FontBlaster' # Swift 4.2
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift4.1' # Swift 4.1
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift3.2' # Swift 3.2
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift3.2' # Swift 3.1

Carthage

github "ArtSabintsev/FontBlaster" // Swift 4.2
github "ArtSabintsev/FontBlaster" "swift4.1" // Swift 4.1
github "ArtSabintsev/FontBlaster" "swift3.2" // Swift 3.2
github "ArtSabintsev/FontBlaster" "swift3.1" // Swift 3.1

Swift Package Manager

.Package(url: "https://github.com/ArtSabintsev/FontBlaster.git", majorVersion: 4)

Manual

  1. Download FontBlaster.
  2. Copy FontBlaster.swift into your project.

Setup

Typically, all fonts are automatically found in Bundle.main. Even if you have a custom bundle, it's usually lodged inside of the mainBundle. Therefore, to load all the fonts in your application, irrespective of the bundle it's in, simply call:

FontBlaster.blast() // Defaults to Bundle.main if no arguments are passed

If you are loading from a bundle that isn't found inside your app's mainBundle, simply pass a reference to your Bundle in the blast(_:) method:

FontBlaster.blast(bundle:) // Takes one argument of type Bundle, or as mentioned above, defaults to Bundle.main if no arguments are passed

If you need a list of all of the loaded fonts, an overloaded version of the blast(_:) method has a completion handler that returns just that. Just like the original method, this method takes either a custom Bundle or defaults to Bundle.main if no argument is passed.

// Defaults to Bundle.main as no argument is passed
FontBlaster.blast() { (fonts) in
  print(fonts) // fonts is an array of Strings containing font names
}

// Custom bundle is passed as argument
FontBlaster.blast(bundle:) { (fonts) in
  print(fonts) // fonts is an array of Strings containing font names
}

To turn on console debug statements, simply set debugEnabled() = true before calling either blast() method:

FontBlaster.debugEnabled = true
FontBlaster.blast()

Sample Project

A Sample iOS project is included in the repo. When you launch the app, all fonts are configured to load custom fonts, but don't actually display them until you push the button on the navigation bar. After pushing the button, FontBlaster imports your fonts and redraws the view.

Inspiration

This project builds upon an old solution that Marco Arment proposed and wrote about on his blog.

Created and maintained by

Arthur Ariel Sabintsev

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.