From f1beb28c461ba162d27e87bc7a23183989a5b9fd Mon Sep 17 00:00:00 2001 From: Kyu Man Lim Date: Fri, 10 Feb 2017 10:21:33 +0900 Subject: Add a way to disable syntethesized bold and italic support Using the environment variables QT_NO_SYNTHESIZED_BOLD and QT_NO_SYNTHESIZED_ITALIC it is now possible to disable the support for synthesized bold and italic, which is used when the font doesn't support those variants. Change-Id: Ic1a6984858e1260f252662689705553073859df4 Task-number: QTBUG-83124 Pick-to: 5.15 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/coretext/qfontengine_coretext.mm | 4 ++-- src/gui/text/freetype/qfontengine_ft.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/text/coretext/qfontengine_coretext.mm b/src/gui/text/coretext/qfontengine_coretext.mm index 7f9eb2d78d..398e8df32c 100644 --- a/src/gui/text/coretext/qfontengine_coretext.mm +++ b/src/gui/text/coretext/qfontengine_coretext.mm @@ -258,10 +258,10 @@ void QCoreTextFontEngine::init() if (slant > 500 && !(traits & kCTFontItalicTrait)) fontDef.style = QFont::StyleOblique; - if (fontDef.weight >= QFont::Bold && !(traits & kCTFontBoldTrait)) + if (fontDef.weight >= QFont::Bold && !(traits & kCTFontBoldTrait) && !qEnvironmentVariableIsSet("QT_NO_SYNTHESIZED_BOLD")) synthesisFlags |= SynthesizedBold; // XXX: we probably don't need to synthesis italic for oblique font - if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait)) + if (fontDef.style != QFont::StyleNormal && !(traits & kCTFontItalicTrait) && !qEnvironmentVariableIsSet("QT_NO_SYNTHESIZED_ITALIC")) synthesisFlags |= SynthesizedItalic; avgCharWidth = 0; diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index 96f11e6e42..e50cfe584e 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -742,13 +742,13 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, FT_Face face = lockFace(); if (FT_IS_SCALABLE(face)) { - bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); + bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC) && !qEnvironmentVariableIsSet("QT_NO_SYNTHESIZED_ITALIC"); if (fake_oblique) obliquen = true; FT_Set_Transform(face, &matrix, nullptr); freetype->matrix = matrix; // fake bold - if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) { + if ((fontDef.weight >= QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face) && !qEnvironmentVariableIsSet("QT_NO_SYNTHESIZED_BOLD")) { if (const TT_OS2 *os2 = reinterpret_cast(FT_Get_Sfnt_Table(face, ft_sfnt_os2))) { if (os2->usWeightClass < 700) embolden = true; -- cgit v1.2.3