Closed iBicha closed 6 years ago
Caused by the Regex function when SanitizeText
is set to true
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 ?
@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 :
16
characters starting from the found emoji (because I don't think any emoji could be larger than 16 characters)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.
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
EmojiTexture handles modifiers correctly (mostly) but not in TextMesh Pro. Will close this for now, and keep #14 until a TMP update
Combinations are currently not working. E.g. an emoji of man + skin tone is not detected as a single emoji, but as 2.