diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 727d49c3..5753ae74 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -777,10 +777,12 @@ void TerminalDisplay::drawCharacters(QPainter& painter, return; } + static constexpr int MaxFontWeight = 99; // https://doc.qt.io/qt-5/qfont.html#Weight-enum + const int normalWeight = font().weight(); // +26 makes "bold" from "normal", "normal" from "light", etc. It is 26 instead of not 25 to prefer // bolder weight when 25 falls in the middle between two weights. See QFont::Weight - const int boldWeight = normalWeight + 26; + const int boldWeight = qMin(normalWeight + 26, MaxFontWeight); const auto isBold = [boldWeight](const QFont &font) { return font.weight() >= boldWeight; };