Calculate the line height of a box more accurately

Partial fix for #230.
Fixes #247.
Fixes #248.
Fixes #246.