Swiftpack.co - Package - ArtSabintsev/FontBlaster

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

link
Stars: 989

Dependencies

Used By

Total: 0

Releases

Project Architecture Changes -

This is simply a a version bump so that less files are brought in when installing via SPM.

Updated Manifest Files -

Updated Package.swift and Podspec files to resolve https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/399.

Adds Swift 5.1 / Xcode 11 / iOS 13 Support -

This release adds support for Swift 5.1, iOS 13, and Xcode 11. Full updates here: #34

Fixed Support for Swift Package Manager -

I fixed the Package.swift so that it is now compatible with Xcode 11 and the latest Swift Package Manifest file (// swift-tools-version:4.0).

Swift 5.0 Support -

The master branch now uses Swift 5.0.

There were no major changes with source compatibility.

Swift 4.2 Support -

As of FontBlaster v4.1.0, , all future changes on master will be done in Xcode 10 using Swift 4.2.

For those using Swift v4.1.0, please check out the swift4.1 branch or version 4.0.4 - both point to the same commit hash.

Modernized Podspec file -

  • Updated Podspec file.
  • Removed .swift-version file, as it's been deprecated.

Fixes Podspec -

Fixes a podspec issue that was introduced in 4.0.2.

tvOS Support -

Fontblaster supported tvOS out of the box. The podspec now explicitly supports allows for installation of Fontblaster on apps that target tvOS 9+.

Fixes for Xcode 9.1 / iOS 11.1 SDK -

  • #24
    • Removed deprecated code references to Character API as String and Character API changed in Swift 4 and is enforced in in Xcode 9.1 / iOS 11.1. (thanks to @andreyrd)

Support for Swift 4 / iOS 11 / Xcode 9 -

FontBlaster v4.0.0 adds support for Swift 4 / iOS 11 / Xcode 9. Only minor changes were made under-the-hood.

Moving forward, only support for the Swift 4 codebase (on master) will be maintained.

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

Code Cleanup -

  • Minor Code Cleanup
  • Attempt at fixing #23

Swiftier Code -

#20: Swiftier Codebase and Repo

  • Improved Comments
  • Improved Scoping
  • Improved Swift PM Support
  • Added Jazzy Documentation

Fixed/Silenced warnings in Xcode 8.3 -

#21: Fixed/Silenced a couple warnings that cropped in Xcode 8.3.

Fix to CGFont() deadlocking issue -

Version 3.0.0: Swift 3 Support -

I've updated the syntax from Swift 2.2 to Swift 3.

-

  • Converted all instances of static func to class func because I made a mistake last year and didn't catch it until now.

Bugfixes -

  • Added labels to Font typealias
  • Fixed code utilizing Font typealias
  • printStatus() method signature changed.

PostScript Name now used. -

  • Accepted PR #14, which returns PostScript names, allowing improperly named fonts to be used programmatically using UIFont.

Updated Tag -

Changed sample project for Carthage support.

Patch for previous version -

Thanks to @shams-ahmed for his eagle-eyes in #12.

Overloaded blast method. -

There's a new blast(_:) method and this one has a completion handler that returns a a list of font names for loaded fonts as array of Strings; `[String]. Checkout #10 and #11 for more information.

Also contains a fix the Package.swift file.

-

Added Swift Package manager Support

-

Added Carthage Support

-

  • Changed most instances of class func to static func.