Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFontDatabase doesn't give me a fixed font (LUbuntu 18.10)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 574 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    beedaddy
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

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

        B Offline
        B Offline
        beedaddy
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        1
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Glad you found a workaround and thank for sharing !

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved