[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] How to determine font ascent
From: |
Werner LEMBERG |
Subject: |
Re: [ft] How to determine font ascent |
Date: |
Wed, 12 Oct 2005 08:59:19 +0200 (CEST) |
> In order to correctly display glyphs I need to know somehow the
> baseline and the "top baseline" (don't know the correct term, the
> term "ascent" seems used for many things that aren't what I mean) of
> the font. For example, if you don't understand what I mean,
> fontforge displays these two horizontal lines with thin gray lines,
> and even shows the "top baseline" Y coord in the Font Info -> Common
> -> Ascent entry.
This information is not available for all fonts, thus FreeType doesn't
expose it.
> The FT_Face structure contains the max bounding box (bbox) of all
> the character in the font, and the ascender/descender values;
> however these are not the values I'm looking for - the 'ascender'
> value given by freetype is the highest point even hit by a single
> character, and not the "top value" intended for normal characters,
> but which can be exceeded by e.g. diacritics.
I think you are looking for something you don't need at all.
> I need this to properly vertically center a character, otherwise I get
> what you can see on this screenshot:
>
> http://cs.ozerki.net/zap/ttf/dejavu-sans.png
>
> The only way I can think of to achieve vertical centering is to know
> how much of a character may go below the baseline (here the
> "descender" value works fine, provided baseline is always at 0 (is
> this true?)). And if I also will know how much a character may go
> *above* the *top baseline*, I can take the biggest of these two
> values and add such an amount of space below the bottom baseline,
> and above the top baseline, thus glyphs will look vertically
> centered.
The concept of `vertically centering' is wrong IMHO. Instead, I
suggest you arrange the menu items as if they were normal text, this
is, you put the glyphs of a line onto its baseline, and the glyphs one
line above with a distance of FT_Face->height from the previous
baseline. This assures that
. all lines of the menu have the same vertical distance
. you use the typographically correct distance the font has been
designed with
. it works even for glyphs like `(' and `)' which often extend the
font's default ascent or descent value
. it works with all font formats
Werner