Programmatically load custom fonts into your iOS and tvOS app.

Last update: Jun 26, 2022

FontBlaster

Programmatically load custom fonts into your iOS 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

GitHub

https://github.com/ArtSabintsev/FontBlaster
Comments
  • 1. SPM: swift build error

    Hi,

    When I do a swift build, it shows me the following error.

    /Users/shawnang/Desktop/VA Driver/.build/checkouts/FontBlaster.git--291364967083757611/Sources/FontBlaster.swift:121:17: error: use of unresolved identifier 'UIFont'
                _ = UIFont()
                    ^~~~~~
    <unknown>:0: error: build had 1 command failures
    error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/shawnang/Desktop/VA\ Driver/.build/debug.yaml
    
    Reviewed by sshhawwnn at 2017-07-25 14:54
  • 2. may crash on ios 10.0.2

    anyone knwo how to fix it?

    Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libdispatch.dylib 0x00000001876544f8 _dispatch_gate_wait_slow + 136 1 libdispatch.dylib 0x0000000187641ff8 dispatch_once_f + 124 2 libdispatch.dylib 0x0000000187641ff8 dispatch_once_f + 124 3 CoreGraphics 0x0000000189bfcc68 CGFontCreate + 160 4 CoreGraphics 0x0000000189bfd270 CGFontCreateFontsWithPath + 104

    here is crash log image:

    https://github.com/lacklock/ZHIconFontKit/blob/master/Resource/crash%20on%20ios.png

    Reviewed by lacklock at 2016-10-09 02:38
  • 3. Improvements

    Hi,

    I'd like to bring the improvements I made to main repository. As you can see, I've changed a lot of things (including code formatting style). I've bumped the version to 5.0.0 because it breaks clients who previously used "loadedFonts" property. The details of the changes are in the commit messages, but if you need more details, I'd be happy to help.

    Please let me know if this is ok with you. Thanks, Mihai

    Reviewed by mihaicristiantanase at 2019-02-21 10:29
  • 4. FontBlaster hangs execution

    I'm trying to load a custom .ttf font, however as soon at the program reaches https://github.com/ArtSabintsev/FontBlaster/blob/a1fd6277988205c92e5ae20385bbe0b6375e38ad/FontBlaster.swift#L144, let fontRef = CGFont(dataProvider), the program just hangs.

    No error, no exception.

    I'm wondering whether this is an issue of FontBlaster or the font itself.

    Reviewed by gmarm at 2016-12-15 11:33
  • 5. support swift 2

    Add support for Swift 2 (lose support for swift 1.2/1.1, may suggest putting my changes on a swift-2 branch until someone writes a non-breaking change

    Reviewed by AndrewSB at 2015-07-12 03:15
  • 6. FontManagerErrorAlreadyRegistered

    HI, I added 8 custom fonts to app,it can registered 8 fonts at first time but error on second time, it only can register 4 custom fonts. Other fonts appear error The operation couldn’t be completed. (com.apple.CoreText.CTFontManagerErrorDomain error 105 - Could not register the font file(s)) Thanks

    Reviewed by lufutu at 2016-03-22 10:21
  • 7. Can be used inside a Framework?

    I'm facing some troubles trying to load some fonts embedded in a Cocoapod development using FontBlaster. Every bundlepath that I get from the ClientApp that consumes the pod points to the 'DevelopmentPod' project. And I want to load the font files that lives in my framework project. I'm thinking to use like an absolute path, to point into the BundleFramework, but I don't know how. Is there any example to achieve this? Or is that can be used only in App projects?

    Thanks.

    Reviewed by YisusFin at 2022-01-05 02:30
  • 8. Swift 5 support release

    Hi Current 4.1.0 release is source-compatible with Swift 5.0. However, we still need separate release with new version to avoid Xcode warning "Conversion to Swift 5 is available". Direct change in Pod.xcodeproj fix the warning :) May you release new version with only change - swiftVersion: '5.0', please?

    Reviewed by OdNairy at 2019-05-24 20:35
  • 9. Not compile iOS version

    Hello! I tried to install the pod and got this error.

    The platform of the target xxxxx (iOS 9.0) is not compatible with FontBlaster (4.0.2), which does not support ios.

    I've watched through your last changes and i'm thinking that this error is related to line below you've recently added: " s.platform = = :tvos, "9.0" "

    If you wish to support other platforms you need to add next code in podspec file: s.ios.deployment_target = "8.0" s.osx.deployment_target = "10.10"

    Reviewed by mr-merlin at 2018-02-28 13:37
  • 10. tvOS support

    Can the FontBlaster CocoaPod support tvOS? If needed I'd be happy to do legwork whether it is doing a pull request for the spec or testing it out, as I believe the same code should work but seeing is believing.

    Reviewed by peterdeweese at 2018-02-23 01:56
  • 11. Use String directly, instead of String.characters

    As of Swift 4, String is a collection of characters again: https://github.com/apple/swift/blob/master/docs/StringManifesto.md#string-should-be-a-collection-of-characters-again

    There is no longer any need to use String.characters, and Xcode displays the following warning when you do so: FontBlaster.swift:170:31: 'characters' is deprecated: Please use String or Substring directly

    Reviewed by andreyrd at 2017-11-09 21:28
SwiftUI Custom Fonts with working Xcode Previews

