AttributedTextView icon indicating copy to clipboard operation
AttributedTextView copied to clipboard

Default font changes in Xcode 11

Open sevgjan opened this issue 4 years ago • 3 comments

Hi all, Why it switches to TimesNewRomanPSMT font in Xcode 11?

Thanks

sevgjan avatar Oct 02 '19 14:10 sevgjan

AttributedTextView does not change any attributes by itself. It just takes the UILable, UITextview or NSAttributed text and applies whatever you specified. Indeed Apple made some changes in Xcode 11

As per Apple's official document https://developer.apple.com/fonts/

SF Pro:

This sans-serif typeface is the system font for iOS, macOS, and tvOS, and includes a rounded variant. It provides a consistent, legible, and friendly typographic voice.

SF Compact:

This sans-serif typeface is the system font for watchOS, and includes a rounded variant. It suits a wide range of content and is easily legible in a variety of contexts.

So we need to download and install SF Pro font and set UILabel attributed string font style with SF Pro Text Regular 18.0 to keep the same font style like Plain text have.

evermeer avatar Oct 03 '19 04:10 evermeer

Quick update In Attributer.swift I was changing: open func font(_ font: UIFont?) -> Attributer { if font != nil { return fontName(font!.fontName.replacingOccurrences(of: ".", with: "")).size(font!.pointSize) } return self } without the dot (.) and it worked for font, it was not changing to TimesNewRoman, but it's not working for font-weight.

sevgjan avatar Oct 11 '19 14:10 sevgjan

still replaces for me see so https://stackoverflow.com/questions/59105193/asking-for-san-francisco-font-in-different-size-returns-a-times-new-roman-varian seems fontFamily should be used instead fontName

evgeniy-bizhanov avatar May 20 '21 05:05 evgeniy-bizhanov