Summary

Lars Knoll khtml-devel@kde.org
Fri, 21 Feb 2003 09:14:28 +0100


> I actually hacked our own API into QFont to support multiple families
> (I made a QFontFamily object).  I would love to know what the official
> API is going to be so that we can massage our code into the appropriate
> format (so that it can be merged in to your trunk).

The stuff I have done for Qt-3.2 is rather simple. You can specify a comma 
separated list for QFont::family(). On X11 (and Win) QFont is a synthesized 
font. We use different X11 fonts for the different writing systems (see 
QFont::Script enum). Font matching folows the CSS way. For every writing 
system we go through the list of families and take the first one that can 
render the script (or a fallback).

> QFontMetrics also needs to be able to work with multiple fonts, in an
> extremely complicated fashion.  The rule in CSS is that if you have
> something like:
>
> <span style="font-family: a,b,c">[glyphs from a] [glyphs from c]</span>
>
> The font metrics for the <span> should include ONLY the fonts used by
> the <span> in the metrics computations, so e.g., fm.ascent() would be
> the max of the ascents of fonts A and C.  Even if B is supported by the
> system, it should not be used.

We currently only do that for width calculations. Font metrics as ascent or 
descent are more difficult, as new fonts could be loaded on the fly. 
QFontMetrics::ascent() will therefore only return the ascent of the default 
script (the one corresponding to your locale).

You will get correct results only if you don't rely on the fonts ascent, but 
use QFontMetrics::boundingBox( const QString & )

> Something to think about if you have plans to extend QFontMetrics to
> also work with multiple families.

We have added a new constructor to QFontMetrics and QFontInfo that take an 
additional QFont::Script enum, and will give you information about the font 
picked for that script. This will never be a list of families, but one 
physical font.

> Our QFontMetrics in Safari isn't right yet at the moment.

Neither ours. As I said we'd have to rely on boundingBox() instead of using 
ascent()/descent(). Possible, but some change.

Cheers,
Lars