Bug 1558375 - Don't set the FT_LOAD_NO_AUTOHINT flag for fonts that have FT_FACE_FLAG_TRICKY, to avoid broken rendering. r=lsalzman

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-06-15 05:27:40 +00:00
Родитель 98d7f04ed2
Коммит 9dbb54dd9e
5 изменённых файлов: 24 добавлений и 2 удалений

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

@ -133,6 +133,9 @@ already_AddRefed<ScaledFont> UnscaledFontFreeType::CreateScaledFont(
}
int flags = FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
if (face->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
cairo_font_face_t* font = cairo_ft_font_face_create_for_ft_face(
face, flags, coords.data(), aNumVariations);
if (cairo_font_face_status(font) != CAIRO_STATUS_SUCCESS) {

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

@ -393,9 +393,13 @@ SkScalerContext_CairoFT::SkScalerContext_CairoFT(sk_sp<SkTypeface> typeface, con
}
}
// Disable autohinting to disable hinting even for "tricky" fonts.
// Disable autohinting when asked to disable hinting, except for "tricky" fonts.
if (!gFontHintingEnabled) {
loadFlags |= FT_LOAD_NO_AUTOHINT;
CairoLockedFTFace faceLock(fScaledFont);
FT_Face face = faceLock.getFace();
if (!(face->face_flags & FT_FACE_FLAG_TRICKY)) {
loadFlags |= FT_LOAD_NO_AUTOHINT;
}
}
if ((fRec.fFlags & SkScalerContext::kEmbeddedBitmapText_Flag) == 0) {

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

@ -508,6 +508,9 @@ bool gfxFT2FontBase::GetFTGlyphAdvance(uint16_t aGID, int32_t* aAdvance) {
int32_t flags =
hinting ? FT_LOAD_ADVANCE_ONLY
: FT_LOAD_ADVANCE_ONLY | FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING;
if (face.get()->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
FT_Error ftError = Factory::LoadFTGlyph(face.get(), aGID, flags);
if (ftError != FT_Err_Ok) {
// FT_Face was somehow broken/invalid? Don't try to access glyph slot.

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

@ -383,6 +383,9 @@ FT2FontEntry* FT2FontEntry::CreateFontEntry(
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled()
? FT_LOAD_DEFAULT
: (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
if (aFace->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
fe->mFontFace =
cairo_ft_font_face_create_for_ft_face(aFace, flags, nullptr, 0);
FTUserFontData* userFontData =
@ -424,6 +427,9 @@ cairo_font_face_t* FT2FontEntry::CairoFontFace(const gfxFontStyle* aStyle) {
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled()
? FT_LOAD_DEFAULT
: (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
if (FT_Face(face)->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
mFontFace = cairo_ft_font_face_create_for_ft_face(face, flags, nullptr, 0);
auto userFontData =
new FTUserFontData(face, face.FontData(), face.DataLength());
@ -441,6 +447,9 @@ cairo_font_face_t* FT2FontEntry::CairoFontFace(const gfxFontStyle* aStyle) {
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled()
? FT_LOAD_DEFAULT
: (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
if (mFTFace->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
// Resolve variations from entry (descriptor) and style (property)
AutoTArray<gfxFontVariation, 8> settings;
GetVariationsForStyle(settings, aStyle ? *aStyle : gfxFontStyle());

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

@ -204,6 +204,9 @@ void gfxFT2Font::FillGlyphDataForChar(FT_Face face, uint32_t ch,
FT_Int32 flags = gfxPlatform::GetPlatform()->FontHintingEnabled()
? FT_LOAD_DEFAULT
: (FT_LOAD_NO_AUTOHINT | FT_LOAD_NO_HINTING);
if (face->face_flags & FT_FACE_FLAG_TRICKY) {
flags &= ~FT_LOAD_NO_AUTOHINT;
}
FT_Error err = Factory::LoadFTGlyph(face, gid, flags);
if (err) {