Android: text scaling incorrectly when drawing text on canvas

I draw formatted text on canvas using DynamicLayout, and I need to implement some kind of scaling. I tried using canvas.scale(...)for this. But when the text contains glare, the text is scaled incompatible with the background, for example:

scaled text with highlight

The code that draws the text is very simple:

canvas.scale(zoom, zoom);
TextPaint textPaint = new TextPaint();
textPaint.setAntiAlias(true);
DynamicLayout layout = new DynamicLayout(text, textPaint, width,
                            Layout.Alignment.ALIGN_NORMAL, 1.0f, 1.0f, false);
layout.draw(canvas);

How to make the right way?

+5
source share
1 answer

I solved this problem by installing textPaint.setSubpixelText(true);

+5
source

All Articles