Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.3.3
-
None
Description
In the example below, the box-character that substitutes glyphs that are not part of the installed fonts
#include <QtGui>
class Widget : public QWidget
{
public:
Widget()
{
}
void setString(const QString &str)
{ string = str; update(); }protected:
void paintEvent(QPaintEvent *event)
{
QPainter painter(this);
int x = 0;
int y = painter.fontMetrics().height();
for (int c = 0; c < string.length(); ++c)
}
private:
QString string;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFont font("Tahoma", 36);
a.setFont(font);
QString unicode;
unicode += QChar(0x0061);
unicode += QChar(0x028c);
unicode += QChar(0x0303);
unicode += QChar(0x0020);
unicode += QChar(0x0303);
unicode += QChar(0x4100);
unicode += QChar(0x901F);
unicode += QChar(0x3100);
unicode += QChar(0x0010);
unicode += QChar(0x00CA);
unicode += QChar(0xF053);
unicode += QChar(0x2112);
unicode += QChar(0x0062);
QLineEdit le;
le.setText(unicode);
QLabel label;
label.setText(unicode);
Widget w;
w.setString(unicode);
w.show();
label.show();
le.show();
return a.exec();
}
When turning font subtitution off, then QLineEdit and QLabel render the text with proper spacing, but QFontMetrics still returns a value that is too small.