Make sure font weight value is within allowed range

wilder-portage
Mariusz Glebocki 7 years ago
parent 60ab2125e1
commit 5e91383e3f
  1. 4
      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; };

Loading…
Cancel
Save