Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何获取给定字体的升序/降序和x高度_Android_Fonts_Fontmetrics - Fatal编程技术网

Android 如何获取给定字体的升序/降序和x高度

Android 如何获取给定字体的升序/降序和x高度,android,fonts,fontmetrics,Android,Fonts,Fontmetrics,我需要找一个/和 通过使用以下代码,我可以找到下降器和总高度: 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 ? 谢谢我认为上升和下降高度通常是相同的,但我

我需要找一个/和

通过使用以下代码,我可以找到下降器和总高度:

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 ?

谢谢

我认为上升和下降高度通常是相同的,但我不会对每种字体都依赖它。我真的看不到一个直接的方法来达到x高度,但是你可以使用下面的技巧。另外,对于总高度,你是说从最高的上升点到最低的下降点的绝对距离吗?我在下面也包含了一些相关内容。我自己还没有测试过这些,但它应该可以工作(但如果我误解了您所说的话,请告诉我):


这就是我的工作原理:

Paint.FontMetrics fm = paint.getFontMetrics();
int totalHeight = (int)(fm.bottom - fm.top + .5f);
Paint.FontMetrics fm = paint.getFontMetrics();
int totalHeight = (int)(fm.bottom - fm.top + .5f);