Can you canvas.drawText() emojis with stroke?

55 Views Asked by At

Can you canvas.drawText() emojis with stroke.?

I'm shocked Android doesn't natively support drawing emojis. The fact you need an external library EmojiCompat is pretty mind-blowing. After some experimentation...

This works (renders the emoji):

paint.setStyle(Paint.Style.FILL);
CharSequence fireEmoji = EmojiCompat.get().process("\uD83D\uDD25");
canvas.drawText(fireEmoji.toString(), x, y, paint);

This doesn't (renders nothing):

paint.setStyle(Paint.Style.STROKE);
CharSequence fireEmoji = EmojiCompat.get().process("\uD83D\uDD25");
canvas.drawText(fireEmoji.toString(), x, y, paint);

This doesn't (renders nothing):

paint.setStyle(Paint.Style.FILL_AND_STROKE);
CharSequence fireEmoji = EmojiCompat.get().process("\uD83D\uDD25");
canvas.drawText(fireEmoji.toString(), x, y, paint);

Adding a stroke around the emojis in my app is pretty important. I currently use hundreds of images instead of drawing the emojis directly because I need the stroke. Is there a way to do this through this method or another method.?

0

There are 0 best solutions below