android - How to get ascender/descender and x height for a given font -
i need ascender/descender , x-height..
by using following code can find descender , total height:
descender_height = paint.descent(); total_height = descender_height - paint.ascent(); //ascender = ?; equal descender height? //x_height = ?; total_height - 2*descender_height ?
thanks
i think ascender , descender height typically same, wouldn't depend on every font. don't see direct way x-height, trick use below. also, total height, talking absolute distance highest ascender lowest descender? i've included below. haven't tested these myself, should work (but let me know if i'm misinterpreting you've said):
// assuming textpaint/paint tp; rect bounds; // retrieve bounding rect 'x' tp.gettextbounds("x", 0, 1, bounds); int xheight = bounds.height(); paint.fontmetrics metrics = tp.getfontmetrics(); int totalheight = metrics.top - metrics.bottom;
Comments
Post a Comment