我正在使用自定义字体并将文本添加到带有 android 中的 Paint 对象的画布中,例如:
Paint paint = new Paint();
paint.setARGB(255, 255, 255, 255);
paint.setTextSize(29);
paint.setAntiAlias(true);
paint.setTypeface(font);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER)); // Text Overlapping Pattern
final TextPaint tp = new TextPaint(paint);
final TextPaint tpStroke = new TextPaint(strokePaint);
// canvas.translate(15, 5);
canvas.translate(20, 5);
StaticLayout sl = new StaticLayout(textOne.getText().toString(), tp, (finalBitmapOne.getWidth()-10), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
sl.draw(canvas);
我对前导/行高不满意,我该如何调整它?
我可以通过以下方式获得领先:
FontMetrics fmPaint = paint.getFontMetrics();
fmPaint.leading;
但是我该如何调整呢?