Skip to content

EmojiCompat support

Constantin A edited this page Jul 9, 2018 · 6 revisions

As of now, EmojiCompat is supported up to Emoji 11.0.
You can find the font at https://github.com/C1710/blobmoji/blob/master/emojicompat/NotoColorEmojiCompat.ttf
I just made an example app called Blobmoji Preview. It enables you to view these emojis by simply sharing text to it.

What is EmojiCompat and how do I use it in my Android app?

EmojiCompat is an Android API enabling developers to include the latest emoji in their apps without having to update the whole system. It requires a modified version of the font which is very easy to generate in this case as this is just a fork of the original Noto-Emoji font which is usually used in EmojiCompat.
I made a library which allows you to use an emoji font other than the one provided by BundledEmojiCompatConfig.
In order to use it with Blobmoji, you'll need to put the EmojiCompat font into the assets folder of your app.
Depending on the exact solution you use, you'll also need to rename this font file.

How do you build the font?

That was a question I had to ask on StackOverflow first.
So there is a script in the Android sources which is able to create this EmojiCompat-compatible font.
As I'm not very familiar with Git, I haven't added this as a Git-submodule yet but it should be doable.
As for now I recommend pulling https://android.googlesource.com/platform/external/noto-fonts/ and https://android.googlesource.com/platform/external/unicode/.
Using this is relatively simple – just replace noto-fonts/emoji/NotoColorEmoji.ttf with the NotoColorEmoji.ttf-file provided here.
Then you might add some entries to the files in unicode/additions to add some custom/new emojis (as the cat skintones for example).
You can build it by simply running the createfonts.py-script. If you get any difficulties with flatbuffers, you might need to install this first – on Fedora you have to run sudo dnf install flatbuffers.
Warning: If you use the latest version, it might be possible that flags are broken. I recommend using the version which is linked in the StackOverflow post

Another warning: If you wish to target older devices (i.e. Android 6 and lower), you'll likely have to change two values in third_party/color_emoji/emoji_builder.py first.

Simply look for the lines containing the following string (i.e. the lines 73 and 223):

self.write (struct.pack (">L", 0x00030000)) # FIXED version

In order to make the font work on older devices, you'll need to exchange the 3 by a 2.
This is a result of this change in the original repo, and there was an issue when I built the fonts for Tusky.