Parse Xft.dpi with fraction
Some versions of GNOME 3 would set Xft.dpi with fraction though that is technically not valid. Change-Id: Ib1027283cc78fd5d9869cd337864a92e28cd7e88 Fixes: QTBUG-64738 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
This commit is contained in:
parent
0a09a6341d
commit
b2e3a5502a
@ -320,12 +320,22 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier,
|
||||
|
||||
static bool parseXftInt(const QByteArray& stringValue, int *value)
|
||||
{
|
||||
Q_ASSERT(value != 0);
|
||||
Q_ASSERT(value);
|
||||
bool ok;
|
||||
*value = stringValue.toInt(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool parseXftDpi(const QByteArray& stringValue, int *value)
|
||||
{
|
||||
Q_ASSERT(value);
|
||||
bool ok = parseXftInt(stringValue, value);
|
||||
// Support GNOME 3 bug that wrote DPI with fraction:
|
||||
if (!ok)
|
||||
*value = qRound(stringValue.toDouble(&ok));
|
||||
return ok;
|
||||
}
|
||||
|
||||
static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue)
|
||||
{
|
||||
if (stringValue == "hintfull")
|
||||
@ -391,7 +401,7 @@ void QXcbVirtualDesktop::readXResources()
|
||||
int value;
|
||||
QByteArray stringValue;
|
||||
if (xResource(r, "Xft.dpi:\t", stringValue)) {
|
||||
if (parseXftInt(stringValue, &value))
|
||||
if (parseXftDpi(stringValue, &value))
|
||||
m_forcedDpi = value;
|
||||
} else if (xResource(r, "Xft.hintstyle:\t", stringValue)) {
|
||||
m_hintStyle = parseXftHintStyle(stringValue);
|
||||
|
Loading…
Reference in New Issue
Block a user