Hi, I'm having a problem getting QTextEdit to render a colored font which is preceded by whitespace. It renders with the appearance of each whitespace character overwriting other characters in the string. An example of the problem is ...

Qt Code:
  1. import sys
  2. from PyQt5.QtWidgets import QApplication, QTextEdit
  3.  
  4. app = QApplication(sys.argv)
  5. editor = QTextEdit()
  6.  
  7. editor.insertHtml('&nbsp;<font color="Red">HELP</font>&nbsp;<br>')
  8. editor.insertHtml('&nbsp;&nbsp;<font color="Red">HELP</font>&nbsp;<br>')
  9. editor.insertHtml('&nbsp;&nbsp;&nbsp;<font color="Red">HELP</font>&nbsp;<br>')
  10. editor.insertHtml('&nbsp;&nbsp;&nbsp;&nbsp;<font color="Red">HELP</font>&nbsp;<br>')
  11.  
  12. editor.show()
  13. app.exec_()
To copy to clipboard, switch view to plain text mode 

I would expect to get output of ...

Qt Code:
  1. HELP
  2. HELP
  3. HELP
  4. HELP
To copy to clipboard, switch view to plain text mode 

But the actual visible output is ...

Qt Code:
  1. HELP
  2. HEL
  3. HE
  4. H
To copy to clipboard, switch view to plain text mode 

Removing the trailing &nbsp; does render the output as expected but is required in the real code for formatting.

Any advice to get this working would be much appreciated.