Skip to content

Commit e1b220e

Browse files
committed
Fix player scrubbar text too big
This was observed on Ubuntu 24.04 on Wayland with 1.25 display scaling.
1 parent 49715be commit e1b220e

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/scrubbar.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ ScrubBar::ScrubBar(QWidget *parent)
5050
void ScrubBar::setScale(int maximum)
5151
{
5252
if (!m_timecodeWidth) {
53-
const int fontSize = font().pointSize()
54-
- (font().pointSize() > 10 ? 2 : (font().pointSize() > 8 ? 1 : 0));
55-
setFont(QFont(font().family(), fontSize * devicePixelRatioF()));
56-
m_timecodeWidth = fontMetrics().horizontalAdvance("00:00:00:00") / devicePixelRatioF();
53+
auto font = QWidget::font();
54+
const int fontSize = font.pointSize()
55+
- (font.pointSize() > 10 ? 2 : (font.pointSize() > 8 ? 1 : 0));
56+
font.setPointSizeF(devicePixelRatioF() * fontSize);
57+
m_timecodeWidth = QFontMetrics(font).horizontalAdvance("00:00:00:00") / devicePixelRatioF();
5758
}
5859
m_max = maximum;
5960
/// m_scale is the pixels per frame ratio
@@ -283,8 +284,10 @@ void ScrubBar::updatePixmap()
283284
m_pixmap = QPixmap(l_width, l_height);
284285
m_pixmap.fill(palette().window().color());
285286
QPainter p(&m_pixmap);
286-
p.setFont(font());
287-
const int markerHeight = fontMetrics().ascent() + 2 * ratio;
287+
QFont font(QWidget::font());
288+
font.setPointSizeF(font.pointSizeF() * ratio);
289+
p.setFont(font);
290+
const int markerHeight = QFontMetrics(font).ascent() + 2;
288291
QPen pen;
289292

290293
if (!isEnabled()) {

0 commit comments

Comments
 (0)