diff options
author | Jonas Karlsson <jonas.karlsson@qt.io> | 2020-08-13 16:53:14 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2020-09-03 17:22:50 +0200 |
commit | 0166028af40dce23408aac45f029e681343867e2 (patch) | |
tree | 8a04688d895f930122a1cb6657980882314035ed | |
parent | 0679197952609d4eda827d18d8f586f21decded8 (diff) |
Use OpenType font weights
In Designer, the only way the user can affect the weight
of the font is by checking/unchecking "bold", and this is
stored as a separate element in the XML. It is undefined
which one takes precedence if they do not match (in fact,
uic and Designer behaves differently in this case.)
To avoid this confusion as well as keep compatibility with
old files after we changed the scale of QFont::Weight to
match that of OpenType, we just ignore the weight element
in the input file.
We also stop writing the duplicate information to the file.
Task-number: QTBUG-42248
Change-Id: I08682f697a96d764c068e47bdab5d0f45cc2150b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r-- | src/designer/src/lib/uilib/properties.cpp | 6 | ||||
-rw-r--r-- | src/shared/fontpanel/fontpanel.cpp | 6 |
2 files changed, 2 insertions, 10 deletions
diff --git a/src/designer/src/lib/uilib/properties.cpp b/src/designer/src/lib/uilib/properties.cpp index f4eea9304..253196f2f 100644 --- a/src/designer/src/lib/uilib/properties.cpp +++ b/src/designer/src/lib/uilib/properties.cpp @@ -228,8 +228,6 @@ QVariant domPropertyToVariant(const DomProperty *p) f.setFamily(font->elementFamily()); if (font->hasElementPointSize() && font->elementPointSize() > 0) f.setPointSize(font->elementPointSize()); - if (font->hasElementWeight() && font->elementWeight() > 0) - f.setWeight(font->elementWeight()); if (font->hasElementItalic()) f.setItalic(font->elementItalic()); if (font->hasElementBold()) @@ -448,10 +446,8 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp DomFont *fnt = new DomFont(); const QFont font = qvariant_cast<QFont>(v); const uint mask = font.resolveMask(); - if (mask & QFont::WeightResolved) { + if (mask & QFont::WeightResolved) fnt->setElementBold(font.bold()); - fnt->setElementWeight(font.weight()); - } if (mask & QFont::FamilyResolved) fnt->setElementFamily(font.family()); if (mask & QFont::StyleResolved) diff --git a/src/shared/fontpanel/fontpanel.cpp b/src/shared/fontpanel/fontpanel.cpp index 45d2a456e..d3c22762a 100644 --- a/src/shared/fontpanel/fontpanel.cpp +++ b/src/shared/fontpanel/fontpanel.cpp @@ -105,11 +105,7 @@ QFont FontPanel::selectedFont() const else rc.setStyle(QFont::StyleNormal); rc.setBold(m_fontDatabase.bold(family, styleDescription)); - - // Weight < 0 asserts... - const int weight = m_fontDatabase.weight(family, styleDescription); - if (weight >= 0) - rc.setWeight(weight); + rc.setWeight(QFont::Weight(m_fontDatabase.weight(family, styleDescription))); return rc; } |