Bugfixing of text layout

This commit is contained in:
Jakub Melka
2019-12-29 17:25:18 +01:00
parent 0c97e21f54
commit afbf37d068
9 changed files with 125 additions and 8 deletions

View File

@ -21,6 +21,7 @@
#include "pdfglobal.h"
#include <QRectF>
#include <QByteArray>
#include <QDataStream>
@ -407,6 +408,27 @@ private:
std::vector<T> m_indices;
};
template<typename T>
constexpr bool isIntervalOverlap(T x1_min, T x1_max, T x2_min, T x2_max)
{
// We have two situations, where intervals doesn't overlap:
// 1) |--------| |---------|
// x1_min x1_max x2_min x2_max
// 2) |--------| |---------|
// x2_min x2_max x1_min x1_max
if (x1_max < x2_min || x2_max < x1_min)
{
return false;
}
return true;
}
constexpr bool isRectangleHorizontallyOverlapped(const QRectF& r1, const QRectF& r2)
{
return isIntervalOverlap(r1.left(), r1.right(), r2.left(), r2.right());
}
} // namespace pdf
#endif // PDFUTILS_H