The emoji expression does not display after Android Canvas.drawText () writes the word on Bitmap.

similar problems are also found on stockoverflow:
https://stackoverflow.com/questions/47807621/draw-emoji-on-bitmap-with-drawtextonpath

my code is as follows:

    private Bitmap convertText2Bitmap(String text) {
        if (TextUtils.isEmpty(text)) {
            return null;
        }
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.RED);
        paint.setTextSize(sbTextSizeSP.getProgress());
        paint.setDither(true);
        paint.setFilterBitmap(true);

        //text
        Rect bounds = new Rect();
        paint.getTextBounds(text, 0, text.length(), bounds);
        Bitmap bitmap = Bitmap.createBitmap(bounds.width(), bounds.height(), Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(bitmap);
        Paint.FontMetrics fontMetrics = paint.getFontMetrics();

        float yPos = -fontMetrics.top;
        canvas.drawText(text, 0, yPos, paint);

        return bitmap;
    }

probably when the font is larger than 300px, there is no emoji on bitmap. When the font is less than 300px, it is displayed normally.

Mar.11,2021
Menu