Freetype: Don't embolden bold fonts

If a font does not set the "bold" flag in its OS/2 table, we check
the weight from the same table to determine whether it is bold or
if we have to embolden it synthetically. But the actual definition of
bold in OS/2 is 700 (which is also what QFont::Bold is documented
to correspond to in qfont.h).

The result was that we would embolden fonts with bold weight if
the bold flag was not set. An example of such a font was the
CJK JP family of Noto Sans.

[ChangeLog][Text] Fixed a problem where certain bold fonts would be
synthetically emboldened by Qt when using the Freetype font engine.

Fixes: QTBUG-80866
Change-Id: I2133d9c44a9e19c0f5f216a649ec64388245d34f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2020-01-02 08:34:38 +01:00
parent 2ced01cbdd
commit 947704cefe

View File

@ -749,7 +749,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format,
// fake bold
if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) {
if (const TT_OS2 *os2 = reinterpret_cast<const TT_OS2 *>(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) {
if (os2->usWeightClass < 750)
if (os2->usWeightClass < 700)
embolden = true;
}
}