The problem is that the red box should enclose the text in this image:
test.png
from the test code:
#include <QApplication>
#include <QPixmap>
#include <QPainter>
#include <QFont>
#include <QDebug>
int main(int argc, char **argv)
{
// Your text
"\xE0\xBD\x96\xE0\xBD\xA6\xE0\xBE\x90\xE0\xBE\xB1\xE0\xBD\xBC\xE0\xBD\x84\xE0\xBD\xA6"
// Your complex text
"\xE0\xBD\xA7\xE0\xBE\xB9\xE0\xBE\xA8\xE0\xBE\xB3\xE0\xBE\xBA\xE0\xBE\xBC"
"\xE0\xBE\xBB\xE0\xBE\x83\xE0\xBC\x8B\xE0\xBD\x8A\xE0\xBE\x9B\xE0\xBE\x9C"
"\xE0\xBE\x9D\xE0\xBE\x9E\xE0\xBD\xB1\xE0\xBC\x8B"
);
QFont font
("Microsoft Himalaya",
30);
pixmap.fill(Qt::white);
p.setFont(font);
p.drawText(pixmap.rect(), Qt::AlignLeft | Qt::AlignTop, text, &br);
p.setPen(Qt::red);
p.drawRect(br);
p.end();
qDebug() << br;
pixmap.save("test.png");
return 0;
}
#include <QApplication>
#include <QPixmap>
#include <QPainter>
#include <QFont>
#include <QDebug>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
const QString text = QString::fromUtf8(
// Your text
"\xE0\xBD\x96\xE0\xBD\xA6\xE0\xBE\x90\xE0\xBE\xB1\xE0\xBD\xBC\xE0\xBD\x84\xE0\xBD\xA6"
// Your complex text
"\xE0\xBD\xA7\xE0\xBE\xB9\xE0\xBE\xA8\xE0\xBE\xB3\xE0\xBE\xBA\xE0\xBE\xBC"
"\xE0\xBE\xBB\xE0\xBE\x83\xE0\xBC\x8B\xE0\xBD\x8A\xE0\xBE\x9B\xE0\xBE\x9C"
"\xE0\xBE\x9D\xE0\xBE\x9E\xE0\xBD\xB1\xE0\xBC\x8B"
);
QFont font("Microsoft Himalaya", 30);
QPixmap pixmap(200, 100);
pixmap.fill(Qt::white);
QPainter p(&pixmap);
p.setFont(font);
QRect br;
p.drawText(pixmap.rect(), Qt::AlignLeft | Qt::AlignTop, text, &br);
p.setPen(Qt::red);
p.drawRect(br);
p.end();
qDebug() << br;
pixmap.save("test.png");
return 0;
}
To copy to clipboard, switch view to plain text mode
and it does not (Linux Qt 4.8.5 and 5.2.0). I would call this a bug but perhaps someone with more non-Latin text rendering experience has an insight.
I used to think boustrophedon was exotic.
Bookmarks