[Qt-interest] QFont - Sans Serif and Monospace for all Plattforms

suzuki toshiya mpsuzuki at hiroshima-u.ac.jp
Wed Oct 12 04:38:10 CEST 2011


Hi Till,

Thank you for clarification that "Monospace" for GNU/Linux is
not the family (it's a predefined alias of fontconfig, so
it is unavailable if Qt is configured not to use fontconfig).

In my understanding, Kluger request is a portable (platform-
independent) method to find a font face with fixed pitch AND
without serif.

According to QFont::StyleHint (in qfont.h),

public:
    enum StyleHint {
        Helvetica,  SansSerif = Helvetica,
        Times,      Serif = Times,
        Courier,    TypeWriter = Courier,
        OldEnglish, Decorative = OldEnglish,
        System,
        AnyStyle,
        Cursive,
        Monospace,
        Fantasy
    };

I'm afraid that setting style for QFont object cannot specify
both of sans serif and monospace at the same time, and more work
is expected.

Something like, getting a list of sans serif fonts and pick up
a monospaced font in it, or, getting a list of monospaced fonts
and pick up a sans serif font in it, or, calculating a cross
section of the sans serif font list & the monospaced font list.

Although "serif/sans serif" and "proportional/fixed pitched"
are mutually independent attribute, there are so many font systems
dealing as if serif/sans serif/monospace are exclusive attributes,
like CSS:
(http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#generic-font-families)

Both of Win32 and fontconfig do not provide quick method to
check "this font (obtained by specifying monospace) has serif?" or
"this font (obtained by specifying sans serif) is monospaced?".

If we could restrict our scope to ISO/IEC 14496-22 compatible
TrueType/OpenType fonts, it is possible to check serif & pitch
by Panose parameters in OS/2 table, but there might be some latency
to check these values.

Yet I've not checked whether accessing Panose via Win32 causes
some slowdown, but accessing Panose on fontconfig based fontengines
will cause some slowdown. fontconfig does not cache Panose parameter
in its database, so the opening/closing the font file is needed.
Crawling all font files will cause some slowdown. I've ever proposed
a patch to cache Panose values in fontconfig database, but the
maintainers response was something like "the requirement is unclear".

Regards,
mpsuzuki

Till Oliver Knoll wrote:
> 
> Am 11.10.2011 um 17:32 schrieb "Kluger, Peter" <Peter.Kluger at SIMPACK.de>:
> 
>>
>> I would have like to avoid an ifdef which is what i do now using setFamily("Lucida Console") for
>> Windows and setFamily("Monospace") for UNIX, 
> 
> Well, as already answered: "Monospace" is NOT a family, it is a style. So did you try QFont::setFontStyle instead? What was the outcome?
> 
> Cheers, Oliver
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list