mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-27 21:24:48 +01:00
Some more text layout tweeking
This commit is contained in:
parent
a58962ab93
commit
e8e9139740
@ -21,12 +21,12 @@ qreal TextItem::avgCharWidth() const
|
||||
ratio = 1.0;
|
||||
// Greek & Cyrilic
|
||||
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())
|
||||
ratio *= 1.1;
|
||||
// The rest (Latin scripts, Arabic, ...)
|
||||
} else {
|
||||
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.70 : 0.58;
|
||||
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.75 : 0.63;
|
||||
if (_font.bold())
|
||||
ratio *= 1.1;
|
||||
}
|
||||
|
@ -43,7 +43,11 @@ QRectF TextPointItem::exactBoundingRect() 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();
|
||||
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
|
||||
: font().pixelSize() * 1.5);
|
||||
return QRectF(0, 0, width, lines * fs * 1.6);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user