Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In iOS 13, using Apple .systemFont will use the incorrect font if a paragraph style is set. #1701

Open
Sethmr opened this issue Oct 7, 2019 · 13 comments

Comments

@Sethmr
Copy link

Sethmr commented Oct 7, 2019

After using the XCode 11 compiler, the .systemFont started having incorrect cases of font app wide for us. After looking deeper into the problem, I found that every time you use the .paragraphStyle in any way shape or form (even with an empty initializer) on your NSAttributedString it will cause Times New Roman to be displayed instead of SF Fonts.

My team uses this extensively in our app and would highly appreciate a fix. I will attempt to find a work around in the mean time that is acceptable. Thanks for a great framework to build upon :).

Example below:


import AsyncDisplayKit

class ViewController: ASViewController<ASDisplayNode> {

    init() {
        super.init(node: ASDisplayNode())
        node.layoutSpecBlock = { [unowned self] _, _ in
            return ASStackLayoutSpec(
                direction: .vertical,
                spacing: 20,
                justifyContent: .center,
                alignItems: .center,
                children: [self.sfTextNode, self.timesNewRomanTextNode]
            )
        }
        node.automaticallyManagesSubnodes = true
        modalPresentationStyle = .fullScreen
        node.backgroundColor = .white
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    lazy var sfTextNode: ASTextNode = {
        let textNode = ASTextNode()
        textNode.attributedText = NSAttributedString(
            string: "Example Text",
            attributes: [.font: UIFont.systemFont(ofSize: 20)]
        )
        return textNode
    }()

    lazy var timesNewRomanTextNode: ASTextNode = {
        let textNode = ASTextNode()
        textNode.attributedText = NSAttributedString(
            string: "Example Text",
            attributes: [.font: UIFont.systemFont(ofSize: 20), .paragraphStyle: NSParagraphStyle()]
        )
        return textNode
    }()

}

Simulator Screen Shot - iPhone 11 Pro Max - 2019-10-07 at 09 48 47

@atkalikov
Copy link

You can use ASTextNode2 instead of ASTextNode.
But in my case it didn’t help me completely. The second version of ASTextNode sometimes behave itself completely different compared to the first version.

@bolsinga
Copy link
Contributor

bolsinga commented Oct 7, 2019

Is this #1579 ?

@Sethmr
Copy link
Author

Sethmr commented Oct 8, 2019

@atkalikov I would be willing to try this, but I literally have hundreds of cases I am working with here. Is there any documentation on the differences between ASTextNode2 and ASTextNode?

@Sethmr
Copy link
Author

Sethmr commented Oct 8, 2019

Also, I don't know if this is any help, but .SF UI Text and .SF UI Display are no longer found in UIFont.familyNames or UIFont.fontNames(forFamilyName: anyFamily). I think this has something to do with the SF Symbols in iOS 13.

@dirtmelon
Copy link
Contributor

I had test in #1579 , it fixes this issue. @bolsinga @Sethmr

@bolsinga
Copy link
Contributor

@dirtmelon Would you be able to create a PR that has a test for this? It would be terrific to back fill these tests. Thanks. @Sethmr Please try with master.

@Sethmr
Copy link
Author

Sethmr commented Oct 17, 2019

@bolsinga I will attempt tomorrow.

@ay8s
Copy link
Collaborator

ay8s commented Oct 18, 2019

Ran into this myself yesterday. Couldn't get it working with latest from master either. Font displayed fine without paragraph style.

Wonder if you found the same @Sethmr?

@Sethmr
Copy link
Author

Sethmr commented Oct 18, 2019

@ay8s If you look at my post, that is directly what it is saying ;)

@bolsinga It is working great in master. I'll be looking forward to the next release. I came up with a patch job that mostly is working in the mean time.

@ay8s
Copy link
Collaborator

ay8s commented Oct 18, 2019

Sorry, I meant in your attempt today. Will have to dig into why it wasn't working for me with master.

@nikmun
Copy link

nikmun commented Nov 4, 2019

I am facing the same issue. When will you guys release the new version with the fix of this issue?

@manzick
Copy link

manzick commented Dec 4, 2019

Hello. Today is December 4th. Can you release at least a little hotfix for this problem?

@0xTomTom
Copy link

Would love a fix.
Nevertheless, great project guys! Texture makes creating iOS projects a lot of fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants