Java – FontMetrics without Graphics

No you do not necessarily need to get/use the graphics object: Font font = new Font(“Helvetica”,Font.PLAIN,12); Canvas c = new Canvas(); FontMetrics fm = c.getFontMetrics(font); If you would now call c.getGraphics() it would return null. The canvas solution on the other hand will also work in headless mode.

Meaning of top, ascent, baseline, descent, bottom, and leading in Android’s FontMetrics

Let’s first review what the documentation says: Top – The maximum distance above the baseline for the tallest glyph in the font at a given text size. Ascent – The recommended distance above the baseline for singled spaced text. Descent – The recommended distance below the baseline for singled spaced text. Bottom – The maximum … Read more

tech