This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { | |
///Update fonts after dynamic fonts settings was changed | |
if traitCollection.preferredContentSizeCategory != previousTraitCollection?.preferredContentSizeCategory { | |
setFonts() | |
} | |
} | |
private func setFonts() { | |
title.font = UIFont(.h3, .black) | |
subtitle.font = UIFont(.bodyM, .medium) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///optional type in case if you want turn off acessability support | |
private let acessabilitySettings: DynamicTypeSettings? = DynamicTypeSettings() | |
private class DynamicTypeSettings { | |
let maxPointSizeScaleFactor: CGFloat | |
init(maxPointSizeScaleFactor: CGFloat = 1.25) { | |
self.maxPointSizeScaleFactor = maxPointSizeScaleFactor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FontManager.swift | |
// | |
// Created by http://www.popcornomnom.com | |
// Copyright © 2020 Marharyta Lytvynenko. All rights reserved. | |
// | |
import UIKit | |
///optional type in case if you don't want to support scaled font yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// somewhere here is a declaration of the Font Style parts | |
// https://gist.github.com/popcornomnom/5288be0c003fedff3e9d43c332837dca | |
// and func stringName(_, _) -> String | |
// https://gist.github.com/popcornomnom/1238714fea8d9a8efa109782958a5b99 | |
///optional type in case if you don't want to support scaled font yet | |
private let autoScaleSettings: AutoScaleSettings? = AutoScaleSettings() | |
private class AutoScaleSettings { | |
let mostPopularScreenWidth: CGFloat = 375 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FontManager.swift | |
// | |
// Created by http://www.popcornomnom.com | |
// Copyright © 2020 Marharyta Lytvynenko. All rights reserved. | |
// | |
import UIKit | |
///optional type in case if you don't want to support scaled font yet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if DEBUG | |
extension UIFont.Size { | |
var debugDescription: String { "\(self)" } | |
} | |
extension UIFont { | |
class func printAllFonts() { | |
let families = UIFont.Family.allCases | |
let sizes = UIFont.Size.allCases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FontManager.swift | |
// | |
// Created by http://www.popcornomnom.com | |
// Copyright © 2019 Marharyta Lytvynenko. All rights reserved. | |
// | |
import UIKit | |
import SwiftUI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Font { | |
public static var title: Font { .init(.h3, .bold) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIFont { | |
public static var title: UIFont { .init(.h3, .bold) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Text("my label") | |
.font(.init(.h3, .bold)) |
NewerOlder