Skip to content

Commit

Permalink
fix for issue ranesr#53: the app shouldn't crash when included as a s…
Browse files Browse the repository at this point in the history
…tatic library
  • Loading branch information
vitalii-tym committed Feb 19, 2019
1 parent e3fc885 commit dff34e3
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Source/SwiftIcons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -735,16 +735,10 @@ public class FontLoader {

if !loadedFontsTracker[fontName]! {
let bundle = Bundle(for: FontLoader.self)
var fontURL: URL!
let identifier = bundle.bundleIdentifier

if (identifier?.hasPrefix("org.cocoapods"))! {
fontURL = bundle.url(forResource: fileName, withExtension: "ttf", subdirectory: "SwiftIcons.bundle")
} else {
fontURL = bundle.url(forResource: fileName, withExtension: "ttf")!
}

let data = try! Data(contentsOf: fontURL)
let fontURL = bundle.url(forResource: fileName, withExtension: "ttf", subdirectory: "SwiftIcons.bundle")
?? bundle.url(forResource: fileName, withExtension: "ttf")
guard let theFontURL = fontURL else { NSException(name: .internalInconsistencyException, reason: "failed to load font \(fontName)").raise(); return }
let data = try! Data(contentsOf: theFontURL)
let provider = CGDataProvider(data: data as CFData)
let font = CGFont(provider!)!

Expand Down

0 comments on commit dff34e3

Please sign in to comment.