freetype
[Top][All Lists]
Advanced

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

Ascender and VisualAscender and Centering Text Vertically


From: Feinberg, Matthew
Subject: Ascender and VisualAscender and Centering Text Vertically
Date: Mon, 9 Oct 2000 12:37:13 -0400

I'm working on an application that uses FreeType.  One component of this
application has to draw buttons for a user interface.  The component is
passed a string of text, a font name and a point size.

The problem I'm running into is that it has to display the text centered
in the button, and I can't find a good generic way of doing it.

If I place the text baseline at:

   ButtonHeight/2  -  face->height/2

The text doesn't appear properly because face->height really doesn't
have any direct relationship to the *visual* height of the character,
which is what I need to center on.

I tried this:

   ButtonHeight/2  -  face->ascender/2

Hoping to center the ascender in the button (which is really what I
want; that looks correct).

Unfortunately, the visual ascender of the font seems to be usually
something shorter than face->ascender.  What I really need to determine
(I think) is the distance from the baseline to the top of a typical
capital letter.

The TrueType format seems to define this as VisualAscender, but I can't
see how to access this through the FreeType 2.0 API, and even if I could
access it, it appears to be TrueType specific, and I need something that
will work for all font formats that FreeType supports.

Is this information even available in all formats?

If not, can the information be retrieved using the autohinter?  If I
understand correctly, the autohinter has to scan the font and gather
metrics like this anyway in order to calculate blue zones for
autohinting.  Is this information available via the public API or can it
be made available?

Thanks!

--
Matthew A. Feinberg
Lead Programmer
Catharon Productions, Inc.
2119 Route 66, Ghent, NY 12075, USA

E-Mail:  address@hidden
Web:  http://www.catharon.com

Tel: (518)392-9003
Fax: (518)392-6444




reply via email to

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