/** 绘制FontMetrics对象的各种线 */mPaint.reset();mPaint.setColor(Color.WHITE);mPaint.setTextSize(80);// FontMetrics对象FontMetrics fontMetrics = mPaint.getFontMetrics();String text = "abcdefg";// 计算每一个坐标float textWidth = mPaint.measureText(text);float baseX = 30;float baseY = 700;float topY = baseY + fontMetrics.top;float ascentY = baseY + fontMetrics.ascent;float descentY = baseY + fontMetrics.descent;float bottomY = baseY + fontMetrics.bottom;// 绘制文本canvas.drawText(text, baseX, baseY, mPaint);// BaseLine描画mPaint.setColor(Color.RED);canvas.drawLine(baseX, baseY, baseX + textWidth, baseY, mPaint);mPaint.setTextSize(20);canvas.drawText("base", baseX + textWidth, baseY, mPaint);// Base描画canvas.drawCircle(baseX, baseY, 5, mPaint);// TopLine描画mPaint.setColor(Color.LTGRAY);canvas.drawLine(baseX, topY, baseX + textWidth, topY, mPaint);canvas.drawText("top", baseX + textWidth, topY, mPaint);// AscentLine描画mPaint.setColor(Color.GREEN);canvas.drawLine(baseX, ascentY, baseX + textWidth, ascentY, mPaint);canvas.drawText("ascent", baseX + textWidth, ascentY + 10, mPaint);// DescentLine描画mPaint.setColor(Color.YELLOW);canvas.drawLine(baseX, descentY, baseX + textWidth, descentY, mPaint);canvas.drawText("descent", baseX + textWidth, descentY, mPaint);// ButtomLine描画mPaint.setColor(Color.MAGENTA);canvas.drawLine(baseX, bottomY, baseX + textWidth, bottomY, mPaint);canvas.drawText("buttom", baseX + textWidth, bottomY + 10, mPaint);