Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QFontDatabase doesn't give me a fixed font (LUbuntu 18.10)



  • Maybe someone could assist me with this problem. I want to print something with a fixed font. So I let me give a fixed font from the system with
    QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
    and set this with myQPainter.setFont(fixedFont).
    This works on my Arch Linux as expected. So does it on Windows 10. And I'm quite sure it did on LUbuntu 18.04. Now I tried it on the latest LUbuntu 18.10 which comes with Qt 5.11.1. And it doesn't work. Instead, it uses a proportional font. So what could be the problem here?


  • Lifetime Qt Champion

    Hi,

    Might be a silly question but did you check that you have indeed a fixed font installed on your LUbuntu box ?



  • @SGaist said in QFontDatabase doesn't give me a fixed font (LUbuntu 18.10):

    Might be a silly question but did you check that you have indeed a fixed font installed on your LUbuntu box ?

    Yes, I did check that. And I guess this is related to QTBUG-54623. What I do now after QFontDatabase::systemFont(...):

    if (fixedFont.fixedPitch() == false) { // workaround for QTBUG-54623
       fixedFont.setFamily("monospace");
    }
    

    This works and gives me the desired fixed font.


  • Lifetime Qt Champion

    Glad you found a workaround and thank for sharing !

    You should also add it to the bug report, this might help other people.


Log in to reply