Android - How to scale text without dithering/antialiasing - I want the pixelated text
For an experiment I want to draw pixelated text on a canvas.
This is what I have so far:开发者_Python百科
Paint text = new Paint();
text.setAntiAlias(false);
text.setFilterBitmap(false);
text.setDither(false);
text.setFakeBoldText(false);
text.setLinearText(false);
text.setTextSize(10);
// Scale the canvas we draw on
matrix = c.getMatrix();
matrix.reset();
matrix.postTranslate(0, 0);
matrix.postScale(10,10);
c.setMatrix(matrix);
c.drawText("ABCabc", 0, 10, text);
This achieves the size I want, but the text is antialiased and dithered, and this is not what I want.
The closest I've gotten is by doing this:
text.setTextScaleX(5);
which scales the text the way I want horizontally, but unfortunately there is no text.setTextScaleY-functuion...
Any ideas?
Can you use text.setTextSize(n) and scale up the font instead?
I know that this is a really old question but here's a simple solution if anyone's still looking for one:
textView.setTextScaleX(scaleX);
textView.setScaleY(scaleY);
So by letting scaleX == scaleY
, the font will be scaled uniformly as expected.
精彩评论