0

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.

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42
  • 1
    That error does not appear in PyQt5 5.10.1 as I show the following images: https://imgur.com/a/5PMZu – eyllanesc Apr 17 '18 at 05:59
  • I'm using PyQt5 5.10.1 . Which point size did you use? I use PointSize 20. – Ishara Madhawa Apr 17 '18 at 06:03
  • Using `self.textBrowser.setFontPointSize(20)` https://imgur.com/a/4SAAX – eyllanesc Apr 17 '18 at 06:06
  • @eyllanesc I'm still getting that alignment problem. Can it be because of property values of the qtextbrowser? I made UI using 'qt designer'. But I keep default property values as it is. – Ishara Madhawa Apr 17 '18 at 08:52
  • @eyllanesc please check the update. – Ishara Madhawa Apr 17 '18 at 09:12
  • 1
    with PyQt 5.10.1 and Python 3.6.5: https://imgur.com/a/papNE – eyllanesc Apr 17 '18 at 09:16
  • @IsharaMadhawa. It is not acceptable to post links to rar files. Copy and paste all the relevant code into your question. – ekhumoro Apr 17 '18 at 17:10
  • @IsharaMadhawa. Please also state which platform you are on and which specific font(s) you are using. – ekhumoro Apr 17 '18 at 17:19
  • @ekhumoro I'm on Windows , I'm using PyQt 5.10.1 and Python 3.6.4. I have mentioned the string array I use and you can see which font I have used. – Ishara Madhawa Apr 17 '18 at 17:27
  • @IsharaMadhawa. Yes, but what is the **name** of that font? What is the output of `print(self.textBrowser.font().family())`? Have you tried using other fonts? – ekhumoro Apr 17 '18 at 17:30
  • @ekhumoro Font name is 'Iskoola Pota'. I used English and It works fine. output for `print(self.textBrowser.font().family())` is 'MS Shell Dlg 2' – Ishara Madhawa Apr 17 '18 at 17:35
  • @IsharaMadhawa. I cannot reproduce the problem. It works fine using a DejuVu Sans Serif font. I suggest you try using some other fonts, as that is the most common cause of problems like this. – ekhumoro Apr 17 '18 at 17:40
  • @ekhumoro Thank you for the support. I'll update if there is any improvements. – Ishara Madhawa Apr 17 '18 at 17:44
  • @IsharaMadhawa. 'MS Shell Dlg 2' is the fallback font on windows, so Qt is not actually using 'Iskoola Pota'. I strongly recommend that you try some other fonts that have good unicode support. – ekhumoro Apr 17 '18 at 17:45
  • @ekhumoro I fixed the issue. check my answer. The other thing is Qt supports 'Iskoola Pota' font. – Ishara Madhawa Apr 22 '18 at 11:10

1 Answers1

0

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)

Ishara Madhawa
  • 3,549
  • 5
  • 24
  • 42