Using Linux fonts for Qt application[solved]
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
very very old Qt version...
One other question: Do you use Qt/X11 or Qt/Embedded?
Thanks for quick response.
Well, I am new to Qt. mine is a desktop application, so I think its Qt/X11
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.
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?
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.
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
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 ?
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)