[Qt-interest] Default application Font
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Thu Jan 29 15:51:03 CET 2009
Hello Jon,
please write to the list instead ;)
Jon Flowers wrote on Thursday, January 29, 2009 3:01 PM:
> I guess my question now is how to set the default font something
> "closer" to what I would expect. I have moved from the glade/gtk+
> environment and when a font gets set it is that way no matter the
> machine it gets run on,
I doubt that very much: the font matching is typically implemented by http://www.freetype.org/ (which on Unix/Linux is what Qt is using as well, IIRC), or in other words: which font is taken when you say "Helvetica" is really decided on a "system level" (or lets say "display manger level"). Off course Qt itself might still do some funky stuff, e.g. replace fonts on its own etc., but that's not the point here.
The point is, regardless of which toolkit you are using (GTK, Qt, Java Swing apps, ...): Which font your application finally displays is ALWAYS dependent on
- what fonts are installed (which typically varies between Linux distros, or even distro versions)
- and even if the same font set is installed: how the user has setup the "replacement fonts"
- Not to mention if you do "remote X sessions"
- Whether the user has enabled "font anti-aliasing" or not
- etc. etc.
So when you say "I have moved from the glade/gtk+ environment and when a font gets set it is that way no matter the machine it gets run on" I would simply say: "I don't believe you." :)
Off course I do see what you say, that you have *control* over the target machines, in that you can presume that:
- they run exactly the same distro with the same patch level
- they have the same fonts installed
- the font configuration is (or should ;) be the same
- and most importantly: the users get cut their head off IF they change the system ;)
So in that case it is off course reasonable to expect certain behaviour (note that you should STILL be using Qt Layout Managers ;)
> yes these are the same machines that will run
> the new Qt version. I have tried to set the QApplication font and
> this actually works on the dev machine, but does not work on the
> production machine. I can't get the font size to change from 13 to 9
> as I wish.
Hmm, again, I might be completely wrong with my assumptions, but maybe on the target machine there is a "bitmap" font installled which is not resizable to each desired size. Actually I thought Qt would only pick up "scaleable" fonts (at least in Qt 3.x source code I saw something like this, I think), hence Qt would ignore installed bitmap fonts at all. But you never know...
> Also looking at the preferences on that machine
Which preferences?
> its default font is
> sans 10 and I am getting Helvetica 13 in my app.
"Sans" typically doesn't really denote a concrete font installed on any system. It is a generic name for saying "Use a font without (Latin: sans) serifs":
http://en.wikipedia.org/wiki/Sans-serif
But then again, there IS a font called "MS Sans Serif":
http://en.wikipedia.org/wiki/MS_Sans_Serif
So when you request a "Sans" font in your Qt application the underlying font rendering system might come up with "Helvetica" (which is physically present somewhere in the "font path"). Or "Arial"... or "MS Arial"... or... well, you get the point.
So that explains the "Helvetica", but not the font size, which to be honest I have no clue. So really check whether that "Helvetica" really IS freely scaleable (and not a bitmap font). If it is a bitmap font, is would still be very weird, because '10' is kind of a "default" size...
> But I have
> overridden the font to sans serif and that seems to hold, but not the
> size. This is something I 'need' to stay the same on all systems.
Try a different font family name, e.g. "Arial", "Helvetica"... or any font from which you KNOW that it is PHYSICALLY (stored as TTF/OTF file, for example) present on the target system! "Sans" is very unlikely to be present as such, see above, and hence it is kind of random which font you actually get...
Also note that some Linux distros DON'T come with "standard" fonts such as "Arial", "Times", "Courier" and such out of the box (at least not the fonts you'd expect from a Windows system, for example), due to license issues. Usually you have to explicitly install a font package such as "MS TTF Fonts" or something...
An easy way to verify your available fonts is e.g. to launch OpenOffice and check the font selector (to be sure, type some letters and try to scale them to different sizes).
> They are not customized by the users as they are used by many hands,
"Used by many hands", ... hmmmm...
> and they have learned NOT to change the setup.
Did they just LEARN not to change the setup? Or are they actually (technically) PREVENTED from changing the setup? Note that you DON'T need admin rights to install personal fonts and change font settings (KDE offers easy ways to do this, for example) ;)
And my experience shows that "systems which are used by many hands" tend to transform themselves in magical and miraculous ways... ;)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list