Commit 6733a936 authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Convert QFontMetrics depreciated width to horizontalAdvance

This change matches what Qt was doing behind the scenes.

int QFontMetrics::width(QChar ch) const
    return horizontalAdvance(ch);
int QFontMetrics::width(const QString &text, int len) const
    return horizontalAdvance(text, len);

Tested with varies files in the konsole/tests folder.
parent 5c793cb0
......@@ -237,13 +237,13 @@ void TerminalDisplay::fontChange(const QFont&)
// "Base character width on widest ASCII character. This prevents too wide
// characters in the presence of double wide (e.g. Japanese) characters."
// Get the width from representative normal width characters
_fontWidth = qRound((static_cast<double>(fm.width(QStringLiteral(REPCHAR))) / static_cast<double>(qstrlen(REPCHAR))));
_fontWidth = qRound((static_cast<double>(fm.horizontalAdvance(QStringLiteral(REPCHAR))) / static_cast<double>(qstrlen(REPCHAR))));
_fixedFont = true;
const int fw = fm.width(QLatin1Char(REPCHAR[0]));
const int fw = fm.horizontalAdvance(QLatin1Char(REPCHAR[0]));
for (unsigned int i = 1; i < qstrlen(REPCHAR); i++) {
if (fw != fm.width(QLatin1Char(REPCHAR[i]))) {
if (fw != fm.horizontalAdvance(QLatin1Char(REPCHAR[i]))) {
_fixedFont = false;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment