mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-24 03:35:54 +01:00
Added missing source file
This commit is contained in:
parent
6d02dafeb6
commit
738ada91c2
35
src/textitem.cpp
Normal file
35
src/textitem.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "textitem.h"
|
||||
|
||||
bool TextItem::collidesWithItem(const TextItem *other) const
|
||||
{
|
||||
QRectF r1(boundingRect());
|
||||
QRectF r2(other->boundingRect());
|
||||
|
||||
if (r1.isEmpty() || r2.isEmpty() || !r1.intersects(r2))
|
||||
return false;
|
||||
|
||||
return other->shape().intersects(shape());
|
||||
}
|
||||
|
||||
int TextItem::avgCharWidth() const
|
||||
{
|
||||
qreal ratio;
|
||||
ushort cp = _text.at(0).unicode();
|
||||
|
||||
// CJK & East Asian scripts
|
||||
if (cp >= 0x2E80)
|
||||
ratio = 1.0;
|
||||
// Greek & Cyrilic
|
||||
else if (cp >= 0x03FF && cp <= 0x04FF) {
|
||||
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.75 : 0.67;
|
||||
if (_font.bold())
|
||||
ratio *= 1.1;
|
||||
// The rest (Latin scripts, Arabic, ...)
|
||||
} else {
|
||||
ratio = (_font.capitalization() == QFont::AllUppercase) ? 0.7 : 0.55;
|
||||
if (_font.bold())
|
||||
ratio *= 1.1;
|
||||
}
|
||||
|
||||
return ratio * _font.pixelSize();
|
||||
}
|
Loading…
Reference in New Issue
Block a user