Fix bugs causing Thin font weights to be ignored or mishandled.
Task-number: QTBUG-53196 Change-Id: If12b3cab3d8de5e0e452fca844b0a484c29e9e86 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
bb30da895e
commit
a160bd4fcc
@ -2730,8 +2730,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
|
|||||||
}
|
}
|
||||||
if (req.pointSize < 0)
|
if (req.pointSize < 0)
|
||||||
req.pointSize = req.pixelSize*72.0/d->dpi;
|
req.pointSize = req.pixelSize*72.0/d->dpi;
|
||||||
if (req.weight == 0)
|
req.weight = QFont::Normal;
|
||||||
req.weight = QFont::Normal;
|
|
||||||
if (req.stretch == 0)
|
if (req.stretch == 0)
|
||||||
req.stretch = 100;
|
req.stretch = 100;
|
||||||
|
|
||||||
|
@ -1840,8 +1840,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
|
|||||||
request.family = fallbackFamilyAt(at - 1);
|
request.family = fallbackFamilyAt(at - 1);
|
||||||
|
|
||||||
if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) {
|
if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) {
|
||||||
if (request.weight > QFont::Normal)
|
engine->fontDef.weight = request.weight;
|
||||||
engine->fontDef.weight = request.weight;
|
|
||||||
if (request.style > QFont::StyleNormal)
|
if (request.style > QFont::StyleNormal)
|
||||||
engine->fontDef.style = request.style;
|
engine->fontDef.style = request.style;
|
||||||
return engine;
|
return engine;
|
||||||
|
@ -357,9 +357,10 @@ void QTextFormatPrivate::recalcFont() const
|
|||||||
f.setPixelSize(props.at(i).value.toInt());
|
f.setPixelSize(props.at(i).value.toInt());
|
||||||
break;
|
break;
|
||||||
case QTextFormat::FontWeight: {
|
case QTextFormat::FontWeight: {
|
||||||
int weight = props.at(i).value.toInt();
|
const QVariant weightValue = props.at(i).value;
|
||||||
if (weight == 0) weight = QFont::Normal;
|
int weight = weightValue.toInt();
|
||||||
f.setWeight(weight);
|
if (weight >= 0 && weightValue.isValid())
|
||||||
|
f.setWeight(weight);
|
||||||
break; }
|
break; }
|
||||||
case QTextFormat::FontItalic:
|
case QTextFormat::FontItalic:
|
||||||
f.setItalic(props.at(i).value.toBool());
|
f.setItalic(props.at(i).value.toBool());
|
||||||
|
@ -424,9 +424,9 @@ public:
|
|||||||
{ return doubleProperty(FontPointSize); }
|
{ return doubleProperty(FontPointSize); }
|
||||||
|
|
||||||
inline void setFontWeight(int weight)
|
inline void setFontWeight(int weight)
|
||||||
{ if (weight == QFont::Normal) weight = 0; setProperty(FontWeight, weight); }
|
{ setProperty(FontWeight, weight); }
|
||||||
inline int fontWeight() const
|
inline int fontWeight() const
|
||||||
{ int weight = intProperty(FontWeight); if (weight == 0) weight = QFont::Normal; return weight; }
|
{ return hasProperty(FontWeight) ? intProperty(FontWeight) : QFont::Normal; }
|
||||||
inline void setFontItalic(bool italic)
|
inline void setFontItalic(bool italic)
|
||||||
{ setProperty(FontItalic, italic); }
|
{ setProperty(FontItalic, italic); }
|
||||||
inline bool fontItalic() const
|
inline bool fontItalic() const
|
||||||
|
@ -1342,8 +1342,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
QWindowsFontEngineDirectWrite *fedw = new QWindowsFontEngineDirectWrite(directWriteFontFace,
|
||||||
fontEngine->fontDef.pixelSize,
|
fontEngine->fontDef.pixelSize,
|
||||||
data);
|
data);
|
||||||
if (fontEngine->fontDef.weight > QFont::Normal)
|
fedw->fontDef.weight = fontEngine->fontDef.weight;
|
||||||
fedw->fontDef.weight = fontEngine->fontDef.weight;
|
|
||||||
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
||||||
fedw->fontDef.style = fontEngine->fontDef.style;
|
fedw->fontDef.style = fontEngine->fontDef.style;
|
||||||
fedw->fontDef.family = fam;
|
fedw->fontDef.family = fam;
|
||||||
@ -1360,8 +1359,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
// reason
|
// reason
|
||||||
|
|
||||||
QFontEngine *fe = new QWindowsFontEngine(fam, lf, data);
|
QFontEngine *fe = new QWindowsFontEngine(fam, lf, data);
|
||||||
if (fontEngine->fontDef.weight > QFont::Normal)
|
fe->fontDef.weight = fontEngine->fontDef.weight;
|
||||||
fe->fontDef.weight = fontEngine->fontDef.weight;
|
|
||||||
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
if (fontEngine->fontDef.style > QFont::StyleNormal)
|
||||||
fe->fontDef.style = fontEngine->fontDef.style;
|
fe->fontDef.style = fontEngine->fontDef.style;
|
||||||
fe->fontDef.family = fam;
|
fe->fontDef.family = fam;
|
||||||
|
@ -106,8 +106,6 @@ void tst_QFontCache::engineData()
|
|||||||
}
|
}
|
||||||
if (req.pointSize < 0)
|
if (req.pointSize < 0)
|
||||||
req.pointSize = req.pixelSize*72.0/d->dpi;
|
req.pointSize = req.pixelSize*72.0/d->dpi;
|
||||||
if (req.weight == 0)
|
|
||||||
req.weight = QFont::Normal;
|
|
||||||
if (req.stretch == 0)
|
if (req.stretch == 0)
|
||||||
req.stretch = 100;
|
req.stretch = 100;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user