title: Error displaying Arabic and English text in the QTextDocument
body: <p>I have a QTextDocument to display HTML codes. When I write a text consisting of a mixture of Arabic and English, for example (Eng - عربي) from right to left, and after execution, this text does not display as required.</p>
  <p>See the picture below for clarification</p>
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport
  from PyQt5.QtGui import QTextDocument
  from PyQt5.QtPrintSupport import QPrinter
  
  class Ui_Form(object):
      def setupUi(self):
          self.handlePreview()
          sys.exit()
  
      def Html(self):
          ht =&quot;&quot;&quot;
          &lt;!DOCTYPE html&gt;
          &lt;html dir=&quot;rtl&quot; style=&quot;font-family: calibri; font-size: 45px;&quot;&gt;
          &lt;body&quot;&gt;
          &lt;p&gt;عربي - Eng&lt;/p&gt;
          &lt;/body&gt;
          &lt;/html&gt;
          &quot;&quot;&quot;
          editor = QTextDocument()
          editor.setHtml(ht)
          editor.print_(self.printer)
  
      def handlePreview(self):
          self.printer = QPrinter()
          dialog = QtPrintSupport.QPrintPreviewDialog(self.printer)
          dialog.setWindowState(QtCore.Qt.WindowMaximized)
          dialog.paintRequested.connect(self.Html)
          dialog.exec_()
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QtWidgets.QApplication(sys.argv)
      Form = QtWidgets.QWidget()
      ui = Ui_Form()
      ui.setupUi()
      Form.show()
      sys.exit(app.exec_())
  </code></pre>
  <p><img src="https://i.stack.imgur.com/WIbit.png" alt="enter image description here" /></p>