静态布局绘制文本,单词模糊,重量不均匀,不清楚。

我想绘制为双字节字符的文本(例如中文,日语等)

谁知道如何解决这个问题。以及如何在StaticLayout中设置字体

TextPaint textPaint = new TextPaint();
//  textPaint.setARGB(1, 0, 0, 0);
textPaint.setFlags(TextPaint.FAKE_BOLD_TEXT_FLAG);
textPaint.setColor(Color.rgb(0, 0, 0));
textPaint.setFakeBoldText(true);
textPaint.setTextSize(16.0F);
StaticLayout layout = new StaticLayout(cityName,textPaint,w/WCOUNT-2-2,
                        Alignment.ALIGN_CENTER,1.0F,0.0F,true);

int wh = layout.getHeight();
int offerseth = rect.height()/2-wh/2;
int ww = layout.getWidth();
int offersetw = rect.width()/2-ww/2;
canvas.translate(rect.left+offersetw,rect.top+offerseth);
layout.draw(canvas);
canvas.translate(-(rect.left+offersetw),-(rect.top+offerseth));

最佳答案

对于较小的字体,我发现您没有:

textPaint.setAntiAlias(true);

07-28 02:31