freetype
[Top][All Lists]
Advanced

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

Re: [ft] Vert advance on line break


From: mpsuzuki
Subject: Re: [ft] Vert advance on line break
Date: Fri, 23 Jan 2009 15:28:50 +0900

Hi,

On Thu, 22 Jan 2009 21:12:52 -0800 (PST)
Disch <address@hidden> wrote:
>My quesiton is:  How do I know how much to increase my Y position by for a
>new line (line break)?

If you're using TrueType or OpenType, please try Line_Gap
values in hhea table

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    TT_HoriHeader                                                      */
  /*                                                                       */
  /* <Description>                                                         */
  /*    A structure used to model a TrueType horizontal header, the `hhea' */
  /*    table, as well as the corresponding horizontal metrics table,      */
  /*    i.e., the `hmtx' table.                                            */
  /*                                                                       */
...
  /*    Line_Gap               :: The font's line gap, i.e., the distance  */
  /*                              to add to the ascender and descender to  */
  /*                              get the BTB, i.e., the                   */
  /*                              baseline-to-baseline distance for the    */
  /*                              font.                                    */

or sTypoLineGap in OS/2 table.

  /*************************************************************************/
  /*                                                                       */
  /* <Struct>                                                              */
  /*    TT_OS2                                                             */
  /*                                                                       */
...
    FT_Short   sTypoLineGap;


For the detailed definitions of these parameters, please
check TrueType specifications available from Microsoft,
Adobe or Apple web site.

>                       I tried using [i]face->size->metrics.height[/i], but
>this seemed far too steep for some fonts (almost like the font was
>double-spaced), and simply doesn't exist at all (is zero) for many, many
>fonts such as Courier, which makes it completely useless for me.

Yeah, it notices the height of glyph, not the space between
the lines. Usually, the calculation of the space between the
lines is not recognized as the role of the fonts.

>This is a seemingly simple question, yet the tutorials fail to mention
>anything about it, the documentation leaves it unclear, and I've even tried
>searching this forum with no success (someone asked the question, then
>replied saying they found the answer -- but never said what the answer is).

Maybe you want to pass "single space" or "double space" to
some FT2 API and receive the appropriate shift from the
previous line to current line, but such 2D layout work is
for more intelligent layout systems. In fact, the LineGaps
in hhea & OS/2 are no more than the minimum space. Some font
file formats does not provide such informations at all. It
would be the reason why FT2 tutorials don't describe line-to-
line process.

Regards,
mpsuzuki




reply via email to

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