How to get ascender/descender and x height for a given font

前端 未结 2 533
时光说笑
时光说笑 2020-12-31 14:10

I need to get a ascender/descender and x-height..

By using following code I can find the descender and the total height:

descender_height = paint.des         


        
2条回答
  •  别那么骄傲
    2020-12-31 14:41

    This is what worked for me:

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

提交回复
热议问题