[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] Line space calculation in FT 1

From: Antoine Leca
Subject: Re: [Freetype] Line space calculation in FT 1
Date: Thu, 22 Apr 2004 11:48:22 +0200

Hi Rob,

On Thursday, April 22, 2004 8:06 AM
Rob Kramer <address@hidden> va escriure:

> I hope this mailing list is still alive.. :)

Yes, because it is used for FT2 as well ;-)

However, you should really think about switching to FT2: FT1 is not really
maintained, only the obvious bugs are corrected.

> I'm looking for a way to calculate a good starting value for the
> distance between two baselines. In FT2, i've seen some people use
> some factor of face->size->metrics->height for that. Or perhaps
> FT_FaceRec.height, although I'm not sure how that is different from
> the other height field.
> How can I calculate this height in FT1?

FT1 is Truetype only. Hence baseline distance is much easier to sort out,
there is less possible variation.

Basically, you should follow Microsoft's rules here:

It is expressed for font designers, so you should read it backwards, but it
should give you the result;

If there is an OS/2 table, Windows-flavour (prop->os2->version != 0xFFFF),
you can use it:

sTypoAscender, sTypoDescender and sTypoLineGap specify the recommended line
spacing for single-spaced horizontal text. The baseline-to-baseline value is
expressed by:

prop->os2->sTypoAscender - prop->os2->sTypoDescender +


However, for reasons known only to themselves, Windows designers did use a
formula a bit more complex:
prop->os2->usWinAscent + prop->os2->usWinDescent
    + MAX(0, prop->os2->sTypoLineGap
        - ((prop->os2->usWinAscent + prop->os2->usWinDescent)
            - (prop->horizontal->Ascender - prop->horizontal->Descender)))

Beware on the units: os2 fields are integers, horizontal ones are

When there is no OS/2 table (prop->os2->version == 0xFFFF), or when only the
original OS/2-flavour is available (68-byte format; they are not handled
correctly by FreeType; since nobody asks, this is not a problem in
practice), the only remaining way is the traditional Apple one,

prop->horizontal->Ascender + prop->horizontal->Descender +

Please double check the signs: I did copy documentations. If it happens to
be wrong, please feel free to comment here, so this will get recorded.

Hope it helps,


reply via email to

[Prev in Thread] Current Thread [Next in Thread]