Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-1423

text rotation quality

    XMLWordPrintable

Details

    Description

      When drawing texts on frame buffer with rotations, some characters may not be well positioned. For example, in string "Mulberry", the two "r"s will be too close with some rotation angles. Is it possible to fix this drawing quality problem in the embedded side?

      Below is an example to reproduce this problem (run on Qtopia Core 4.3.0 with QVFb 480x272, 32 bit):

      class TextRenderer : public QWidget
      {
      protected:
      virtual void paintEvent(QPaintEvent *event)
      {
      int stringCount = 50;
      const QString c_TestString = "Mulberry";
      QVector<QPoint> points;
      QVector<int> angles;
      // leave a border to prevent going off edge
      QFont defaultFont;
      QFontMetrics fontMetrics(defaultFont);
      int stringWidth = fontMetrics.width(c_TestString);
      for (int i=0; i<stringCount; i++)

      { QPoint pt(rand() % (width()-stringWidth), stringWidth/2 + rand() % (height()-stringWidth)); points.push_back(pt); angles.push_back((rand() % 180) - 90); }

      QPen pen(Qt::lightGray);
      QPainter painter(this);
      painter.fillRect(rect(), Qt::white);
      painter.setPen(pen);
      int i=0;
      foreach(const QPoint &point, points)

      { QMatrix matrix; matrix.translate(point.x(), point.y()); matrix.rotate(-angles[i++]); matrix.translate(-point.x(), -point.y()); painter.setWorldMatrix(matrix); QRect bBox = painter.boundingRect(QRect(point, QSize()), Qt::AlignLeft | Qt::AlignBottom, c_TestString); painter.drawText(bBox, c_TestString); painter.resetMatrix(); }

      }
      };

      int main(int argc, char **argv)
      {
      QApplication app(argc, argv, QApplication::GuiServer);

      TextRenderer testScreen;
      testScreen.showFullScreen();

      return app.exec();
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            z35liu Zheng Liu (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes