mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-05-25 07:14:13 +02:00
XFA: rich text rendering fix
This commit is contained in:
parent
f5131dc7ed
commit
c68380ab03
@ -26,6 +26,7 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
#include <QAbstractTextDocumentLayout>
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -11806,29 +11807,37 @@ void PDFXFAEngineImpl::drawUiTextEdit(const xfa::XFA_textEdit* textEdit,
|
|||||||
QVector<QTextLayout::FormatRange> textFormats = block.textFormats();
|
QVector<QTextLayout::FormatRange> textFormats = block.textFormats();
|
||||||
for (const QTextLayout::FormatRange& formatRange : textFormats)
|
for (const QTextLayout::FormatRange& formatRange : textFormats)
|
||||||
{
|
{
|
||||||
QTextCharFormat format = formatRange.format;
|
QTextCharFormat charFormat = formatRange.format;
|
||||||
QFont font = format.font();
|
QFont font = charFormat.font();
|
||||||
|
|
||||||
if (font.pointSizeF() < 0)
|
if (font.pointSizeF() > 0)
|
||||||
{
|
{
|
||||||
continue;
|
font.setPixelSize(qFloor(font.pointSizeF()));
|
||||||
}
|
}
|
||||||
|
|
||||||
font.setPixelSize(qFloor(font.pointSizeF()));
|
|
||||||
font.setHintingPreference(QFont::PreferNoHinting);
|
font.setHintingPreference(QFont::PreferNoHinting);
|
||||||
format.setFont(font, QTextCharFormat::FontPropertiesAll);
|
charFormat.setFont(font, QTextCharFormat::FontPropertiesAll);
|
||||||
|
|
||||||
QTextCursor cursor(block);
|
QTextCursor cursor(block);
|
||||||
cursor.setPosition(block.position() + formatRange.start, QTextCursor::MoveAnchor);
|
cursor.setPosition(block.position() + formatRange.start, QTextCursor::MoveAnchor);
|
||||||
cursor.setPosition(block.position() + formatRange.start + formatRange.length, QTextCursor::KeepAnchor);
|
cursor.setPosition(block.position() + formatRange.start + formatRange.length, QTextCursor::KeepAnchor);
|
||||||
cursor.mergeCharFormat(format);
|
cursor.mergeCharFormat(charFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
block = block.next();
|
block = block.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.setPageSize(textRect.size());
|
document.setPageSize(textRect.size());
|
||||||
document.drawContents(painter);
|
|
||||||
|
if (document.pageCount() > 1)
|
||||||
|
{
|
||||||
|
// Jakub Melka: we do not have enough space, try to make more,
|
||||||
|
// we are still using clip rectangle.
|
||||||
|
QSizeF size = document.documentLayout()->documentSize();
|
||||||
|
document.setPageSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.drawContents(painter, textRect.translated(-textRect.topLeft()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user