Handle locales more safely.

As it turns out, switching to uselocale is a bit more complicated than we originally thought.

@adrientetar, take a look (and try round-tripping a few typefaces in various formats).