Some more text layout tweeking

This commit is contained in:
Martin Tůma 2019-10-04 09:26:15 +02:00
parent a58962ab93
commit e8e9139740
2 changed files with 8 additions and 5 deletions

View File

@ -21,12 +21,12 @@ qreal TextItem::avgCharWidth() const
ratio = 1.0; ratio = 1.0;
// Greek & Cyrilic // Greek & Cyrilic
else if (cp >= 0x03FF && cp <= 0x04FF) { else if (cp >= 0x03FF && cp <= 0x04FF) {
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.75 : 0.68; ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.80 : 0.73;
if (_font.bold()) if (_font.bold())
ratio *= 1.1; ratio *= 1.1;
// The rest (Latin scripts, Arabic, ...) // The rest (Latin scripts, Arabic, ...)
} else { } else {
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.70 : 0.58; ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.75 : 0.63;
if (_font.bold()) if (_font.bold())
ratio *= 1.1; ratio *= 1.1;
} }

View File

@ -43,7 +43,11 @@ QRectF TextPointItem::exactBoundingRect() const
QRectF TextPointItem::fuzzyBoundingRect() const QRectF TextPointItem::fuzzyBoundingRect() const
{ {
int limit = font().pixelSize() * _maxWidth; int fs = font().pixelSize();
if (text().size() <= 3)
return QRectF(0, 0, text().size() * fs, fs * 1.6);
int limit = fs * _maxWidth;
qreal cw = avgCharWidth(); qreal cw = avgCharWidth();
int width = 0, lines = 0; int width = 0, lines = 0;
@ -77,8 +81,7 @@ QRectF TextPointItem::fuzzyBoundingRect() const
} }
} }
return QRectF(0, 0, width, lines > 1 ? lines * font().pixelSize() * 1.3 return QRectF(0, 0, width, lines * fs * 1.6);
: font().pixelSize() * 1.5);
} }