Bug 1454598 - part 1 - Make gfxFcPlatformFontList::GetFTLibrary work before font system is fully up and running, so that the global FT_Library can be used during initialization of the font list itself.

This commit is contained in:
Jonathan Kew 2018-04-17 21:45:29 +01:00
Родитель 417ce944be
Коммит 6b0c3d90d8
2 изменённых файлов: 22 добавлений и 23 удалений

Просмотреть файл

@ -2178,27 +2178,26 @@ gfxFcPlatformFontList::GetFTLibrary()
// so use the hacky method below of making a font and extracting
// the library pointer from that.
bool needsBold;
gfxFontStyle style;
gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList();
gfxFontFamily* family = pfl->GetDefaultFont(&style);
NS_ASSERTION(family, "couldn't find a default font family");
gfxFontEntry* fe = family->FindFontForStyle(style, needsBold, true);
if (!fe) {
return nullptr;
}
RefPtr<gfxFont> font = fe->FindOrMakeFont(&style, false);
if (!font) {
return nullptr;
}
FcPattern* pat =
FcPatternBuild(0, FC_FAMILY, FcTypeString, "serif", (char*)0);
cairo_font_face_t* face =
cairo_ft_font_face_create_for_pattern(pat, nullptr, 0);
FcPatternDestroy(pat);
gfxFT2FontBase* ft2Font = reinterpret_cast<gfxFT2FontBase*>(font.get());
gfxFT2LockedFace face(ft2Font);
if (!face.get()) {
return nullptr;
}
cairo_matrix_t identity;
cairo_matrix_init_identity(&identity);
cairo_font_options_t* options = cairo_font_options_create();
cairo_scaled_font_t* sf =
cairo_scaled_font_create(face, &identity, &identity, options);
cairo_font_options_destroy(options);
cairo_font_face_destroy(face);
sCairoFTLibrary = face.get()->glyph->library;
FT_Face ft = cairo_ft_scaled_font_lock_face(sf);
sCairoFTLibrary = ft->glyph->library;
cairo_ft_scaled_font_unlock_face(sf);
cairo_scaled_font_destroy(sf);
}
return sCairoFTLibrary;

Просмотреть файл

@ -775,6 +775,10 @@ gfxPlatform::Init()
gPlatform->PopulateScreenInfo();
gPlatform->ComputeTileSize();
#ifdef MOZ_ENABLE_FREETYPE
Factory::SetFTLibrary(gPlatform->GetFTLibrary());
#endif
nsresult rv;
rv = gfxPlatformFontList::Init();
if (NS_FAILED(rv)) {
@ -806,10 +810,6 @@ gfxPlatform::Init()
MOZ_CRASH("Could not initialize gfxFontCache");
}
#ifdef MOZ_ENABLE_FREETYPE
Factory::SetFTLibrary(gPlatform->GetFTLibrary());
#endif
/* Create and register our CMS Override observer. */
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver, GFX_PREF_CMS_FORCE_SRGB);