Closed defagos closed 3 years ago
Support for SwiftUI has been improved in iOS 14 (see link mentioned above).
To improve type inference, I also removed support for standard system text styles. This does not make much sense since we want to enforce specific sizes consistently and AFAIK we don't use standard system sizes anywhere. Simpler is better and instead of
let font = UIFont.srg_mediumFont(withTextStyle: SRGAppearanceFontTextStyle.caption.rawValue)
we can simply write:
let font = UIFont.srg_mediumFont(withTextStyle: .caption)
This also removes the need for font descriptor caching for system sizes, code that worked but that now is superfluous.
If we really find later that supporting standard system sizes is a good idea, we can restore the code I removed and add new constants to SRGAppearanceFontTextStyle
for the system sizes, e.g. SRGAppearanceFontTextStyleSystemBody
, with the usual UIFontTextStyle
system values.
This change has been made on the feature/spm-support
branch.
A small improvement will be delivered in 3.0.0, but we should really adopt UIFontMetrics
correctly. This has been moved to another issue #4.
Have a look at this article: https://www.hackingwithswift.com/quick-start/swiftui/how-to-use-dynamic-type-with-a-custom-font
In particular, we might define either decide to keep our hardcoded size matrix, or to use the
UIFontMetrics
scaling methods to automatically derive font sizes based on style (available with iOS 11).Moreover, we might need to create extensions for proper resizing support with SwiftUI.