• Stars
    star
    1,135
  • Rank 41,034 (Top 0.9 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Programmatically load custom fonts into your iOS, macOS and tvOS app.

FontBlaster

Programmatically load custom fonts into your iOS, macOS, and tvOS app.

Swift Support Platform CocoaPods 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
  • Swift PM Support
  • Automatically imports fonts from Bundle.main
  • Able to import fonts from remote bundles
  • Sample Project

Installation Instructions

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

CocoaPods

pod 'FontBlaster' # Swift 5.1+
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift5.0' # Swift 5.0
pod 'FontBlaster', :git => 'https://github.com/ArtSabintsev/FontBlaster.git', :branch => 'swift4.2' # 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

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

More Repositories

1

Siren

Notify users when a new version of your app is available and prompt them to upgrade.
Swift
4,140
star
2

Harpy

Notify users when a new version of your app is available and prompt them to upgrade.
Objective-C
2,600
star
3

Zephyr

Effortlessly synchronize UserDefaults over iCloud.
Swift
899
star
4

Guitar

A Cross-Platform String and Regular Expression Library written in Swift.
Swift
660
star
5

Solarized-Dark-for-Xcode

Solarized Dark Theme for Xcode. Compatible with all modern versions of Xcode since 2013!
Shell
366
star
6

UIFloatLabelTextField

A subclassed UITextField that follows the Float Label UI design pattern.
Objective-C
323
star
7

Magic

A Swift alternative for Objective-C's DLog macro.
Ruby
283
star
8

UIFloatLabelTextView

A subclassed UITextView that follows the Float Label UI design pattern.
Objective-C
174
star
9

Freedom

The Freedom to Open URLs in Third-Party Browsers on iOS with Custom UIActivity Subclasses.
Swift
86
star
10

Asynchronous-Freeloader

Multithreaded Asynchronous Image Downloader
Objective-C
22
star
11

Cognac

An Alluring, Dark, and Muted Theme For Your Favorite Text Editor.
16
star
12

Cognac-Xcode

An Alluring, Dark, and Muted Theme For Xcode.
Shell
14
star
13

GitFame

A Swift CLI script that logs your GitHub Stars and Forks.
Makefile
13
star
14

MaterialSwitch

A Material Design inspired switch for iOS
Swift
12
star
15

UIDevice-SupportedDevices

An Objective-C category on UIDevice that returns devices based on the supportedDevices key in the JSON results returned in an iTunes Lookup API call.
Objective-C
12
star
16

UIView-AutoLayoutView

A small Objective-C category on UIView that creates a UIView object that is ready to be used in programmatic AutoLayout.
Objective-C
9
star
17

UIColor-ColorWithHexAndAlpha

A category on UIColor that enables you to use hex values to create UIColor objects.
Objective-C
8
star
18

iOSDevCampDC-2018

My talk on Scaling iOS Architecture for iOSDevCampDC 2018.
5
star
19

Panhandler

Remind your active users to rate and review your iOS app
Objective-C
5
star
20

Cognac-iTerm

An Alluring, Dark, and Muted Syntax Theme For iTerm2.
3
star
21

Cognac-VSCode

An Alluring, Dark, and Muted Syntax Theme For Visual Studio Code.
3
star
22

artsabintsev.github.io

My Homepage.
CSS
2
star
23

NSDate-DateFromBSONObjectID

Convert MongoDB's BSON ObjectID to NSDate
Objective-C
2
star
24

Swift-3-CocoaHeads-DC-Talk

My talk on Swift 3 at CocoaHeads DC on July 7, 2016.
Swift
2
star
25

iOSDevCampDC-2017

My Talk on Open Source Software Development for iOSDevCampDC 2017.
2
star
26

cocoaheads-ukraine-2017

My Talk on Open Source Software Development for CocoaHeads Ukraine #13 in 2017
1
star
27

Apple-Watch-WatchKit-CocoaHeads-DC-Talk-

Keynote, PDF, and Sample Project for my WatchKit Talk.
Swift
1
star
28

Cognac-Terminal

An Alluring, Dark, and Muted Theme For The macOS Terminal.
1
star
29

Simple-Class-Portraits

A simple addon for World of Warcraft.
Lua
1
star