Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Scale down artistic color selector numbers better

Carsten Hartenfelse6d8dc0d49bc
diff --git a/plugins/dockers/artisticcolorselector/kis_color_selector.cpp b/plugins/dockers/artisticcolorselector/kis_color_selector.cpp
index 216787ada1..0c4e647883 100644
--- a/plugins/dockers/artisticcolorselector/kis_color_selector.cpp
+++ b/plugins/dockers/artisticcolorselector/kis_color_selector.cpp
@@ -765,8 +765,19 @@ void KisColorSelector::drawLightStrip(QPainter& painter, const QRect& rect)
QFont font = painter.font();
QFontMetrics fm = painter.fontMetrics();
int retries = 10; // limit number of font size searches to prevent endless cycles
+ // Font size can be specified in points or pixels. If the font uses
+ // pixel sizes, the point size will be -1 and vice-versa.
+ bool inPointSize = font.pointSize() != -1;
while ((retries > 0) && (fm.boundingRect("100%").width() > rect.width()*rectColorLeftX)) {
- font.setPointSize(font.pointSize() - 1);
+ // Scale down with a proportional step size, otherwise large font
+ // sizes on scaled displays don't get small enough in 10 tries.
+ if (inPointSize) {
+ int pointSize = font.pointSize();
+ font.setPointSize(pointSize - (pointSize / 11 + 1));
+ } else {
+ int pixelSize = font.pixelSize();
+ font.setPixelSize(pixelSize - (pixelSize / 11 + 1));
+ }
painter.setFont(font);
fm = painter.fontMetrics();
retries--;