title: QPainter drawText() in QGLWidget draw long Chinese text with English upside down
body: <p>I use codes below to draw text in QGLWidget, but when the text is long and mixed Chinese(or Japanese) with English, then the text becomes upside down. Anyone knows why?</p>
  
  <p>PS1: When I change QGLWidget to QWidget, everything is OK.</p>
  
  <p>PS2: My Qt version is 4.8.0, OS is Ubuntu 12.04 64bit</p>
  
  <p>PS3: When I firstly draw the text into an image, then draw that image, everything is ok.</p>
  
  <p>Normal when using QWidget:
  <img src="https://i.imgur.com/4SXXaQ9.png" alt="normal text"></p>
  
  <p>Upside-down when using QGLWidget:
  <img src="https://i.imgur.com/g98BJ0k.png" alt="upside down text"></p>
  
  <p>mainwindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QGLWidget&gt;
  
  class MainWindow : public QGLWidget
  {
  Q_OBJECT
  
  public:
      explicit MainWindow(QGLWidget *parent = 0);
  
  protected:
      void paintEvent(QPaintEvent* event);
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>mainwindow.cpp</p>
  
  <pre><code>MainWindow::MainWindow(QGLWidget *parent) : QGLWidget(parent)
  {
      setGeometry(0, 0, 1000, 200);
  }
  
  void MainWindow::paintEvent(QPaintEvent* event) {
      QPainter painter;
      painter.begin(this);
  
      QString text = QString::fromLocal8Bit(
                  "THIS IS一段A很长的LONG示例文本TEXT。在非常长的时候会出现上下  颠倒的问题。你那里是否出现了？" \
                  "一段很长的示例文本。在非常长的时候会出现上下颠倒的问题。你那里是否出现了？" \
                  "一段很长的示例文本。在非常长的时候会出现上下颠倒的问题。你那里是否出现了？"
                  );
  
      painter.setFont(QFont("default", 46, -1, false));
      painter.drawText(QRect(0, 0, 3000, 200), Qt::TextSingleLine, text);
      painter.end();
  }
  </code></pre>
  
  <p>**</p>
  
  <h2>Edit:</h2>
  
  <p>**</p>
  
  <p>I change font family name "default" to "YaHei Consolas Hybrid", it becomes normal when only drawText once. But When I use codes below to change text at intervals, the Chinese Characters become upside down again...</p>
  
  <p>MainWindow.cpp</p>
  
  <pre><code>#include &lt;QtGui&gt;
  #include "mainwindow.h"
  #include "ui_mainwindow.h"
  
  MainWindow::MainWindow(QGLWidget *parent) : QGLWidget(parent)
  {
      setGeometry(0, 0, 2000, 100);
  
      paintTimer = new QTimer(this);
      connect(paintTimer, SIGNAL(timeout()), this, SLOT(repaint()));
      paintTimer-&gt;start(16);
  
      text1 ="【中文1024测试】ABCDEFGHIJKLMNOPQRSTUVWXYZ中文ABCDEFGHIJKLMNOPQRSTUVWXYZ"\
              "中文ABCDEFGHIJKLMNOPQRSTUVWXYZ中文ABCDEFGHIJKLMN";
  
      text2 = "中文English中文English中文English中文English中文Englis中文";
  
      text = text2;
  
      offset = 0;
  }
  
  void MainWindow::paintEvent(QPaintEvent* event) {
      QPainter painter;
      painter.begin(this);
  
      painter.setFont(QFont("YaHei Consolas Hybrid", 40, -1, false));
      painter.drawText(QRect(0, 0, 3000, 100), Qt::TextSingleLine, text);
      painter.end();
  
      offset= (offset + 8) %400;
  
      if (offset &gt; 200) {
          text = text1;
      } else {
          text = text2;
      }
  }
  </code></pre>
  
  <p>MainWindow.h</p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QGLWidget&gt;
  #include &lt;QTimer&gt;
  #include &lt;QFont&gt;
  
  class MainWindow : public QGLWidget
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QGLWidget *parent = 0);
  
  protected:
      void paintEvent(QPaintEvent* event);
  private:
      QTimer* paintTimer;
      QString text1;
      QString text2;
      QString text;
      int offset;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>