简体   繁体   中英

Python - pyqt5 - Alignment of text goes wrong in qtextbrowser when working with a specific font

I have a string array which contains strings of a specific font (සිංහල). When I append those strings to a qtextbroswer , alignment goes wrong as

[this output screenshot.]

I think the caused character for this issue is 'නු'. Because it has higher height than other characters.

Following is the code segment I have used for this.

self.chars = ['වචන', 'වචනා', 'වචනි','වචනී','වචන', 'වචනු', 'වචනූ', 'වචනෙ', 'වචනේ']
self.textBrowser.append(' '.join(x for x in self.chars))

How can I get rid of this issue?

UPDATE:

I uploaded the project here .

steps to run:

  • run test2.py
  • click 'select an image'
  • select any image
  • click 'upload and test'

Now you will see the output.

I fixed the issue by myself. Instead of set font inside a method, I inserted following code into UI itself (using qt designer).

font = QtGui.QFont()
font.setFamily("Iskoola Pota")
font.setPointSize(20)
self.textBrowser.setFont(font)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM