diff options
author | Raph Levien <raph@google.com> | 2012-07-27 12:42:04 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2012-07-30 15:17:33 -0700 |
commit | e454fde2aeb9f50cae4ae6d3237aac6553540ff5 (patch) | |
tree | 515a5fc821f4c1dbca6154d70300efb40bba141e /src | |
parent | ad960230962206012a14a04033e2c504f4c63fc2 (diff) | |
download | external_skia-e454fde2aeb9f50cae4ae6d3237aac6553540ff5.zip external_skia-e454fde2aeb9f50cae4ae6d3237aac6553540ff5.tar.gz external_skia-e454fde2aeb9f50cae4ae6d3237aac6553540ff5.tar.bz2 |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index da00d51..eb05959 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -685,6 +685,13 @@ void SkFontHost::FilterRec(SkScalerContext::Rec* rec) { #ifdef SK_BUILD_FOR_ANDROID uint32_t SkFontHost::GetUnitsPerEm(SkFontID fontID) { SkAutoMutexAcquire ac(gFTMutex); + FT_Library libInit = NULL; + if (gFTCount == 0) { + if (!InitFreetype()) + sk_throw(); + libInit = gFTLibrary; + } + SkAutoTCallIProc<struct FT_LibraryRec_, FT_Done_FreeType> ftLib(libInit); SkFaceRec *rec = ref_ft_face(fontID); uint16_t unitsPerEm = 0; |