Clean up and reorder core pair-wise kerning code to do less computation.

We now first compute the distance between glyphs; before potentially
collecting more statistics.