This seems like a basic question, but I couldn't find a similar one on SO. While reading the documentation, I was having trouble grasping the concepts. I want to understand what the difference is between
Let's first review what the documentation says:
Note that the Baseline is what the first four are measured from. It is line which forms the base that the text sits on, even though some characters (like g, y, j, etc.) might have parts that go below the line. It is comparable to the lines you write on in a lined notebook.
Here is a picture to help visualize these things:
Remember that when drawing on a canvas in Java and Android, going down is an increase in y and going up is a decrease in y. That means that FontMetrics'
ascent are negative numbers since they are measured from the baseline (while descent and bottom are positive numbers). Thus, to get the distance from
bottom you would need to do (
The leading is the distance between the bottom of one line and the top of the next line. In the picture it is the space between the orange of Line 1 and the purple of Line 2. According to this site, though,
leading is usually set to zero. The descent-bottom and the ascent-top distances usually provide enough line spacing already.
Check out these links for more information: