iBicha / EmojiTexture

A Unity plugin to render Emojis ☺ ❀ πŸ† πŸ‘ to a texture
Other
62 stars 9 forks source link

Fix code points sequence rendering (emoji modifiers) (faulty Regex) #4

Closed iBicha closed 6 years ago

iBicha commented 6 years ago

Combinations are currently not working. E.g. an emoji of man + skin tone is not detected as a single emoji, but as 2.

iBicha commented 6 years ago

Caused by the Regex function when SanitizeText is set to true

sandiz commented 6 years ago

hi, thanks for the awesome plugin! works great with standard emojis!

do you know what regex string to use to detect emoji + skin tone ? any idea if the regex will be on a per emoji basis or can we catch any emoji + skin tone pair ?

iBicha commented 6 years ago

@sandiz thank you for the comment.

Thing is, I started working on this plugin before realizing how complex emojis can be. For example, there are "woman + skin tone" πŸ‘©πŸ½, and there are "woman + mechanic + skin tone" πŸ‘©πŸ½β€πŸ”§or it could be a freaking entire family πŸ‘¨β€πŸ‘¨β€πŸ‘§β€πŸ‘§which is really each an emoji, with a special character that acts as a separator. Even flags are composed. From what I've been, there is no consistent way that I can use to detect a full sequence that represents one glyph or image. And even if I figure it out, it would be a b**** to maintain since it's constantly evolving. Nonetheless, I'm addressing the issue.

Edit: funny how they display correctly on macOS and Android, but not on windows. It's not consistent even with popular apps such as chrome. It's up to the system to decide how to display them.

So far, this is the current direction I'm going to for the next fix: If the SanitizeText is set to false, the text will be rendered as is. If not :

There are also platform specific functions that can help determine if a set of characters is a single glyph or not. These are not tested, but will definitely be used if results are more accurate.

I made few tests, and it seems to work well. It has a small overhead, since we are measuring multiple times the size, but it's a fair compromise for now, until I figure out another solution (and that's what the SanitizeText is for, to turn this off if you want)

The other problem is that this will not work in TextMesh Pro. It keeps a map from One Unicode character to a sprite, and it replaces it when it is found. Probably will not work, until TextMesh Pro gets updated to support this.

A solution is in the work, but I'm open to suggestions.

iBicha commented 6 years ago

Now, it should get correct results (99% of the time) on Android and iOS. TextMesh Pro however, did not benefit from the fix due to how it is designed (and neither Github Emojis) I will keep this open, as it is not 100% solved.

Edit: should investigate how THIS works

iBicha commented 6 years ago

EmojiTexture handles modifiers correctly (mostly) but not in TextMesh Pro. Will close this for now, and keep #14 until a TMP update