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. Using Linux fonts for Qt application[solved]
Forum Updated to NodeBB v4.3 + New Features

Using Linux fonts for Qt application[solved]

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 10.8k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    vivek.narvekar
    wrote on 2 Aug 2011, 14:19 last edited by
    #1

    I am trying to use the existing fonts from Redhat Linux OS using QApplication::setFont(QFont).
    If I try to use the fonts which appears under font:///, Qt does not consider them, and shows some default font. But if I try to set the font, to some basic font types eg Courier, Time New Roman, such fonts are shown properly in my application.
    Does this mean that Qt can not use the fonts listed under font:/// ?
    I am using Qt3

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 2 Aug 2011, 14:26 last edited by
      #2

      Hi,

      very very old Qt version...

      One other question: Do you use Qt/X11 or Qt/Embedded?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vivek.narvekar
        wrote on 2 Aug 2011, 14:29 last edited by
        #3

        Hello,

        Thanks for quick response.

        Well, I am new to Qt. mine is a desktop application, so I think its Qt/X11

        Thank You

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vivek.narvekar
          wrote on 2 Aug 2011, 14:35 last edited by
          #4

          When I try running same application in windows OS, It properly picks fonts which are listed under C:\WINDOWS\Fonts.
          Basically my problem is that, with the default font, Japanese characters are not rendered correctly, shows boxes. So, If I set the font to MS Gothic on windows, then the Japanese characters are shown properly. Hence I am looking for something similar in Linux.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on 2 Aug 2011, 14:44 last edited by
            #5

            AFAIK QT/X11 uses the installed fonts from the desktop system, so KDE or GNOME or whatever you use.

            May I ask why you use Qt 3 and not Qt 4, which is outs since years?

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vivek.narvekar
              wrote on 2 Aug 2011, 14:56 last edited by
              #6

              The existing application is a huge one, with lot of other dependencies like PyQt, SIP. Migrating entire code to new version is a huge task, and need lot of time, and knowledge of existing code.

              So, as you mention the fonts which are installed by the OS, can be used by Qt ?

              Procedure which I followed to install these fonts was - browse fonts:/// , and copy pasted the new font files (ttf) there.
              After that, I was able to see those font on FireFox browser setting, but, when I try to use them in my Qt application, these fonts are not considered.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on 2 Aug 2011, 15:15 last edited by
                #7

                hm strange.
                you could try to make some "font combo" to check which font's can be used by Qt.
                To fill the combo, use "QFontDatabase::families":http://doc.qt.nokia.com/3.3/qfontdatabase.html#families . perhaps the font you want to use has somespecialities that are not possible in Qt or the name has something special

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vivek.narvekar
                  wrote on 3 Aug 2011, 11:19 last edited by
                  #8

                  tried QFontDatabase::families() to get the list of all the available fonts.
                  The list of fonts obtained were totally different, from what is shown by fontconfig.

                  I used following command to see fontconfig fonts
                  fc-list | sed 's,:.*,,' | sort -u

                  Then compared the fonts listed by this command with the fonts option shown in GEDIT, openoffice, firefox, and the list was same.

                  Whereas, the fonts list which i got from QFontDatabase::families() was totally different.

                  Here is what i got with QFontDatabase::families()

                  Application, Arial [, Arial [Monotype], Book Antiqua, Charter, Clean, Courier New, Courier [Adobe], Courier [Cronyx], Courier[Monotype], Fixed [Cronyx], Fixed [Misc], Fixed [Nec], Fixed [Screen], Fixed [Sony], Helvetica [Adobe], Helvetica [Cronyx], Hp System, Hp User,Interfac
                  e System, Interface User, Lucida, Lucidabright, Lucidasans, Lucidasanstyp, Lucidatypewriter, Menu, Microsoft Sans Serif, New CenturySchoolbook, Nil [Cronyx], Nil [Misc], Open Look Cursor, Open Look Glyph, Prestige, Proof, Roman, Sung, Swiss 742, Symbol [, Symbol [Adobe],Tahoma
                  , Terminal [Bitstream], Terminal [Dec], Times New Roman [, Times New Roman [Monotype], Times [Adobe], Times [Cronyx], Times [Monotype],Timesnewroman, Utopia, Vt, Vt330,

                  So, does Qt 3.0.4, uses fontconfig system to find fonts on Linux ? or is it using something else ?

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vivek.narvekar
                    wrote on 17 Aug 2011, 08:00 last edited by
                    #9

                    Solved. Thanks a lot Gerolf for very useful info.

                    on further investigation, found that qt 3.0.4 version uses core X font subsystem on Linux. Hence it will take the fonts which are installed in core X.

                    Also found that qt 3.3.6 and maybe all the higher versions of qt uses fontconfig subsystem.

                    fontconfig is a new subsystem, and it will eventually replace core x font subsystem (from linux forums)

                    Thanks Gerolf

                    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