sin*_*nek 9 fonts android fontmetrics
我需要得到一个ascender/descender和x-height ..
通过使用以下代码,我可以找到下降器和总高度:
descender_height = paint.descent();
total_height = descender_height - paint.ascent();
//ascender = ?; is this always equal to descender height?
//x_height = ?; total_height - 2*descender_height ?
Run Code Online (Sandbox Code Playgroud)
谢谢
我认为ascender和descender高度通常是相同的,但我不会依赖于它的每一种字体.我真的没有看到直接到达x高度的方法,但你可以使用的技巧将是如下所示.另外,对于总高度,您是在谈论从最高上升者到最低下降者的绝对距离吗?我还在下面提供了一些内容.我自己没有对它们进行测试,但它应该可以工作(但如果我误解了你所说的话,请告诉我):
// Assuming TextPaint/Paint tp;
Rect bounds;
// this will just retrieve the bounding rect for 'x'
tp.getTextBounds("x", 0, 1, bounds);
int xHeight = bounds.height();
Paint.FontMetrics metrics = tp.getFontMetrics();
int totalHeight = metrics.top - metrics.bottom;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5309 次 |
| 最近记录: |