Canvas.drawText() doesn't render large emojis

2020-06-03 08:14发布

问题:

Canvas.drawText() doesn't render emojis above a certain font size on Android.

Correct render at somewhere below 256 px:

Incorrect render at above 256 px:

(There is a similar question about Google Chrome, and just like Android, Chrome also uses the Skia graphics library, so this seems like a bug in Skia.)

Apparently emojis fail to render above 256 px font size on my devices. But I'm not sure if this is the limit everywhere.

Is there a way to learn the font size at which emojis disappear? Or is there a workaround for this?

回答1:

I've come up with a test (an empirical estimation) for the maximum font size at which emojis can still be rendered.

The way this function works is it creates a 1x1 bitmap, and tries to draw the Earth Globe emoji (