Amharic text and QtLineEdit

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Amharic text and QtLineEdit

Timothy W. Grove

Has anyone ever had trouble displaying Amharic text in a QLineEdit, or had similar issues with other scripts to what I'm describing below?

When typing Amharic text into a QLineEdit on MacOS I'm not seeing the expected text but blocks of horizontal lines in place of each character. If I copy those blocks and paste them into some other (non-pyqt) application the Amharic text appears. Conversely, if I type well-formed Amharic text in another application and copy-and-paste that back into my pyqt application, only those blocks of lines appear.

Something similar happens under Windows. (I can't repeat this myself, but it's reported by another user) When Amharic is typed blank spaces appear, like typing white text onto a white background. Again, the same results as above for copying and pasting.

My input method for MacOS is Keyman with SIL-Ethiopic (https://keyman.com/macos/).

I made a simple example below which only uses a dialog containing one QLineInput, where the problem can be seen.

from PyQt5.QtWidgets import QDialog, QApplication, QLineEdit

class TestDlg(QDialog):
    def __init__(self):       
        super(TestDlg, self).__init__()
        le = QLineEdit(self)
       
app = QApplication([])       
dlg = TestDlg()
if dlg.exec_():
    pass
app.exec_()


Not much to go on, but I'm hoping that someone somewhere has seen something like this before.

Best regards,
Tim


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Amharic text and QtLineEdit

Zachary Quinn Scheuren
Hi Tim,

I've had this problem before when trying to support multiple scripts and customize them in different ways. In your example since the QLineEdit isn't getting an appropriate font you can do it by explicitly setting a font or setting up appropriate styles for fallback, etc as explained at https://doc.qt.io/qt-5/qfont.html

For a quick test on macOS I added

le.setFont('Kefa') 

and that forced the QLineEdit to use the installed Kefa font. I also tried with 'Noto Sans Ethiopic' and that worked, too. 
It does seem like a bug that the font matching algorithm fails to find a suitable font when you know one exists, but I always just set it myself or gave users the option to use whatever font they wanted.

Hope that helps.

Zachary


On Tue, Mar 13, 2018 at 9:31 AM, Timothy W. Grove <[hidden email]> wrote:

Has anyone ever had trouble displaying Amharic text in a QLineEdit, or had similar issues with other scripts to what I'm describing below?

When typing Amharic text into a QLineEdit on MacOS I'm not seeing the expected text but blocks of horizontal lines in place of each character. If I copy those blocks and paste them into some other (non-pyqt) application the Amharic text appears. Conversely, if I type well-formed Amharic text in another application and copy-and-paste that back into my pyqt application, only those blocks of lines appear.

Something similar happens under Windows. (I can't repeat this myself, but it's reported by another user) When Amharic is typed blank spaces appear, like typing white text onto a white background. Again, the same results as above for copying and pasting.

My input method for MacOS is Keyman with SIL-Ethiopic (https://keyman.com/macos/).

I made a simple example below which only uses a dialog containing one QLineInput, where the problem can be seen.

from PyQt5.QtWidgets import QDialog, QApplication, QLineEdit

class TestDlg(QDialog):
    def __init__(self):       
        super(TestDlg, self).__init__()
        le = QLineEdit(self)
       
app = QApplication([])       
dlg = TestDlg()
if dlg.exec_():
    pass
app.exec_()


Not much to go on, but I'm hoping that someone somewhere has seen something like this before.

Best regards,
Tim


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Amharic text and QtLineEdit

Timothy W. Grove

Hello Zachary,

Thank you for your reply and for your solution; it works great! The only amendment to your quick test needed was to create a QFont object first and then set it:

f = QFont('Kefa')
le.setFont(f)

Best regards,

Tim


On 14/03/2018 00:09, Zachary Scheuren wrote:
Hi Tim,

I've had this problem before when trying to support multiple scripts and customize them in different ways. In your example since the QLineEdit isn't getting an appropriate font you can do it by explicitly setting a font or setting up appropriate styles for fallback, etc as explained at https://doc.qt.io/qt-5/qfont.html

For a quick test on macOS I added

le.setFont('Kefa') 

and that forced the QLineEdit to use the installed Kefa font. I also tried with 'Noto Sans Ethiopic' and that worked, too. 
It does seem like a bug that the font matching algorithm fails to find a suitable font when you know one exists, but I always just set it myself or gave users the option to use whatever font they wanted.

Hope that helps.

Zachary


On Tue, Mar 13, 2018 at 9:31 AM, Timothy W. Grove <[hidden email]> wrote:

Has anyone ever had trouble displaying Amharic text in a QLineEdit, or had similar issues with other scripts to what I'm describing below?

When typing Amharic text into a QLineEdit on MacOS I'm not seeing the expected text but blocks of horizontal lines in place of each character. If I copy those blocks and paste them into some other (non-pyqt) application the Amharic text appears. Conversely, if I type well-formed Amharic text in another application and copy-and-paste that back into my pyqt application, only those blocks of lines appear.

Something similar happens under Windows. (I can't repeat this myself, but it's reported by another user) When Amharic is typed blank spaces appear, like typing white text onto a white background. Again, the same results as above for copying and pasting.

My input method for MacOS is Keyman with SIL-Ethiopic (https://keyman.com/macos/).

I made a simple example below which only uses a dialog containing one QLineInput, where the problem can be seen.

from PyQt5.QtWidgets import QDialog, QApplication, QLineEdit

class TestDlg(QDialog):
    def __init__(self):       
        super(TestDlg, self).__init__()
        le = QLineEdit(self)
       
app = QApplication([])       
dlg = TestDlg()
if dlg.exec_():
    pass
app.exec_()


Not much to go on, but I'm hoping that someone somewhere has seen something like this before.

Best regards,
Tim


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt



_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt