Mercurial > hg > svgui
changeset 1607:52d4bfba5b3d
Reduce font size when pane is very thin
author | Chris Cannam |
---|---|
date | Wed, 06 May 2020 11:44:38 +0100 |
parents | d6976d231efb |
children | 6616e1899daa |
files | view/View.cpp |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/view/View.cpp Wed May 06 09:08:37 2020 +0100 +++ b/view/View.cpp Wed May 06 11:44:38 2020 +0100 @@ -2199,8 +2199,19 @@ } QFont font(paint.font()); - font.setPointSize(Preferences::getInstance()->getViewFontSize() - * scaleFactor); + int pointSize = Preferences::getInstance()->getViewFontSize() * scaleFactor; + font.setPointSize(pointSize); + + int h = height(); + int fh = QFontMetrics(font).height(); + if (pointSize > 6) { + if (h < fh * 2.1) { + font.setPointSize(pointSize - 2); + } else if (h < fh * 3.1) { + font.setPointSize(pointSize - 1); + } + } + paint.setFont(font); }