Низкое качество текста (растровый текст) - PullRequest
1 голос
/ 05 апреля 2020

Я напечатал текст на холсте, но текст низкого качества, я провел некоторые исследования, необходимо использовать graphics2d, как я могу его адаптировать?

Изображение: нажмите, чтобы увидеть картинка

private Bitmap Text(){
    Bitmap image = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(image);
    if (drawable != null) {
        drawable.setBounds(realBounds);
        drawable.draw(canvas);
    }

    if (textRect.width() == getWidth()) {
        int dy = getHeight() / 2 - staticLayoutText.getHeight() / 2;
        // center vertical
        canvas.translate(0, dy);
    } else {
        int dx = textRect.left;
        int dy = textRect.top + textRect.height() / 2 - staticLayoutText.getHeight() / 2;
        canvas.translate(dx, dy);
    }

    staticLayoutShadow.draw(canvas);
    staticLayoutOutline.draw(canvas);
    staticLayoutText.draw(canvas);
    return image;
}

@Override
public void draw(@NonNull Canvas canvas) {
    Matrix matrix = getMatrix();
    canvas.save();
    canvas.concat(matrix);
    paint = new Paint();
    paint.setAntiAlias(true);
    if (mode != null)
        paint.setXfermode(new PorterDuffXfermode(mode));
    canvas.drawBitmap(Text(), null, realBounds, paint);
    canvas.restore();
}
...