Thanks for your response Werner. I thought you pointed me to the
OpenType specification but I didn't know there is a page for
recommendation. My fault.
I have compiled a file documenting different metrics I have come
across (see attached rtf.) As far as I can tell all metrics (except
usWinAscent and usWinDescent) are defined on *all* glyphs on the font
file. I have 2 questions in mind:
1. What is the best way to get the ascent and descent values for Latin
characters? (effectively 'A' to 'Z' and 'a' to 'z'.)
2. What is "AFM file" as mentioned in sTypoAscender and sTypoDescender
documentation?
Thanks again,
Anson
On 5/25/05, Werner LEMBERG <[EMAIL PROTECTED]> wrote:
>
> > By far I have found 3 sets of ascent/descent/height metrics. We
> > have ascender/descender/height from FT_Face. We have
> > ascender/descender/height from FT_Size_Metrics. We also have
> > sTypoAscender/sTypoDescender from TT_Face. How do they differ from
> > each other?
>
> You haven't yet read the documentation files I've pointed to, right?
>
> From http://www.microsoft.com/OpenType/OTSpec/recom.htm:
>
> sTypoAscender is used to determine the optimum offset from the top
> of a text frame to the first baseline. sTypoDescender is used to
> determine the optimum offset from the last baseline to the bottom of
> the text frame. The value of (sTypoAscender - sTypoDescender) is
> recommended to equal one em. [...]
>
> For Western fonts, the Ascender and Descender fields in Type 1
> fonts' AFM files are a good source of sTypoAscender and
> sTypoDescender, respectively. The Minion Pro font family (designed
> on a 1000-unit em), for example, sets sTypoAscender = 727 and
> sTypoDescender = -273.
>
> sTypoAscender, sTypoDescender and sTypoLineGap specify the
> recommended line spacing for single-spaced horizontal text. The
> baseline-to-baseline value is expressed by:
>
> OS/2.sTypoAscender - OS/2.sTypoDescender + OS/2.sTypoLineGap
>
> sTypoLineGap will usually be set by the font developer such that the
> value of the above expression is approximately 120% of the em. The
> application can use this value as the default horizontal line
> spacing. The Minion Pro font family (designed on a 1000-unit em),
> for example, sets sTypoLineGap = 200.
>
> On this page you find more details how the various metrics data
> *within an OpenType file* differ.
>
> A complete description of FreeType's glyph metrics can be found at
> http://freetype.freedesktop.org/freetype2/docs/glyphs/glyphs-3.html.
> In case this file doesn't explain everything, it is a bug in the
> documentation, and I ask you to send questions (again) to the
> freetype-devel list so that it is going to be fixed.
>
>
> Werner
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
\viewkind4\uc1\pard\b\f0\fs20 1. Ascender\b0\par
\par
\b FT_Face\b0 - The face's ascender is the vertical distance from the baseline to the topmost point of \b any\b0 glyph in the face. This field's value is positive, expressed in \b font units\b0 . Some font designs use a value different from `bbox.yMax'. Only relevant for scalable formats.\par
\par
\b FT_Size_Metrics\b0 - Scaled versions of 'face->ascender'. Expressed in \b 26.6\b0 fixed point pixels. Positive for ascenders above the baseline.\par
\par
\b hhea\b0 - Distance from baseline of highest ascender.\par
\par
\b sTypoAscender\b0 - The typographic ascender for this font. Remember that this is not the same as the Ascender value in the 'hhea' table, which Apple defines in a far different manner. One good source for sTypoAscender in \b Latin based\b0 fonts is the Ascender value from an AFM file.\par
\par
\b usWinAscent\b0 - The ascender metric for Windows. This, too, is distinct from Apple's Ascender value and from the sTypoAscender values. usWinAscent is computed as the \b yMax for all characters in the Windows ANSI character set\b0 . usWinAscent is used to compute the Windows font height and default line spacing. For platform 3 encoding 0 fonts, it is the same as yMax. Windows will clip the bitmap of any portion of a glyph that appears above this value. Some applications use this value to determine default line spacing. This is strongly discouraged. The typographic ascender, descender and line gap fields in conjunction with unitsPerEm should be used for this purpose. Developers should set this field keeping the above factors in mind. \par
If any clipping is unacceptable, then the value should be set to yMax. However, if a developer desires to provide appropriate default line spacing using this field, for those applications that continue to use this field for doing so (against OpenType recommendations), then the value should be set appropriately. In such a case, it may result in some glyph bitmaps being clipped.\par
\par
\par
\b 2. Descender\b0\par
\par
\b FT_Face\b0 - The face's descender is the vertical distance from the baseline to the bottommost point of \b any\b0 glyph in the face. This field's value is negative for values below the baseline. It is expressed in \b font units\b0 . Some font designs use a value different from `bbox.yMin'. Only relevant for scalable formats.\par
\par
\b FT_Size_Metrics\b0 - Scaled versions of 'face->descender'. Expressed in \b 26.6\b0 fixed point pixels. Negative for descenders below the baseline.\par
\par
\b hhea\b0 - Distance from baseline of lowest descender.\par
\par
\b sTypoDescender\b0 - The typographic descender for this font. Remember that this is not the same as the Descender value in the 'hhea' table, which Apple defines in a far different manner. One good source for sTypoDescender in \b Latin based\b0 fonts is the Descender value from an AFM file.\par
\par
\b usWinDescent\b0 - The descender metric for Windows. This, too, is distinct from Apple's Descender value and from the sTypoDescender values. usWinDescent is computed as the \b -yMin for all characters in the Windows ANSI character set\b0 . usWinDescent is used to compute the Windows font height and default line spacing. For platform 3 encoding 0 fonts, it is the same as -yMin. Windows will clip the bitmap of any portion of a glyph that appears below this value. Some applications use this value to determine default line spacing. This is strongly discouraged. The typographic ascender, descender and line gap fields in conjunction with unitsPerEm should be used for this purpose. Developers should set this field keeping the above factors in mind. \par
If any clipping is unacceptable, then the value should be set to yMin. However, if a developer desires to provide appropriate default line spacing using this field, for those applications that continue to use this field for doing so (against OpenType recommendations), then the value should be set appropriately. In such a case, it may result in some glyph bitmaps being clipped.\par
\par
\par
\b 3. Height\b0\par
\par
\b FT_Face\b0 - The face's height is the vertical distance from \b one baseline to the next\b0 when writing several lines of text. Its value is always positive, expressed in \b font units\b0 . The value can be computed as 'ascender+descender+\b line_gap\b0 ' where the value of `line_gap' is also called 'external leading'. Only relevant for scalable formats.\par
\par
\b FT_Size_Metrics\b0 - Scaled versions of 'face->height'. Expressed in \b 26.6\b0 fixed point pixels. Always positive.\par
\par
\par
\b 4. Line Gap\b0\par
\par
\b sTypoLineGap\b0 - The typographic line gap for this font. Remember that this is not the same as the LineGap value in the 'hhea' table, which Apple defines in a far different manner.\par
\par
\b hhea\b0 - typographic line gap.\par
\par
\par
\b 5. Notes not to be forgotten\b0\par
\par
\b FT_Size_Metrics\b0 - Unfortunately, due to glyph hinting, these values might not be exact for certain fonts. Thus they must be treated as unreliable with an error margin of at least one pixel! Indeed, the only way to get the exact pixel ascender and descender is to render _\b all\b0 _ glyphs. As this would be a definite performance hit, it is up to client applications to perform such computations.\par
\par
\b hhea\b0 - The values for ascent, descent and lineGap represent the design intentions of the font's creator rather than any computed value.\par
\par
}
_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype