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

ASTextNode2 incorrect layout for CJK language #656

Open
yxztj opened this issue Nov 2, 2017 · 2 comments
Open

ASTextNode2 incorrect layout for CJK language #656

yxztj opened this issue Nov 2, 2017 · 2 comments

Comments

@yxztj
Copy link
Contributor

yxztj commented Nov 2, 2017

Looks very similar to facebookarchive/AsyncDisplayKit#2894, which has been fixed by delaying set NSTextStorage.setAttributedString in ASTextKitContext.

Now ASTextNode2 is not using TextKit(thus the previous fix is not applicable), but Core Text directly. Again the issue only happen when displaying CJK language. Haven't found a way to fix it now.

Setting the same attributedString on both ASTextNode(left) and ASTextNode2(right)
screen shot 2017-11-02 at 6 35 07 pm

Fine with English:
screen shot 2017-11-02 at 6 57 14 pm

It's simple to reproduce the issue:

let text = "哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈"
let attrText = NSAttributedString(string: text, attributes: [
    NSAttributedStringKey.font: UIFont.systemFont(ofSize: 16)
])
        
let node = ASTextNode()
node.attributedText = attrText
self.view.addSubview(node.view)
node.frame = CGRect(x: 20, y: 20, width: 150, height: 200)
        
let node2 = ASTextNode2()
node2.attributedText = attrText
self.view.addSubview(node2.view)
node2.frame = CGRect(x: 170, y: 20, width: 150, height: 200)
@JunyuKuang
Copy link

Have you found a way to work around this?

@JunyuKuang
Copy link

This seems to be a Core Text bug, and I filed a bug report (FB8270180) to Apple. They fixed it in iOS 14 beta 6.

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

2 participants