Bug 1511131 - init UnscaledFontFreeType's face from file when creating scaled fonts. r=jnicol

Differential Revision: https://phabricator.services.mozilla.com/D27126

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Lee Salzman 2019-04-12 12:48:56 +00:00
parent e0060de75c
commit 4140aef08f
2 changed files with 20 additions and 1 deletions

View File

@ -75,6 +75,23 @@ bool ScaledFontFreeType::GetWRFontInstanceOptions(
return true;
}
FT_Face UnscaledFontFreeType::InitFace() {
if (mFace) {
return mFace;
}
if (mFile.empty()) {
return nullptr;
}
FT_Face face = Factory::NewFTFace(nullptr, mFile.c_str(), mIndex);
if (!face) {
gfxWarning() << "Failed initializing FreeType face from filename";
return nullptr;
}
mOwnsFace = true;
mFace = face;
return mFace;
}
static cairo_user_data_key_t sNativeFontResourceKey;
static void ReleaseNativeFontResource(void* aData) {
@ -91,7 +108,7 @@ already_AddRefed<ScaledFont> UnscaledFontFreeType::CreateScaledFont(
Float aGlyphSize, const uint8_t* aInstanceData,
uint32_t aInstanceDataLength, const FontVariation* aVariations,
uint32_t aNumVariations) {
FT_Face face = GetFace();
FT_Face face = InitFace();
if (!face) {
gfxWarning() << "Attempted to deserialize FreeType scaled font without "
"FreeType face";

View File

@ -56,6 +56,8 @@ class UnscaledFontFreeType : public UnscaledFont {
bool GetWRFontDescriptor(WRFontDescriptorOutput aCb, void* aBaton) override;
#ifdef MOZ_WIDGET_ANDROID
FT_Face InitFace();
already_AddRefed<ScaledFont> CreateScaledFont(
Float aGlyphSize, const uint8_t* aInstanceData,
uint32_t aInstanceDataLength, const FontVariation* aVariations,