SwiftUI Custom Fonts with working Xcode Previews This is a small SwiftUI only app that demonstrates how to use custom fonts, where the custom fonts ar

May 26, 2022
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon)
Icons fonts for iOS (Font Awesome 5, Iconic, Ionicon, Octicon, Themify, MapIcon, MaterialIcon, Foundation 3, Elegant Icon, Captain Icon)

Installation SPM Not yet supported. Please use Cocoapods or Carthage Carthage github "0x73/SwiftIconFont" Cocoapods CocoaPods is a dependency manager

Jun 21, 2022
Pretendard Fonts for iOS (Swift Package Manager)
Pretendard Fonts for iOS (Swift Package Manager)

PretendardKit Pretendard 1.3.3 을 기반으로 합니다. Install (Swift Package Manager) dependencies: [ .package(url: "https://github.com/wookeon/PretendardKit

Jun 2, 2022
Font management (System & Custom) for iOS and tvOS
Font management (System & Custom) for iOS and tvOS

UIFontComplete Font management (System & Custom) for iOS and tvOS Usage No more wasted time searching for names of UIFont fonts and no more surprises

Jun 8, 2022
This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

Server-side-Dynamic-Fonts This projects shows how we can server-side add/update "ANY" custom font in a live iOS App without needing to update the app.

Mar 26, 2022
Auto-generated icon font library for iOS, watchOS and tvOS
Auto-generated icon font library for iOS, watchOS and tvOS

Iconic helps making icon fonts integration effortless on iOS, tvOS and watchOS. Its main component is in charge of auto-generating strongly typed Swif

Jun 23, 2022
Use 1600+ icons (and more!) from FontAwesome and Google Material Icons in your swift/iOS project in an easy and space-efficient way!
Use 1600+ icons (and more!) from FontAwesome and Google Material Icons in your swift/iOS project in an easy and space-efficient way!

Swicon Use 1600+ icons from FontAwesome and Google Material Icons in your iOS project in an easy and space-efficient way! The built-in icons are from

Jan 3, 2021
Use FontAwesome in your Swift projects
Use FontAwesome in your Swift projects

FontAwesome.swift Use Font Awesome in your Swift projects To see the complete set of 3,978 icons in Font Awesome 5, please check the FontAwesome.com s

Jun 19, 2022
Use Ionicons in your Swift projects.
Use Ionicons in your Swift projects.

IoniconsKit IoniconsKit internally use ionicons.ttf v2.0.1 Example To run the example project, clone the repo, and run pod install from the Example di

May 29, 2022
Use Octicons in your Swift projects.
Use Octicons in your Swift projects.

OcticonsKit OcticonsKit internally use octicons.ttf v4.3.0 Example To run the example project, clone the repo, and run pod install from the Example di

Jan 31, 2022
SwiftUIFontIcon The easiest way to implement font icons in your SwiftUI project.
SwiftUIFontIcon  The easiest way to implement font icons in your SwiftUI project.

SwiftUIFontIcon The easiest way to implement font icons in your SwiftUI project. Usage The library is super super easy to use, just something like thi

May 28, 2022
All the SFSymbols (1.1 & 2.0) at your fingertips

SFSymbol: SFSymbol and SFSymbol 2 All the SFSymbols at your fingertips (SFSymbol 1.1 & 2) Usage SFSymbol and SFSymbol2 are an enums that contain the i

Jun 13, 2022
Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons.

FontAwesomeKit Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons. Version 2.2 Notable Changes Not Jus

Jun 11, 2022
Google Material Design Icons for Swift and ObjC project
Google Material Design Icons for Swift and ObjC project

GoogleMaterialIconFont Google Material Design Icons for Swift and ObjC project This library is inspired by FontAwesome.swift Both Swift and Objctive-C

Jan 23, 2022
Generator of settings icon by SF Symbols. Customisable background color and ready-use in table cell.

SPSettingsIcons Generate settings icons by Apple's SF Symbols. For safe using SFSymbols see SPSafeSymbols library. Installation Swift Package Manager

Jun 15, 2022
Google Material Design Icons Font for iOS
Google Material Design Icons Font for iOS

GoogleMaterialDesignIcons #Google Material Design Icons Font for iOS It is based on https://github.com/google/material-design-icons. it converts the m

Apr 23, 2022
A better choice for iOS Developer to use FontAwesome Icon with UI.😍
A better choice for iOS Developer to use FontAwesome Icon with UI.😍

FontAwesomeKit.Swift ?? ?? A better choice for iOS Developer to use FontAwesome Icon with UI. ?? Support Swift 4.2 & iOS 8.0+ FontAwesome 4.7.0 Storyb

May 16, 2022
Font Awesome swift library for iOS.
Font Awesome swift library for iOS.

Font Awesome Swift Follow me: @vaberer I like ★. Do not forget to ★ this super convenient library. Added UISegmentedControl & UITabbarItem & UISlider

May 10, 2022
This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to load remote images

iOS NOW ⭐ This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to loa

Dec 7, 2021
xFonts is an app that lets you install custom fonts on iOS and iPadOS.

xFonts xFonts is an app that lets you install custom fonts on iOS and iPadOS. Grab fonts from your iCloud Drive or Dropbox and add them to your collec

Jun 7, 2022