1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

A better QPainter text rect inconsistency workaround

This commit is contained in:
Martin Tůma 2024-11-15 20:23:48 +01:00
parent 734ba4bf44
commit 2fdbc25ca3

View File

@ -27,7 +27,7 @@ TextPointItem::TextPointItem(const QPoint &point, const QString *text,
QFontMetrics fm(*_font); QFontMetrics fm(*_font);
int limit = _font->pixelSize() * MAX_TEXT_WIDTH; int limit = _font->pixelSize() * MAX_TEXT_WIDTH;
_textRect = fm.boundingRect(QRect(0, 0, limit, 0), FLAGS, *_text); _textRect = fm.boundingRect(QRect(0, 0, limit, 0), FLAGS, *_text);
_textRect.adjust(0, 0, 1, 1); _textRect.adjust(-1, 0, 2, 0);
if (_bgColor && _textRect.width() < _font->pixelSize() * MIN_BOX_WIDTH) if (_bgColor && _textRect.width() < _font->pixelSize() * MIN_BOX_WIDTH)
expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH); expand(_textRect, _font->pixelSize() * MIN_BOX_WIDTH);