Fix bug 6888377: crash in GetUnitsPerEm on locale change

The underlying problem is that no SkScalerContext objects existed at the
time shapeFontRun is called immediately after a locale change from en to
ja (apparently the dumping of the cache caused all these to be
deallocated), so gFTLibrary was null (and the call tio ref_ft_face
assumes that it's initialized).

There's a pattern for calls which might not necessarily be called from a
scaler context (GetAdvancedTypefaceMetrics is one such), to explicitly
check for an uninitialized library, and create one for the length of the
call if so. This patch changes GetUnitsPerEm to follow this pattern.

Change-Id: I19a4b6fa49fad0aeacc04bf971101aacca6bc94f
1 file changed