Hello guys, i want to share this improvement API to TextMeshPro
This package will include all you need to support all Emojis of Android/iOS in you app (Unicode Emoji 12.0)
The original TextMeshPro use unicode characters to try map Emojis, but this is problematic because in Android we have a huge amount of Emojis that use Char Sequence.
Thats why you need this API.
CURRENT VERSION: 1.1.5
NEW INSTALL GUIDE (Package Manager Unity 2019):
- Delete old versions of this API inside your Assets folder
- Add following link inside manifest.json (Packages\manifest.json)
{
"dependencies": {
"com.kyub.emojisearch": "https://gitlab.com/KyubInteractive/emojisearchapi.git#com.kyub.emojisearch-1.1.5",
...
}
}
FAST GUIDE:
- Replace your TextMeshProUGUI component to TMP_EmojiTextUGUI component in the GameObject
-
Enable RichText (we need it because we use <sprite=index> tag to map the emojis).
-
Add in TMP SETTINGS (or in your TMP_EmojiTextUGUI) the spriteasset in correct format
(generated by Sprite Importer)
PS: Already added the EmojiData_google in this project so you can use it.
(License Apache License 2.0)
This SpriteAsset contains all emojis from Android 9.0 in 32x32 per emoji format.
USING CONVERSION TOOL TO GENERATE SPRITEASSETS (NEW GUIDE):
- Download a JSON and a Spritetexture from GitHub - iamcal/emoji-data: Easy to parse data and spritesheets for emoji
- Access in Unity the tool āSprite Emoji Importerā
(Path: āWindow/TextMeshPro/Sprite Emoji Importerā) - Drop the JSON downloaded from emoji-date in the tool and configure the size/spacing/padding of the grid in SpriteSheet (default size 32x32, with spacing 2x2 and padding 1x1)
- Check the Import Format to āEmoji Data Jsonā
- Hit Create Sprite Asset
- Save your SpriteAsset and use it in TextMeshPro (yey!)
ENJOY the Full Unicode Emoji 14.0 Support! YEY!
- Here an example of a chat system implemented with this Api
ABOUT SEARCH ENGINE IMPLEMENTATION:
- The emoji sequence will be extracted from TMP_Sprite.name in UTF32 or UTF16 HEX format separeted by ā-ā for each char (see example below)
Ex: TMP_Sprite.name = 0023-fe0f-20e3.png
0023-fe0f-20e3.png will generate:
Unicode 00000023 and
Sequence 00000023 0000fe0f 000020e3
so this a valid CharSequence and must be included in SearchEngine because TMP_Text dont know how to handle with it
(the sequence != unicode representation)
But
0023.png will generate:
Unicode 00000023 and
Sequence 00000023
so this will be ignored by the searchengine (default TMP_Text can handle this case without extra overheads because the sequence == unicode representation)
PS1: The pattern is the default names in emoji-date JSONs and in EmojiOne JSONs
PS2: The CharSequence will be ignored if UnicodeHex == Name.ToHex() or if the Name is not in correct pattern.
-
Search engine will try cache all Emoji Sequences of a SpriteAsset in two lookup tables
-
The first table will Map the CharSequence to SpriteIndex
(example: sequence U+1f3c4 U+200d U+2640 U+fe0f will be mapped to <Sprite=512>) -
The second Dictionary will map all paths until the end.
(Example: in Sequence U+1f3c4 U+200d U+2640 U+fe0f we will generate entry for all chars util the end because we need O(1) access while trying to find if a char is mapped as a sequence (or if i can give up and just leave this char in final text)
FastPath Entries for U+1f3c4 U+200d U+2640 U+fe0f
-
U+1f3c4*
-
U+1f3c4 U+200d*
-
U+1f3c4 U+200d U+2640*
-
U+1f3c4 U+200d U+2640 U+fe0f*
-
During parse process it will check char by char, looking at FastPathDictionary. if we failed to find entry in FastPath we try to retrieve sprite from CharSequenceToSpriteIndex table (with current path checked until last iteration). If failed we leave this char alone (this is not an emoji sequence).
-
The process is very eficient because we acess all dictionaries in O(1), so the order of complexity to parse a text is O(N) while N = text.length
(with minor extra overheads during the search). -
The SearchEngine will only parse text when something changed in TMP_EmojiTextUGUI
-
The original text in TMP_EmojiTextUGUI will not be affected because the parse process donāt save the parsed text in m_text (only in the charbuffer)
FAQ
-
MOST STABLE VERSIONS OF TEXTMESHPRO TO USE:
version >= 2.1.0-preview.2 && version <=2.1.0-preview.10 -
CREATE EMOJI WITH 64X64 SIZE OR IMPORT NEW SPRITESHEET:
Check explanations in thread
Full Emoji Support Api (emoji Sequen - Unity Engine - Unity Discussions
If the creator of TextMeshPro need any help to integrate this to original TMP_Text,
just send me a message or e-mail.
(raf.csoares@gmail.com or raf.csoares@kyubinteractive.com)