Refactoring of TrueType code and implementation of OpenType font repairing

Fixes #3324 and #2442