Repository navigation
iOS 13 - Setting the font property of a style always results in Times New Roman being used #84
Description
Activity
I have debugged into this, and I think I know why this happens. Let's assume, we have set the style to SystemFont, Size 14.
SwiftRichString Font Instantiation on iOS 12 SDK:
FontData.swift, Line 155, attributes(currentFont:, size:) -> [NSAttributedString.Key:Any] FontConvertible.swift, Line 65, font(size:) -> Font (lldb) po self <UICTFont: 0x7fb74dd77f30> font-family: ".SFUIText"; font-weight: normal; font-style: normal; font-size: 14.00pt (lldb) po self.fontName ".SFUIText" FontData.swift, Line 159, attributes(currentFont:, size:) -> [NSAttributedString.Key:Any] po finalFont <UICTFont: 0x7fb74dc1ced0> font-family: ".SFUIText"; font-weight: normal; font-style: normal; font-size: 14.00pt--> the font name is reported as ".SFUIText" and SwiftRichString is able to instantiate the matching UIFont from this name via
Font(name: self.fontName, size: (size ?? Font.systemFontSize))!SwiftRichString Font Instantiation on iOS 13 SDK:
FontData.swift, Line 155, attributes(currentFont:, size:) -> [NSAttributedString.Key:Any] FontConvertible.swift, Line 65, font(size:) -> Font (lldb) po self <UICTFont: 0x7fa576769f90> font-family: ".SFUI-Regular"; font-weight: normal; font-style: normal; font-size: 14.00pt (lldb) po self.fontName ".SFUI-Regular" FontData.swift, Line 159, attributes(currentFont:, size:) -> [NSAttributedString.Key:Any] po finalFont <UICTFont: 0x7fa576400020> font-family: "Times New Roman"; font-weight: normal; font-style: normal; font-size: 14.00pt--> the font name is reported as ".SFUI-Regular" and SwiftRichString is NOT able to instantiate a matching UIFont from this name via
Font(name: self.fontName, size: (size ?? Font.systemFontSize))!. Instead UIFont(name:, size:) seems to fall back to Times New Roman.Here is the according rdar bug report:
https://openradar.appspot.com/6153065One could avoid this issue by changing the instantiation in FontConvertible.swift, Line 65 from
return Font(name: self.fontName, size: (size ?? Font.systemFontSize))!to
return Font(descriptor: self.fontDescriptor, size: (size ?? Font.systemFontSize))However, I don't know whether this should only apply to this single line, or other parts/system flavors as well.
But actually I hope that this gets fixed on Apple's side.
I created a pull request containing the workaround: #85
Merged and on track for 3.0.2. Thanks for PR.
Now that iOS 13 has been released, can this PR land in master (and have 3.0.2)?
Reacted by Harley ArmstrongAny progress with solving this issue in the Master ? Thx
Reacted by dtrofymenkoreleased
Somehow I'm still experiencing the issue with 3.0.2. Am I alone?
@danqing Not alone, experiencing this issue as well with 3.0.2. (But it was working fine in the develop
branch)@danqing Same here. Release 3.0.2 didn't fix the issue on iOS 13 for me.
@danqing Same here for 3.0.2 on iOS 13
Commit e5c147f seems to have introduced the issue as there seems to be a mixup with the platform checks. As far as I can see the workaround is now applied to macOS instead of iOS
Good catch @wberger. That seems to be the issue. Sending in a PR now.
Environment
Example
When the following code is compiled with Xcode 11 and run on iOS 13 any styles that contain fonts stop working correctly.