Fix regression in QTextDocument::toHtml() with font pixel size
Introduced by 2e0003eda4783f69a40fb4b31e7084c761d9640d. We were missing a attributesEmitted=true which caused the output from toHtml() to sometimes be invalid when using pixel sizes to specify the font size. Task-number: QTBUG-25778 Change-Id: Ied61fcaef425a590d71c0b52292ac676cb88ba52 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Jiang Jiang <gzjjgod@gmail.com>
This commit is contained in:
parent
ee1e37cc64
commit
e640ebacb9
@ -2142,6 +2142,7 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
|
|||||||
html += QLatin1String(" font-size:");
|
html += QLatin1String(" font-size:");
|
||||||
html += QString::number(format.intProperty(QTextFormat::FontPixelSize));
|
html += QString::number(format.intProperty(QTextFormat::FontPixelSize));
|
||||||
html += QLatin1String("px;");
|
html += QLatin1String("px;");
|
||||||
|
attributesEmitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format.hasProperty(QTextFormat::FontWeight)
|
if (format.hasProperty(QTextFormat::FontWeight)
|
||||||
|
@ -180,6 +180,8 @@ private slots:
|
|||||||
|
|
||||||
void copiedFontSize();
|
void copiedFontSize();
|
||||||
|
|
||||||
|
void QTBUG25778_pixelSizeFromHtml();
|
||||||
|
|
||||||
void htmlExportImportBlockCount();
|
void htmlExportImportBlockCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2840,6 +2842,18 @@ void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange()
|
|||||||
QCOMPARE(rec.first, QString("contentsChanged"));
|
QCOMPARE(rec.first, QString("contentsChanged"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QTextDocument::QTBUG25778_pixelSizeFromHtml()
|
||||||
|
{
|
||||||
|
QTextDocument document1;
|
||||||
|
QTextDocument document2;
|
||||||
|
|
||||||
|
document1.setHtml("<span style=\"font-size: 24px\">Foobar</span>");
|
||||||
|
document2.setHtml(document1.toHtml());
|
||||||
|
|
||||||
|
QTextCursor cursor(&document2);
|
||||||
|
QCOMPARE(cursor.charFormat().font().pixelSize(), 24);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QTextDocument::copiedFontSize()
|
void tst_QTextDocument::copiedFontSize()
|
||||||
{
|
{
|
||||||
QTextDocument documentInput;
|
QTextDocument documentInput;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user