Copy stretch to multifont fontDef
If we do not the fontDef of the multifont will be the default 0. Task-number: QTBUG-59443 Change-Id: Ib223517975b2a57b2371e309d12cd8f918d30825 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
b67b80b715
commit
efb84b6189
@ -2556,6 +2556,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
|
|||||||
qreal size = ti.fontEngine->fontDef.pixelSize;
|
qreal size = ti.fontEngine->fontDef.pixelSize;
|
||||||
int synthesized = ti.fontEngine->synthesized();
|
int synthesized = ti.fontEngine->synthesized();
|
||||||
qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.;
|
qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.;
|
||||||
|
Q_ASSERT(stretch > qreal(0));
|
||||||
|
|
||||||
QTransform trans;
|
QTransform trans;
|
||||||
// Build text rendering matrix (Trm). We need it to map the text area to user
|
// Build text rendering matrix (Trm). We need it to map the text area to user
|
||||||
@ -2632,6 +2633,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
|
|||||||
return;
|
return;
|
||||||
int synthesized = ti.fontEngine->synthesized();
|
int synthesized = ti.fontEngine->synthesized();
|
||||||
qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.;
|
qreal stretch = synthesized & QFontEngine::SynthesizedStretch ? ti.fontEngine->fontDef.stretch/100. : 1.;
|
||||||
|
Q_ASSERT(stretch > qreal(0));
|
||||||
|
|
||||||
*currentPage << "BT\n"
|
*currentPage << "BT\n"
|
||||||
<< "/F" << font->object_id << size << "Tf "
|
<< "/F" << font->object_id << size << "Tf "
|
||||||
|
@ -1293,6 +1293,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
fedw->fontDef.style = fontEngine->fontDef.style;
|
fedw->fontDef.style = fontEngine->fontDef.style;
|
||||||
fedw->fontDef.family = fam;
|
fedw->fontDef.family = fam;
|
||||||
fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
fedw->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
||||||
|
fedw->fontDef.stretch = fontEngine->fontDef.stretch;
|
||||||
return fedw;
|
return fedw;
|
||||||
} else {
|
} else {
|
||||||
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
|
qErrnoWarning("%s: CreateFontFace failed", __FUNCTION__);
|
||||||
@ -1310,6 +1311,7 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
|
|||||||
fe->fontDef.style = fontEngine->fontDef.style;
|
fe->fontDef.style = fontEngine->fontDef.style;
|
||||||
fe->fontDef.family = fam;
|
fe->fontDef.family = fam;
|
||||||
fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
fe->fontDef.hintingPreference = fontEngine->fontDef.hintingPreference;
|
||||||
|
fe->fontDef.stretch = fontEngine->fontDef.stretch;
|
||||||
return fe;
|
return fe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,11 @@
|
|||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
|
#include <QtGui/QAbstractTextDocumentLayout>
|
||||||
#include <QtGui/QPageLayout>
|
#include <QtGui/QPageLayout>
|
||||||
#include <QtGui/QPdfWriter>
|
#include <QtGui/QPdfWriter>
|
||||||
|
#include <QtGui/QTextCursor>
|
||||||
|
#include <QtGui/QTextDocument>
|
||||||
|
|
||||||
class tst_QPdfWriter : public QObject
|
class tst_QPdfWriter : public QObject
|
||||||
{
|
{
|
||||||
@ -40,6 +43,7 @@ private slots:
|
|||||||
void basics();
|
void basics();
|
||||||
void testPageMetrics_data();
|
void testPageMetrics_data();
|
||||||
void testPageMetrics();
|
void testPageMetrics();
|
||||||
|
void qtbug59443();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QPdfWriter::basics()
|
void tst_QPdfWriter::basics()
|
||||||
@ -245,6 +249,28 @@ void tst_QPdfWriter::testPageMetrics()
|
|||||||
QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
|
QCOMPARE(writer.pageLayout().paintRect(QPageLayout::Millimeter), QRectF(leftMMf, topMMf, heightMMf - leftMMf - rightMMf, widthMMf - topMMf - bottomMMf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QPdfWriter::qtbug59443()
|
||||||
|
{
|
||||||
|
// Do not crash or assert
|
||||||
|
QTemporaryFile file;
|
||||||
|
QVERIFY2(file.open(), qPrintable(file.errorString()));
|
||||||
|
QPdfWriter writer(file.fileName());
|
||||||
|
writer.setPageSize(QPdfWriter::A4);
|
||||||
|
QTextDocument doc;
|
||||||
|
doc.documentLayout()->setPaintDevice(&writer);
|
||||||
|
|
||||||
|
doc.setUndoRedoEnabled(false);
|
||||||
|
QTextCursor cursor(&doc);
|
||||||
|
QFont font = doc.defaultFont();
|
||||||
|
font.setFamily("Calibri");
|
||||||
|
font.setPointSize(8);
|
||||||
|
doc.setDefaultFont(font);
|
||||||
|
|
||||||
|
cursor.insertText(QString::fromStdWString(L"기초하며, 베어링제조업체와 타\n"));
|
||||||
|
doc.print(&writer);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QPdfWriter)
|
QTEST_MAIN(tst_QPdfWriter)
|
||||||
|
|
||||||
#include "tst_qpdfwriter.moc"
|
#include "tst_qpdfwriter.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user