Add lancelot tests to verify vertical alignment of inline images
Adds a test case for 199f9c5448.
Task-number: QTBUG-59310
Change-Id: Iee26f8bc21884da36471935f64524b62c3f79ff4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
bb10
parent
5d276d6a1d
commit
86aabb500c
|
|
@ -36,6 +36,7 @@
|
|||
#include <qtextlayout.h>
|
||||
#include <qdebug.h>
|
||||
#include <QStaticText>
|
||||
#include <QTextDocument>
|
||||
#include <private/qimage_p.h>
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
|
|
@ -441,6 +442,10 @@ void PaintCommands::staticInit()
|
|||
"^drawStaticText\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
|
||||
"drawStaticText <x> <y> <text>",
|
||||
"drawStaticText 10 10 \"my text\"");
|
||||
DECL_PAINTCOMMAND("drawTextDocument", command_drawTextDocument,
|
||||
"^drawTextDocument\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
|
||||
"drawTextDocument <x> <y> <html>",
|
||||
"drawTextDocument 10 10 \"html\"");
|
||||
DECL_PAINTCOMMAND("drawTiledPixmap", command_drawTiledPixmap,
|
||||
"^drawTiledPixmap\\s+([\\w.:\\/]*)"
|
||||
"\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)\\s*(-?\\w*)"
|
||||
|
|
@ -1295,6 +1300,29 @@ void PaintCommands::command_drawStaticText(QRegularExpressionMatch re)
|
|||
m_painter->drawStaticText(x, y, QStaticText(txt));
|
||||
}
|
||||
|
||||
void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re)
|
||||
{
|
||||
if (!m_shouldDrawText)
|
||||
return;
|
||||
QStringList caps = re.capturedTexts();
|
||||
int x = convertToInt(caps.at(1));
|
||||
int y = convertToInt(caps.at(2));
|
||||
QString txt = caps.at(3);
|
||||
|
||||
if (m_verboseMode)
|
||||
printf(" -(lance) drawTextDocument(%d, %d, %s)\n", x, y, qPrintable(txt));
|
||||
|
||||
QTextDocument doc;
|
||||
doc.setBaseUrl(QUrl::fromLocalFile(QDir::currentPath() + QLatin1String("/")));
|
||||
doc.setHtml(txt);
|
||||
|
||||
m_painter->save();
|
||||
m_painter->translate(x, y);
|
||||
doc.drawContents(m_painter);
|
||||
m_painter->restore();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************************************/
|
||||
void PaintCommands::command_noop(QRegularExpressionMatch)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ private:
|
|||
void command_drawRoundRect(QRegularExpressionMatch re);
|
||||
void command_drawText(QRegularExpressionMatch re);
|
||||
void command_drawStaticText(QRegularExpressionMatch re);
|
||||
void command_drawTextDocument(QRegularExpressionMatch re);
|
||||
void command_drawTiledPixmap(QRegularExpressionMatch re);
|
||||
void command_path_addEllipse(QRegularExpressionMatch re);
|
||||
void command_path_addPolygon(QRegularExpressionMatch re);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
drawTextDocument 10 10 "<img height=50 width=50 align=top src=:/images/border.png /><img height=10 width=10 valign=bottom src=:/images/border.png /><span style='font-size: 100px'>Xy</span>"
|
||||
drawTextDocument 10 210 "<img height=50 width=50 align=top src=:/images/border.png /><img height=10 width=10 valign=bottom src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
drawTextDocument 310 210 "<img height=10 width=10 align=top src=:/images/border.png /><img height=50 width=50 valign=bottom src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
drawTextDocument 10 310 "<img height=50 width=50 align=top src=:/images/border.png /><img height=50 width=50 valign=bottom src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
|
||||
drawTextDocument 10 410 "<img height=10 width=10 align=top src=:/images/border.png /><img height=50 width=50 src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
drawTextDocument 10 510 "<img height=10 width=10 valign=bottom src=:/images/border.png /><img height=50 width=50 src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
drawTextDocument 310 410 "<img height=50 width=50 align=top src=:/images/border.png /><img height=10 width=10 src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
drawTextDocument 310 510 "<img height=50 width=50 valign=bottom src=:/images/border.png /><img height=10 width=10 src=:/images/border.png /><span style='font-size: 25px'>Xy</span>"
|
||||
Loading…
Reference in New Issue