Programmatically load custom fonts into your iOS and tvOS app.

Overview

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

Comments
  • SPM: swift build error

    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
    
    Potential Bug 
    opened by sshhawwnn 15
  • may crash on ios 10.0.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

    Potential Bug 
    opened by lacklock 13
  • Improvements

    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

    opened by mihaicristiantanase 7
  • FontBlaster hangs execution

    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.

    Potential Bug 
    opened by gmarm 7
  • support swift 2

    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

    opened by AndrewSB 6
  • FontManagerErrorAlreadyRegistered

    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

    Question Potential Bug 
    opened by lufutu 5
  • Can be used inside a Framework?

    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.

    Question 
    opened by YisusFin 3
  • Swift 5 support release

    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?

    Request Enhancement 
    opened by OdNairy 2
  • Not compile iOS version

    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"

    Potential Bug 
    opened by mr-merlin 2
  • tvOS support

    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.

    Enhancement 
    opened by peterdeweese 2
  • Use String directly, instead of String.characters

    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

    opened by andreyrd 2
Releases(5.3.0)
Owner
Arthur Ariel Sabintsev
Senior Engineering Manager
Arthur Ariel Sabintsev
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

Jeremy Gale 9 Aug 24, 2022
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

sedat çiftçi 1.1k Dec 14, 2022
Pretendard Fonts for iOS (Swift Package Manager)

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

Darth Vader 1 Jun 2, 2022
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

Nicholas Maccharoli 1.3k Nov 14, 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.

null 2 Mar 26, 2022
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

Home Assistant 1.6k Nov 12, 2022
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

Zhibo 39 Nov 3, 2022
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

Thi Doãn 1.6k Dec 30, 2022
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

Keita Oouchi 313 Dec 8, 2022
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

Keita Oouchi 52 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. Usage The library is super super easy to use, just something like thi

Bui Dac Huy 81 Dec 27, 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

Nicholas Maccharoli 171 Dec 28, 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

Pride Chung 2.8k Jan 6, 2023
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

Yusuke Kita 146 Nov 8, 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

Sparrow Code 110 Dec 28, 2022
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

Yuji Hato 365 Oct 19, 2022
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

Qiun Cheng 192 May 16, 2022
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

Patrick Vaberer 746 Dec 17, 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

William Tristão de Paula 1 Dec 7, 2021
Easiest way to load view classes into another XIB or storyboard.

LoadableViews Easiest way to load view classes into another XIB or storyboard. Basic setup Subclass your view from LoadableView Create a xib file, set

MLSDev 43 Nov 4, 2022