Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

/// Font name struct
public struct AppFont {
public struct AppFontFamilyType {
public let id: Int
public let familyName: String
public let defaultFont: String
Expand Down
File renamed without changes.
File renamed without changes.
52 changes: 27 additions & 25 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Example/mtpFontManager/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ let persistFontKey = "font"
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

lazy var exo: AppFont = {
let font = AppFont(
lazy var exo: AppFontFamilyType = {
let font = AppFontFamilyType(
id: 1,
familyName: "Exo",
defaultFont: "Exo-Regular",
Expand All @@ -36,8 +36,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}()


lazy var taviraj: AppFont = {
let font = AppFont(plist: "taviraj")
lazy var taviraj: AppFontFamilyType = {
let font = AppFontFamilyType(plist: "taviraj")
return font
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class FontManager {
private init() {
}

private var _currentFont: AppFont?
public var currentFont: AppFont? {
private var _currentFont: AppFontFamilyType?
public var currentFont: AppFontFamilyType? {
set {
if let oldId = _currentFont?.id, let newId = newValue?.id, newId == oldId {
return
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension UIFont {
return UIFont.systemFont(ofSize: UIFont.systemFontSize)
}

return UIFont(name: font.defaultFont, size: size)!
return UIFont(name: font.defaultFont, size: size) ?? UIFont()
}

@objc private class func myBoldSystemFont(ofSize size: CGFloat) -> UIFont {
Expand Down Expand Up @@ -141,15 +141,15 @@ extension UIFont {

let apperance = UINavigationBar.appearance()
var titleAttr = apperance.titleTextAttributes ?? [:]
titleAttr.updateValue( UIFont(name: font.semibold ?? font.defaultFont, size: 17)!, forKey: NSAttributedString.Key.font)
titleAttr.updateValue( UIFont(name: font.semibold ?? font.defaultFont, size: 17), forKey: NSAttributedString.Key.font)
apperance.titleTextAttributes = titleAttr


if #available(iOS 9.0, *) {
let buttonBarAppearance=UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self])
var barButtonTitleAttr = convertFromOptionalNSAttributedStringKeyDictionary(convertFromOptionalNSAttributedStringKeyDictionary(buttonBarAppearance.titleTextAttributes(for: .normal))) ?? [:]

barButtonTitleAttr.updateValue(UIFont(name: font.regular ?? font.defaultFont, size: 17)!, forKey: NSAttributedString.Key.font.rawValue)
barButtonTitleAttr.updateValue(UIFont(name: font.regular ?? font.defaultFont, size: 17), forKey: NSAttributedString.Key.font.rawValue)

let convertedAttributes = Dictionary(uniqueKeysWithValues:
barButtonTitleAttr.lazy.map { (NSAttributedString.Key($0.key), $0.value) }
Expand All @@ -161,7 +161,7 @@ extension UIFont {


// override system font in IB
@objc private convenience init(myCoder aDecoder: NSCoder) {
@objc private convenience init?(myCoder aDecoder: NSCoder) {
if let fontDescriptor = aDecoder.decodeObject(forKey: "UIFontDescriptor") as? UIFontDescriptor {
let fontAttr = UIFontDescriptor.AttributeName(rawValue: "NSCTFontUIUsageAttribute")
if let fontAttribute = fontDescriptor.fontAttributes[fontAttr] as? String ,
Expand Down Expand Up @@ -192,7 +192,7 @@ extension UIFont {
default:
fontName = font.defaultFont
}
self.init(name: fontName, size: fontDescriptor.pointSize)!
self.init(name: fontName, size: fontDescriptor.pointSize)
}
else {
self.init(myCoder: aDecoder)
Expand Down
4 changes: 2 additions & 2 deletions mtpFontManager.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ mtpFontManager is a font Manager for iOS to simplify use of custom fonts.
mtpFontManager also supports applay custom font entire application, varius font weight and dynamic types styles.
DESC

s.homepage = 'https://github.com/mostafataghipour/mtpFontManager'
s.homepage = 'https://github.com/mayurhexascal/mtpFontManager.git'
s.screenshots = 'https://raw.githubusercontent.com/MostafaTaghipour/mtpFontManager/master/screenshots/1.gif', 'https://raw.githubusercontent.com/MostafaTaghipour/mtpFontManager/master/screenshots/2.png'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Mostafa Taghipour' => 'mostafa.taghipour@ymail.com' }
s.source = { :git => 'https://github.com/mostafataghipour/mtpFontManager.git', :tag => s.version.to_s }
s.source = { :git => 'https://github.com/mayurhexascal/mtpFontManager.git', :branch => 'Update-force-fully-code-into-optional-code' }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

s.ios.deployment_target = '8.2'
Expand Down