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

Fixed an issue when rendering emojis and other unicode strings #48

Closed
robertodias180 opened this issue Sep 12, 2018 · 1 comment
Closed
Assignees
Labels
Milestone

Comments

@robertodias180
Copy link

Some emojist stoped working after update.
this code is the code I have

let messageStyle = Style {
    $0.font = UIFont.systemFont(ofSize: 12)
    $0.kerning = Kerning.point(0.3)
    $0.color = UIColor.bsBase
}
self.messageLabel.attributedText = "😇".set(style: messageStyle)

On version 2.0.1
screen shot 2018-09-12 at 12 12 24

On version 2.0.2+
screen shot 2018-09-12 at 12 06 39

Any clues what may have caused this?

@robertodias180 robertodias180 changed the title Some emojis stoped working on 2.0.2+ Some emojis stopped working on 2.0.2+ Sep 12, 2018
@malcommac malcommac changed the title Some emojis stopped working on 2.0.2+ Fixed an issue when rendering emojis and other unicode strings Sep 20, 2018
@malcommac malcommac self-assigned this Sep 20, 2018
@malcommac malcommac added the bug label Sep 20, 2018
@malcommac malcommac added this to the 2.0.5 milestone Sep 20, 2018
malcommac added a commit that referenced this issue Sep 20, 2018
@malcommac
Copy link
Owner

Thank you; just fixed it.

String.count returns the number of rendered characters in the string. Some emojis are a combination of two or more UTF characters that are rendered into one character, in order to allow for more emojis.
In order to get the actual length of the string for use in NSRange, I need to use NSAttributedString.length.

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

No branches or pull requests

2 participants